Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59942 - in branches/release/libs/serialization: doc example src test
From: ramey_at_[hidden]
Date: 2010-02-26 00:28:58


Author: ramey
Date: 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
New Revision: 59942
URL: http://svn.boost.org/trac/boost/changeset/59942

Log:
move recent changes to release branch
Text files modified:
   branches/release/libs/serialization/doc/derivation.html | 4 +-
   branches/release/libs/serialization/doc/extended_type_info.html | 62 ++++++++++++++++++++++++++++++++++++++-
   branches/release/libs/serialization/doc/implementation.html | 2
   branches/release/libs/serialization/doc/overview.html | 3 -
   branches/release/libs/serialization/example/demo.cpp | 2
   branches/release/libs/serialization/src/shared_ptr_helper.cpp | 4 +-
   branches/release/libs/serialization/src/void_cast.cpp | 4 ++
   branches/release/libs/serialization/test/Jamfile.v2 | 7 +--
   branches/release/libs/serialization/test/polymorphic_base.hpp | 2
   branches/release/libs/serialization/test/polymorphic_derived2.hpp | 4 ++
   branches/release/libs/serialization/test/test_dll_plugin.cpp | 47 +++++++++++++++++++++++++++---
   branches/release/libs/serialization/test/test_polymorphic2.cpp | 9 +++++
   branches/release/libs/serialization/test/test_polymorphic2.hpp | 9 +++++
   branches/release/libs/serialization/test/test_polymorphic2imp.cpp | 9 +++++
   14 files changed, 147 insertions(+), 21 deletions(-)

Modified: branches/release/libs/serialization/doc/derivation.html
==============================================================================
--- branches/release/libs/serialization/doc/derivation.html (original)
+++ branches/release/libs/serialization/doc/derivation.html 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -26,8 +26,8 @@
 </table>
 <hr>
 <dl class="page-index">
- <dt><a target="detail" href="#portable_archives">Portable Binary Archives</a>
- <dt><a target="detail" href="#fast_archives">Fast Binary Archives</a>
+ <dt>Portable Binary Archives
+ <dt>Fast Binary Archives
 </dl>
 
 <a name=portable_archives>

Modified: branches/release/libs/serialization/doc/extended_type_info.html
==============================================================================
--- branches/release/libs/serialization/doc/extended_type_info.html (original)
+++ branches/release/libs/serialization/doc/extended_type_info.html 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -245,7 +245,7 @@
 
 </dl>
 
-<h3><a name="requirements">Requirements</a></h3>
+<h3><a name="requirements">Requirements for and Implementation</a></h3>
 In order to be used by the serialization library, an implementation of
 <code style="white-space: normal">extended_type_info</code>,
 (referred to as ETI here), must be derived from
@@ -351,8 +351,66 @@
 inter-operability with between two different implementations of
 <code style="white-space: normal">extended_type_info</code>.
 
+<h3><a name="type_requirements">Requirements for Each Type</a></h3>
+Each type to be managed by the system must be
+"registered" individually. This is accomplished by instantiating
+templates. For example, if the type T is to use the type_info system
+one would include the following code:
+
+<code style="white-space: normal"><pre>
+namespace boost {
+namespace serialization {
+template
+struct extended_type_info_typeid&gt;T&gt;;
+template
+struct extended_type_info_typeid&gt;const T&gt;;
+} // serialization
+} // boost
+</pre></code>
+
+For those using the serialization library, this step can be skipped
+as it is done automatically. The serialization library includes
+the macro:
+
+<code style="white-space: normal"><pre>
+BOOST_CLASS_TYPE_INFO(
+ my_type,
+ extended_type_info_typeid&gt;my_class&gt;
+)
+</pre></code>
+
+which is used to specify which <code>extended_type_info</code> system is to
+be used for a given type.
+<p>
+<code>extended_type_info</code> includes a facility for constructing
+instances of types without knowing what the exact types are. This is done
+with the function
+<code>
+virtual void * extended_type_info::construct(unsigned int count = 0, ...) const;
+</code>
+. For example:
+<br>
+<code><pre>
+struct base {
+...
+};
+struct derived : public base {
+...
+};
+...
+extended_type_info *eti = extended_type_info::find("my_class")
+base * b = eti->construct(...);
+</pre></code>
+<br>
+The <code>construct</code> takes an argument count and up to
+four parameters of any type. The arguments are passed to the
+constructor of "my_class".
+
+
+A complete example of this can be found
+<a target="test_plugin.cpp" href="test_plugin.cpp">here</a>
 <hr>
