Intra2net AG

container.hxx

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
00003 
00004 The software in this package is distributed under the GNU General
00005 Public License version 2 (with a special exception described below).
00006 
00007 A copy of GNU General Public License (GPL) is included in this distribution,
00008 in the file COPYING.GPL.
00009 
00010 As a special exception, if other files instantiate templates or use macros
00011 or inline functions from this file, or you compile this file and link it
00012 with other works to produce a work based on this file, this file
00013 does not by itself cause the resulting work to be covered
00014 by the GNU General Public License.
00015 
00016 However the source code for this file must still be made available
00017 in accordance with section (3) of the GNU General Public License.
00018 
00019 This exception does not invalidate any other reasons why a work based
00020 on this file might be covered by the GNU General Public License.
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 } // namespace libt2n
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 

Generated on 13 May 2015 by  doxygen 1.6.1
© Intra2net AG 2024 | Legal | Contact