added test using own class as argument
authorJens Thiele <jens.thiele@intra2net.com>
Tue, 21 Nov 2006 16:04:55 +0000 (16:04 +0000)
committerJens Thiele <jens.thiele@intra2net.com>
Tue, 21 Nov 2006 16:04:55 +0000 (16:04 +0000)
example-codegen/Makefile.am
example-codegen/client.cpp
example-codegen/foo.hxx [new file with mode: 0644]
example-codegen/server.cpp
example-codegen/server.hxx

index f1ce586..5deff2e 100644 (file)
@@ -8,7 +8,7 @@ noinst_LTLIBRARIES = libclient.la
 client_SOURCES = client.cpp
 client_LDADD = $(LDADD) libclient.la
 
-server_SOURCES = server.cpp codegen_server.cpp
+server_SOURCES = server.cpp codegen_server.cpp foo.hxx
 
 noinst_PROGRAMS = client server
 
@@ -17,7 +17,7 @@ codegen.stamp: server.hxx $(top_builddir)/codegen/codegen
 # todo use tmp file for server.xml
        gccxml $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $< -fxml=server.xml
        $(top_builddir)/codegen/codegen $< server.xml codegen_
-       touch codegen.stamp
+       touch $@
 
 codegen_common.hxx codegen_common.cpp codegen_client.hxx codegen_client.cpp codegen_server.cpp: codegen.stamp
 
index 266bef0..008d9e1 100644 (file)
@@ -24,12 +24,15 @@ int main(int argc, char** argv)
       throwok=(std::string(e.what())=="throw me around");
   }
 
+  Foo foo={10,10};
+  
   return ( throwok
           && ( cc.testfunc("hello") == "hello, testfunc() was here" )
           && ( cc.testfunc_ref("hello") == "hello, testfunc() was here" )
           && ( cc.t2(10) == 10 )
           && ( cc_other.t3(10, 20, "hello", std::pair<int, float>(10,20)) )
           && ( cc_other.t3(10) == 10 ) 
-          && ( cc_other.t3(std::vector<int>(1,10)) ) )
+          && ( cc_other.t3(std::vector<int>(1,10)) ) 
+          && ( cc_other.t3(foo) ) )
     ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/example-codegen/foo.hxx b/example-codegen/foo.hxx
new file mode 100644 (file)
index 0000000..49d0197
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef FOO_HXX
+#define FOO_HXX
+
+#include <boost/serialization/version.hpp>
+
+struct Foo
+{
+  int i,j;
+
+  friend class boost::serialization::access;
+  template<class Archive>
+  void serialize(Archive & ar, const unsigned int /* version */)
+  {
+    ar & BOOST_SERIALIZATION_NVP(i);
+    ar & BOOST_SERIALIZATION_NVP(j);
+  }
+};
+
+BOOST_CLASS_VERSION(Foo, 1)
+
+#endif
index 7bf0bf2..1931ab8 100644 (file)
@@ -5,6 +5,12 @@
 
 using namespace libt2n;
 
+bool t3(const Foo &foo)
+{
+    return (foo.i==foo.j);
+}
+
+
 int main(int argc, char** argv) {
   socket_server ss("./socket");
   socket_server ss_other("./socket_other");
index b15ccee..16068a0 100644 (file)
@@ -8,6 +8,8 @@
 #include <vector>
 #include <boost/serialization/vector.hpp>
 
+#include "foo.hxx"
+
 #include "codegen_common.hxx"
 
 LIBT2N_SET_DEFAULTGROUP(default);
@@ -63,3 +65,6 @@ LIBT2N_EXPORT_GROUP(other) bool t3(const std::vector<int> &i)
 {
     return (i.size()==1) && (i[0]==10);
 }
+
+//! test own type and seperate declaration and definition
+LIBT2N_EXPORT_GROUP(other) bool t3(const Foo &foo);