-<p><i>&copy; Copyright Robert Ramey 2005.
+<p><i>&copy; Copyright Robert Ramey 2005-2009.
 Distributed under the Boost Software License, Version 1.0. (See
 accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 </i></p>

Modified: branches/release/libs/serialization/doc/implementation.html
==============================================================================
--- branches/release/libs/serialization/doc/implementation.html (original)
+++ branches/release/libs/serialization/doc/implementation.html 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -231,7 +231,7 @@
     and use this library with this compiler, one must use version 1.6x rather than the
     latest version shipped with boost. See Release Notes.
 </ul>
-<h4><a name="Intel80">Intel C++ 8.0</a></h4>
+<h4><a name="intel80">Intel C++ 8.0</a></h4>
 No known issues. All tests compile and run in debug and release modes.
 
 <h4><a name="vc80">Visual C++ 8.0</a></h4>

Modified: branches/release/libs/serialization/doc/overview.html
==============================================================================
--- branches/release/libs/serialization/doc/overview.html (original)
+++ branches/release/libs/serialization/doc/overview.html 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -28,9 +28,6 @@
 <dl class="index">
   <dt>Requirements</dt>
   <dt>Other Implementations</dt>
- <!--
- <dt>Footnotes</dt>
- -->
 </dl>
 <p>Here, we use the term <strong>"serialization"</strong> to mean
 the reversible deconstruction of an arbitrary set of C++ data structures

Modified: branches/release/libs/serialization/example/demo.cpp
==============================================================================
--- branches/release/libs/serialization/example/demo.cpp (original)
+++ branches/release/libs/serialization/example/demo.cpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -265,7 +265,7 @@
     }
     bus_schedule(){}
 };
-BOOST_CLASS_VERSION(bus_schedule, 2)
+BOOST_CLASS_VERSION(bus_schedule::trip_info, 2)
 
 std::ostream & operator<<(std::ostream &os, const bus_schedule::trip_info &ti)
 {

Modified: branches/release/libs/serialization/src/shared_ptr_helper.cpp
==============================================================================
--- branches/release/libs/serialization/src/shared_ptr_helper.cpp (original)
+++ branches/release/libs/serialization/src/shared_ptr_helper.cpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -94,9 +94,9 @@
 
 // #ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP
 BOOST_ARCHIVE_DECL(void)
-shared_ptr_helper::append(const boost_132::shared_ptr<void> & t){
+shared_ptr_helper::append(const boost_132::shared_ptr<const void> & t){
     if(NULL == m_pointers_132)
- m_pointers_132 = new std::list<boost_132::shared_ptr<void> >;
+ m_pointers_132 = new std::list<boost_132::shared_ptr<const void> >;
     m_pointers_132->push_back(t);
 }
 // #endif

Modified: branches/release/libs/serialization/src/void_cast.cpp
==============================================================================
--- branches/release/libs/serialization/src/void_cast.cpp (original)
+++ branches/release/libs/serialization/src/void_cast.cpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -284,6 +284,10 @@
     void_cast_detail::set_type::iterator it;
     for(it = s.begin(); it != s.end();){
         const void_caster * vc = *it;
+ if(vc == this){
+ s.erase(it++);
+ }
+ else
         if(vc->m_parent == this){
             s.erase(it);
             delete vc;

Modified: branches/release/libs/serialization/test/Jamfile.v2
==============================================================================
--- branches/release/libs/serialization/test/Jamfile.v2 (original)
+++ branches/release/libs/serialization/test/Jamfile.v2 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -53,7 +53,6 @@
 lib dll_polymorphic_derived2_lib
     :
         polymorphic_derived2.cpp
- polymorphic_base.cpp
         ../build//boost_serialization
     :
         <link>shared
@@ -111,10 +110,10 @@
 
 if ! $(BOOST_ARCHIVE_LIST) {
     test-suite "serialization2" :
- [ test-bsl-run test_dll_exported : polymorphic_base : dll_polymorphic_derived2_lib : <runtime-link>shared ]
-# [ test-bsl-run test_dll_plugin : : dll_base_lib dll_derived2_lib : <runtime-link>shared ]
+ [ test-bsl-run test_dll_exported : : dll_polymorphic_derived2_lib : <runtime-link>shared ]
+# [ test-bsl-run test_dll_plugin : : dll_polymorphic_derived2_lib : <runtime-link>shared ]
+ [ compile test_dll_plugin.cpp ]
         [ test-bsl-run test_dll_simple : : dll_a_lib : <runtime-link>shared ]
-
         [ test-bsl-run test_private_ctor ]
         [ test-bsl-run test_reset_object_address : A ]
         [ test-bsl-run test_void_cast ]

Modified: branches/release/libs/serialization/test/polymorphic_base.hpp
==============================================================================
--- branches/release/libs/serialization/test/polymorphic_base.hpp (original)
+++ branches/release/libs/serialization/test/polymorphic_base.hpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -34,7 +34,7 @@
     // note that since this class uses the "no_rtti"
     // extended_type_info implementation, it MUST
     // implement this function
- virtual const char * get_key() const;
+ virtual const char * get_key() const = 0;
     virtual ~polymorphic_base(){};
 };
 

Modified: branches/release/libs/serialization/test/polymorphic_derived2.hpp
==============================================================================
--- branches/release/libs/serialization/test/polymorphic_derived2.hpp (original)
+++ branches/release/libs/serialization/test/polymorphic_derived2.hpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -21,6 +21,8 @@
 #include <boost/serialization/base_object.hpp>
 #include <boost/serialization/type_info_implementation.hpp>
 #include <boost/serialization/extended_type_info_typeid.hpp>
+#include <boost/serialization/factory.hpp>
+
 #include <boost/preprocessor/empty.hpp>
 
 #include "polymorphic_base.hpp"
@@ -64,6 +66,8 @@
     boost::serialization::extended_type_info_typeid<polymorphic_derived2>
 )
 
+BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2)
+
 #undef DLL_DECL
 
 #endif // POLYMORPHIC_DERIVED2_HPP

Modified: branches/release/libs/serialization/test/test_dll_plugin.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_dll_plugin.cpp (original)
+++ branches/release/libs/serialization/test/test_dll_plugin.cpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -29,12 +29,8 @@
 #include <boost/archive/archive_exception.hpp>
 
 // for now, only test with simple text and polymorphic archive
-#define BOOST_ARCHIVE_TEST polymorphic_text_archive.hpp
 #include "test_tools.hpp"
 
-#include <boost/archive/polymorphic_text_oarchive.hpp>
-#include <boost/archive/polymorphic_text_iarchive.hpp>
-
 #include <boost/serialization/base_object.hpp>
 #include <boost/serialization/export.hpp>
 #include <boost/serialization/type_info_implementation.hpp>
@@ -52,10 +48,19 @@
     void serialize(Archive &ar, const unsigned int /* file_version */){
         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base);
     }
+ const char * get_key() const{
+ return
+ boost::serialization::type_info_implementation<
+ polymorphic_derived1
+ >::type::get_const_instance().get_key();
+ }
 public:
     virtual ~polymorphic_derived1(){}
 };
 
