added a first "minimal" example - splitted code to be prepared for generator
[libt2n] / examples / minimalistic-stub.hxx
diff --git a/examples/minimalistic-stub.hxx b/examples/minimalistic-stub.hxx
new file mode 100644 (file)
index 0000000..7888989
--- /dev/null
@@ -0,0 +1,99 @@
+#ifndef MINIMALISTIC_STUB_HXX
+#define MINIMALISTIC_STUB_HXX
+
+
+/*
+  stubs to be generated
+  header is used by the client library and the server
+*/
+
+// todo: why do we have to include the boost headers first?
+// do we have to know which archive format we will use?
+
+#include <boost/archive/binary_oarchive.hpp>
+#include <boost/archive/binary_iarchive.hpp>
+#include <boost/archive/xml_oarchive.hpp>
+#include <boost/archive/xml_iarchive.hpp>
+#include <boost/serialization/serialization.hpp>
+#include <boost/serialization/string.hpp>
+
+#include <string>
+#include <t2n_exception.hxx>
+#include <command.hxx>
+
+#ifdef _GCCXML__
+#define LIBT2P_EXPORT __attribute((gccxml("libt2n")))
+#else
+#define LIBT2P_EXPORT
+#endif
+
+class cmd_group_example : public libt2n::command
+{
+    private:
+        friend class boost::serialization::access;
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int version)
+        {
+            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(libt2n::command);
+        }
+};
+
+
+class testfunc_res : public libt2n::result
+{
+    private:
+        std::string res;
+
+        friend class boost::serialization::access;
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int version)
+        {
+           ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(libt2n::result);
+            ar & BOOST_SERIALIZATION_NVP(res);
+        }
+
+    public:
+        testfunc_res()
+            { }
+
+        testfunc_res(const std::string& str)
+        {
+            res=str;
+        }
+
+        std::string get_data()
+        {
+            return res;
+        }
+};
+
+
+class testfunc_cmd : public cmd_group_example
+{
+    private:
+        std::string param;
+
+        friend class boost::serialization::access;
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int version)
+        {
+            ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(cmd_group_example);
+            ar & BOOST_SERIALIZATION_NVP(param);
+        }
+
+    public:
+        testfunc_cmd()
+            { }
+
+        testfunc_cmd(const std::string& str)
+        {
+            param=str;
+        }
+
+        libt2n::result* operator()();
+};
+
+void
+extended_type_info_test();
+
+#endif