container.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __LIBT2N_CONTAINER
00023 #define __LIBT2N_CONTAINER
00024
00025 #include <boost/archive/binary_oarchive.hpp>
00026 #include <boost/archive/binary_iarchive.hpp>
00027 #include <boost/archive/xml_oarchive.hpp>
00028 #include <boost/archive/xml_iarchive.hpp>
00029 #include <boost/serialization/serialization.hpp>
00030
00031 #include "command.hxx"
00032 #include "t2n_exception.hxx"
00033
00034 #include <iostream>
00035
00036 namespace libt2n
00037 {
00038
00041 class result_container
00042 {
00043 private:
00044 result *res;
00045 t2n_exception *ex;
00046
00047 enum result_type_t { regular, exception } result_type;
00048
00049 friend class boost::serialization::access;
00050 template<class Archive>
00051 void serialize(Archive & ar, const unsigned int version);
00052
00053 public:
00054 result_container()
00055 : res(NULL)
00056 , ex(NULL)
00057 , result_type(regular)
00058 {
00059 }
00060
00061 result_container(result *_res)
00062 : res(_res)
00063 , ex(NULL)
00064 , result_type(regular)
00065 {
00066 }
00067
00068 result_container(t2n_exception *_ex)
00069 : res(NULL)
00070 , ex(_ex)
00071 , result_type(exception)
00072 {
00073 }
00074
00075 ~result_container();
00076
00077 void set_result(result *_res)
00078 { res=_res; ex=0; result_type=regular; }
00079
00080 void set_exception(t2n_exception *_ex)
00081 { res=0; ex=_ex; result_type=exception; }
00082
00083 result* get_result(void);
00084
00085 bool has_exception()
00086 { return (result_type==exception && ex != NULL); }
00087 bool has_result()
00088 { return (result_type==regular && res != NULL); }
00089 };
00090
00093 class command_container
00094 {
00095 private:
00096 command *cmd;
00097
00098 friend class boost::serialization::access;
00099 template<class Archive>
00100 void serialize(Archive & ar, const unsigned int version);
00101
00102 public:
00103 command_container()
00104 : cmd(NULL)
00105 {}
00106
00107 command_container(command *_cmd)
00108 : cmd(_cmd)
00109 {}
00110
00111 ~command_container();
00112
00114 command* get_command()
00115 { return cmd; }
00116 };
00117
00118 }
00119
00120 BOOST_CLASS_TRACKING(libt2n::result_container, boost::serialization::track_never)
00121 BOOST_CLASS_TRACKING(libt2n::command_container, boost::serialization::track_never)
00122
00123 #include "container.tcc"
00124
00125 #endif
00126