+// This class is derived from polymorphic_base which uses the no_rtti system
+// rather than the typeid system. This system uses the exported name as the
+// type identifier key. This MUST be exported!!!
 BOOST_CLASS_EXPORT(polymorphic_derived1)
 
 // MWerks users can do this to make their code work
@@ -101,6 +106,7 @@
     // don't need these any more - don't leak memory
     delete rb1;
     // note delete original handle - not runtime cast one !!!
+ //delete rb2;
     d2_eti->destroy(rd2);
 }
 
@@ -146,6 +152,8 @@
     delete rb2;
 }
 
+#ifdef BOOST_WINDOWS
+
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
@@ -157,7 +165,10 @@
 
     HINSTANCE hDLL; // Handle to DLL
     hDLL = LoadLibrary("dll_polymorphic_derived2.dll");
- assert(0 != hDLL);
+ BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load dll_polymorphic_derived2" );
+ if(0 == hDLL)
+ return EXIT_FAILURE;
+
     save_exported(testfile);
     load_exported(testfile);
     FreeLibrary(hDLL);
@@ -166,4 +177,30 @@
     return EXIT_SUCCESS;
 }
 
+#else // presume *nix
+
+#include <dlfcn.h>
+
+int
+test_main( int /* argc */, char* /* argv */[] )
+{
+ const char * testfile = boost::archive::tmpnam(NULL);
+ BOOST_REQUIRE(NULL != testfile);
+
+ void * hDLL; // Handle to DLL
+ hDLL = dlopen("dll_polymorphic_derived2.so", RTLD_NOW | RTLD_GLOBAL);
+ BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load dll_polymorphic_derived2" );
+ if(0 == hDLL)
+ return EXIT_FAILURE;
+
+ save_exported(testfile);
+ load_exported(testfile);
+ dlclose(hDLL);
+
+ std::remove(testfile);
+ return EXIT_SUCCESS;
+}
+
+#endif
+
 // EOF

Modified: branches/release/libs/serialization/test/test_polymorphic2.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_polymorphic2.cpp (original)
+++ branches/release/libs/serialization/test/test_polymorphic2.cpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -1,3 +1,12 @@
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// test_polymorphic2.cpp
+
+// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// should pass compilation and execution
 #include <fstream>
 
 #include "test_tools.hpp"

Modified: branches/release/libs/serialization/test/test_polymorphic2.hpp
==============================================================================
--- branches/release/libs/serialization/test/test_polymorphic2.hpp (original)
+++ branches/release/libs/serialization/test/test_polymorphic2.hpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -1,3 +1,12 @@
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// test_polymorphic2.hpp
+
+// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// should pass compilation and execution
 namespace boost {
 namespace archive {
     class polymorphic_oarchive;

Modified: branches/release/libs/serialization/test/test_polymorphic2imp.cpp
==============================================================================
--- branches/release/libs/serialization/test/test_polymorphic2imp.cpp (original)
+++ branches/release/libs/serialization/test/test_polymorphic2imp.cpp 2010-02-26 00:28:56 EST (Fri, 26 Feb 2010)
@@ -1,3 +1,12 @@
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// test_polymorphic2imp.cpp
+
+// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// should pass compilation and execution
 
 #include <boost/serialization/export.hpp>
 #include <boost/archive/polymorphic_oarchive.hpp>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk