78889894729472da767f784c1ccb92a972c2eb11
[libt2n] / examples / minimalistic-stub.hxx
1 #ifndef MINIMALISTIC_STUB_HXX
2 #define MINIMALISTIC_STUB_HXX
3
4
5 /*
6   stubs to be generated
7   header is used by the client library and the server
8 */
9
10 // todo: why do we have to include the boost headers first?
11 // do we have to know which archive format we will use?
12
13 #include <boost/archive/binary_oarchive.hpp>
14 #include <boost/archive/binary_iarchive.hpp>
15 #include <boost/archive/xml_oarchive.hpp>
16 #include <boost/archive/xml_iarchive.hpp>
17 #include <boost/serialization/serialization.hpp>
18 #include <boost/serialization/string.hpp>
19
20 #include <string>
21 #include <t2n_exception.hxx>
22 #include <command.hxx>
23
24 #ifdef _GCCXML__
25 #define LIBT2P_EXPORT __attribute((gccxml("libt2n")))
26 #else
27 #define LIBT2P_EXPORT
28 #endif
29
30 class cmd_group_example : public libt2n::command
31 {
32     private:
33         friend class boost::serialization::access;
34         template<class Archive>
35         void serialize(Archive & ar, const unsigned int version)
36         {
37             ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(libt2n::command);
38         }
39 };
40
41
42 class testfunc_res : public libt2n::result
43 {
44     private:
45         std::string res;
46
47         friend class boost::serialization::access;
48         template<class Archive>
49         void serialize(Archive & ar, const unsigned int version)
50         {
51             ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(libt2n::result);
52             ar & BOOST_SERIALIZATION_NVP(res);
53         }
54
55     public:
56         testfunc_res()
57             { }
58
59         testfunc_res(const std::string& str)
60         {
61             res=str;
62         }
63
64         std::string get_data()
65         {
66             return res;
67         }
68 };
69
70
71 class testfunc_cmd : public cmd_group_example
72 {
73     private:
74         std::string param;
75
76         friend class boost::serialization::access;
77         template<class Archive>
78         void serialize(Archive & ar, const unsigned int version)
79         {
80             ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(cmd_group_example);
81             ar & BOOST_SERIALIZATION_NVP(param);
82         }
83
84     public:
85         testfunc_cmd()
86             { }
87
88         testfunc_cmd(const std::string& str)
89         {
90             param=str;
91         }
92
93         libt2n::result* operator()();
94 };
95
96 void
97 extended_type_info_test();
98
99 #endif