--- /dev/null
+INCLUDES = -I$(top_srcdir)/src @BOOST_CPPFLAGS@ @CPPUNIT_CFLAGS@
+
+LDADD = $(top_builddir)/src/libt2n.la @BOOST_SERIALIZATION_LIB@ @BOOST_LDFLAGS@
+
+libminimalistic_client_la_SOURCES = minimalistic-client-stub.cpp
+noinst_LTLIBRARIES = libminimalistic-client.la
+
+minimalistic_client_SOURCES = minimalistic-client.cpp
+minimalistic_client_LDADD = $(LDADD) libminimalistic-client.la
+
+minimalistic_server_SOURCES = minimalistic-server.cpp minimalistic-server-stub.cpp minimalistic-stub.cpp
+
+noinst_PROGRAMS = minimalistic_client minimalistic_server
--- /dev/null
+boost serialization and extended_type_info trouble:
+- the problem was that the static initializers generated by the BOOST_CLASS_EXPORT macro haven't been called
+this happened because the translation unit of the static library created wasn't used
--- /dev/null
+- function to command group mapping?
--- /dev/null
+#include "minimalistic-client-stub.hxx"
+#include "minimalistic-stub.hxx"
+
+// fake
+libt2n::result* testfunc_cmd::operator()()
+{
+ return NULL;
+}
+
+std::string cmd_group_example_client::testfunc(const std::string& str)
+{
+ libt2n::result_container rc;
+ send_command(new testfunc_cmd(str),rc);
+
+ testfunc_res* res=dynamic_cast<testfunc_res*>(rc.get_result());
+ if (!res)
+ throw libt2n::t2n_communication_error("result object of wrong type");
+ return res->get_data();
+}
+
+// include in this compilation unit to ensure the compilation unit is used
+// see also:
+// http://www.google.de/search?q=g%2B%2B+static+initializer+in+static+library
+#include "minimalistic-stub.cpp"
--- /dev/null
+/* header file for the library that should be automatically generated */
+
+#ifndef MINIMALISTIC_CLIENT_STUB_HXX
+#define MINIMALISTIC_CLIENT_STUB_HXX
+
+#include <command_client.hxx>
+
+class cmd_group_example_client : public libt2n::command_client
+{
+ public:
+ cmd_group_example_client(libt2n::client_connection &_c,
+ long long _command_timeout_usec=command_timeout_usec_default,
+ long long _hello_timeout_usec=hello_timeout_usec_default)
+ : libt2n::command_client(_c,_command_timeout_usec,_hello_timeout_usec)
+ { }
+
+ std::string testfunc(const std::string& str);
+};
+
+void
+extended_type_info_test();
+
+#endif
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2004 by Intra2net AG *
+ * info@intra2net.com *
+ * *
+ ***************************************************************************/
+
+#include <socket_client.hxx>
+
+// include library header
+#include "minimalistic-client-stub.hxx"
+
+int main(int argc, char** argv)
+{
+ extended_type_info_test();
+
+ libt2n::socket_client_connection sc("./socket");
+ cmd_group_example_client cc(sc);
+
+ return (cc.testfunc("hello")=="hello, testfunc() was here") ? EXIT_SUCCESS : EXIT_FAILURE;
+}
--- /dev/null
+#include "minimalistic-stub.hxx"
+
+std::string testfunc(const std::string& str);
+
+libt2n::result* testfunc_cmd::operator()()
+{
+ return new testfunc_res(testfunc(param));
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2004 by Intra2net AG *
+ * info@intra2net.com *
+ * *
+ ***************************************************************************/
+
+#include <string>
+#include <stdexcept>
+
+#include "minimalistic-stub.hxx"
+
+#include <socket_server.hxx>
+#include <command_server.hxx>
+
+using namespace std;
+
+LIBT2P_EXPORT string testfunc(const string& str)
+{
+ string ret;
+ if (str=="throw")
+ throw libt2n::t2n_runtime_error("throw me around");
+ if (str=="big")
+ ret.insert(0,100*1024,'x');
+ else
+ ret=str+", testfunc() was here";
+ return ret;
+}
+
+using namespace libt2n;
+
+int main(int argc, char** argv) {
+ extended_type_info_test();
+
+ socket_server ss("./socket");
+ group_command_server<cmd_group_example> cs(ss);
+
+ // handle requests (without timeout)
+ while(true)
+ cs.handle();
+
+ return 0;
+}
--- /dev/null
+#include "minimalistic-stub.hxx"
+#include <boost/serialization/export.hpp>
+
+/* register types with boost serialization */
+
+BOOST_CLASS_EXPORT(cmd_group_example)
+BOOST_CLASS_EXPORT(testfunc_cmd)
+BOOST_CLASS_EXPORT(testfunc_res)
+
+void
+extended_type_info_test() {
+ cmd_group_example* t=new testfunc_cmd();
+ const boost::serialization::extended_type_info * true_type
+ = boost::serialization::type_info_implementation<libt2n::command>::type::get_derived_extended_type_info(*t);
+ // note:if this exception is thrown, be sure that derived pointer
+ // is either regsitered or exported.
+ assert(NULL != true_type);
+ assert(std::string("testfunc_cmd")==true_type->get_key());
+}
--- /dev/null
+#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