container.hxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Gerd v. Egidy                                   *
00003  *   gve@intra2net.com                                                     *
00004  *                                                                         *
00005  *   This library is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License version   *
00007  *   2.1 as published by the Free Software Foundation.                     *
00008  *                                                                         *
00009  *   This library is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU Lesser General Public License for more details.                   *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this program; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00018  ***************************************************************************/
00019 #ifndef __LIBT2N_CONTAINER
00020 #define __LIBT2N_CONTAINER
00021 
00022 #include <boost/archive/binary_oarchive.hpp>
00023 #include <boost/archive/binary_iarchive.hpp>
00024 #include <boost/archive/xml_oarchive.hpp>
00025 #include <boost/archive/xml_iarchive.hpp>
00026 #include <boost/serialization/serialization.hpp>
00027 
00028 #include "command.hxx"
00029 #include "t2n_exception.hxx"
00030 
00031 #include <iostream>
00032 
00033 namespace libt2n
00034 {
00035 
00038 class result_container
00039 {
00040     private:
00041         enum result_type_t { regular, exception } result_type;
00042 
00043         result *res;
00044         t2n_exception *ex;
00045 
00046         friend class boost::serialization::access;
00047         template<class Archive>
00048         void serialize(Archive & ar, const unsigned int version);
00049 
00050     public:
00051         result_container()
00052             { res=0; ex=0; }
00053 
00054         result_container(result *_res)
00055             { set_result(_res); }
00056         result_container(t2n_exception *_ex)
00057             { set_exception(_ex); }
00058 
00059         ~result_container();
00060 
00061         void set_result(result *_res)
00062             { res=_res; ex=0; result_type=regular; }
00063         void set_exception(t2n_exception *_ex)
00064             { res=0; ex=_ex; result_type=exception; }
00065 
00066         result* get_result(void);
00067 
00068         bool has_exception()
00069             { return (result_type==exception); }
00070         bool has_result()
00071             { return (result_type==regular); }
00072 };
00073 
00076 class command_container
00077 {
00078     private:
00079         command *cmd;
00080 
00081         friend class boost::serialization::access;
00082         template<class Archive>
00083         void serialize(Archive & ar, const unsigned int version);
00084 
00085     public:
00086         command_container()
00087             { cmd=0; }
00088         command_container(command *_cmd)
00089             { cmd=_cmd; }
00090 
00091         ~command_container();
00092 
00094         command* get_command()
00095             { return cmd; }
00096 };
00097 
00098 } // namespace libt2n
00099 
00100 BOOST_CLASS_TRACKING(libt2n::result_container, boost::serialization::track_never)
00101 BOOST_CLASS_TRACKING(libt2n::command_container, boost::serialization::track_never)
00102 
00103 #include "container.tcc"
00104 
00105 #endif
00106 

Generated on Fri Sep 26 15:36:59 2008 for libt2n by  doxygen 1.5.6