Commit | Line | Data |
---|---|---|
7087e187 GE |
1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Gerd v. Egidy * | |
3 | * gve@intra2net.com * | |
4 | * * | |
5 | * This library is free software; you can redistribute it and/or modify * | |
6 | * it under the terms of the GNU Lesser General Public License version * | |
7 | * 2.1 as published by the Free Software Foundation. * | |
8 | * * | |
9 | * This library is distributed in the hope that it will be useful, * | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
12 | * GNU Lesser General Public License for more details. * | |
13 | * * | |
14 | * You should have received a copy of the GNU Lesser General Public * | |
15 | * License along with this program; if not, write to the * | |
16 | * Free Software Foundation, Inc., * | |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | |
18 | ***************************************************************************/ | |
19 | ||
a7170401 GE |
20 | #include <boost/archive/binary_oarchive.hpp> |
21 | #include <boost/archive/binary_iarchive.hpp> | |
22 | #include <boost/archive/xml_oarchive.hpp> | |
23 | #include <boost/archive/xml_iarchive.hpp> | |
24 | ||
7087e187 GE |
25 | #include "container.hxx" |
26 | ||
d184c648 GE |
27 | #include <boost/serialization/export.hpp> |
28 | ||
a7170401 GE |
29 | BOOST_CLASS_EXPORT(libt2n::result_container) |
30 | BOOST_CLASS_EXPORT(libt2n::command_container) | |
31 | ||
32 | namespace libt2n | |
33 | { | |
34 | ||
35 | template<class Archive> | |
2f90dcbf | 36 | void result_container::serialize(Archive & ar, const unsigned int /* version */) |
a7170401 GE |
37 | { |
38 | // When the class Archive corresponds to an output archive, the | |
39 | // & operator is defined similar to <<. Likewise, when the class Archive | |
40 | // is a type of input archive the & operator is defined similar to >>. | |
41 | ||
42 | ar & BOOST_SERIALIZATION_NVP(result_type); | |
43 | ar & BOOST_SERIALIZATION_NVP(res); | |
44 | ar & BOOST_SERIALIZATION_NVP(ex); | |
45 | } | |
46 | ||
47 | /// deletes the carried result or exception objects | |
48 | result_container::~result_container() | |
49 | { | |
50 | if (res) | |
51 | delete res; | |
52 | if (ex) | |
53 | delete ex; | |
54 | } | |
55 | ||
56 | /** @brief returns the result or throw the carried exception. | |
57 | ATTENTION: the result object is deleted in the destructor | |
58 | */ | |
59 | result* result_container::get_result(void) | |
60 | { | |
61 | if (result_type==exception) | |
62 | ex->do_throw(); | |
63 | return res; | |
64 | } | |
65 | ||
66 | template<class Archive> | |
2f90dcbf | 67 | void command_container::serialize(Archive & ar, const unsigned int /* version */) |
a7170401 GE |
68 | { |
69 | ar & BOOST_SERIALIZATION_NVP(cmd); | |
70 | } | |
71 | ||
72 | /// deletes the carried command | |
73 | command_container::~command_container() | |
74 | { | |
75 | if (cmd) | |
76 | delete cmd; | |
77 | } | |
d184c648 | 78 | |
a7170401 | 79 | } // namespace libt2n |