Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65429 - trunk/boost/msm/back
From: christophe.j.henry_at_[hidden]
Date: 2010-09-15 15:45:02


Author: chenry
Date: 2010-09-15 15:45:00 EDT (Wed, 15 Sep 2010)
New Revision: 65429
URL: http://svn.boost.org/trac/boost/changeset/65429

Log:
improved serialization:
- for composite states
- for front-end attributes
Text files modified:
   trunk/boost/msm/back/history_policies.hpp | 6 +++---
   trunk/boost/msm/back/state_machine.hpp | 24 +++++++++++++++++++++---
   2 files changed, 24 insertions(+), 6 deletions(-)

Modified: trunk/boost/msm/back/history_policies.hpp
==============================================================================
--- trunk/boost/msm/back/history_policies.hpp (original)
+++ trunk/boost/msm/back/history_policies.hpp 2010-09-15 15:45:00 EDT (Wed, 15 Sep 2010)
@@ -50,7 +50,7 @@
          return *this;
     }
     template<class Archive>
- void serialize(Archive & ar, const unsigned int version)
+ void serialize(Archive & ar, const unsigned int)
     {
         ar & m_initialStates;
     }
@@ -91,7 +91,7 @@
          return *this;
     }
     template<class Archive>
- void serialize(Archive & ar, const unsigned int version)
+ void serialize(Archive & ar, const unsigned int)
     {
         ar & m_initialStates;
     }
@@ -140,7 +140,7 @@
          return *this;
     }
     template<class Archive>
- void serialize(Archive & ar, const unsigned int version)
+ void serialize(Archive & ar, const unsigned int)
     {
         ar & m_initialStates;
         ar & m_currentStates;

Modified: trunk/boost/msm/back/state_machine.hpp
==============================================================================
--- trunk/boost/msm/back/state_machine.hpp (original)
+++ trunk/boost/msm/back/state_machine.hpp 2010-09-15 15:45:00 EDT (Wed, 15 Sep 2010)
@@ -45,6 +45,9 @@
 #ifndef BOOST_NO_RTTI
 #include <boost/any.hpp>
 #endif
+
+#include <boost/serialization/base_object.hpp>
+
 #include <boost/msm/row_tags.hpp>
 #include <boost/msm/back/metafunctions.hpp>
 #include <boost/msm/back/history_policies.hpp>
@@ -1021,13 +1024,25 @@
         serialize_state(Archive& ar):ar_(ar){}
 
         template<typename T>
- typename ::boost::enable_if< typename has_do_serialize<T>::type,void >::type
+ typename ::boost::enable_if<
+ typename ::boost::mpl::or_<
+ typename has_do_serialize<T>::type,
+ typename is_composite_state<T>::type
+ >::type
+ ,void
+ >::type
         operator()(T& t) const
         {
             ar_ & t;
         }
         template<typename T>
- typename ::boost::disable_if< typename has_do_serialize<T>::type,void >::type
+ typename ::boost::disable_if<
+ typename ::boost::mpl::or_<
+ typename has_do_serialize<T>::type,
+ typename is_composite_state<T>::type
+ >::type
+ ,void
+ >::type
         operator()(T& t) const
         {
             // no state to serialize
@@ -1036,8 +1051,11 @@
     };
     
     template<class Archive>
- void serialize(Archive & ar, const unsigned int version)
+ void serialize(Archive & ar, const unsigned int)
     {
+ // invoke serialization of the base class
+ (serialize_state<Archive>(ar))(boost::serialization::base_object<Derived>(*this));
+ // now our attributes
         ar & m_states;
         // queues cannot be serialized => skip
         ar & m_history;


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