$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Oliver Kania (kania.oliver_at_[hidden])
Date: 2007-11-09 08:24:31
I have the following two data structures:
std::map<const std::string, boost::shared_ptr< C >,
jedox::util::CaseInsensitiv > m_LookupName;
std::map<unsigned int, boost::shared_ptr< C > > m_LookupId;
Before serialization, the shared pointer - values  of the maps do point to
sth. meaningful.
Afterwards, however, they point to data-structures with meaningless content.
The keys (strings / ints) are serialized / unserialized correctly.
I guess its a general problem with serializing shared pointers contained in
a std::map as values !?
BTW: the structures the shared pointers point to do have a serialization
method themselves and I a
assume that it is called when serializing the map.
I serialize / unserialize as follows:
template<class Archive>
            void save( Archive &ar, unsigned int version) const{
                m_offlineMode = true;
                bool oldCachedAll = m_CachedAll;
                m_CachedAll   = true;
                ar & m_CachedAll;
                ar & m_offlineMode;
                // do not serialize the lock -- use the default constructor.
                // we assume that no iterators that lock the cache do exist
when serializing.
                // ar & m_Lock;
                ar & m_LookupId;          // 1st structure
                ar & m_LookupName;    // 2nd structure
                ar & m_SequenceNumber;
                //reset old state for the case we want to continue working
                m_CachedAll = oldCachedAll;
                m_offlineMode = false;
            }
            template<class Archive>
            void load( Archive &ar, unsigned int version) {
                ar & m_CachedAll;
                ar & m_offlineMode;
                // do not serialize the lock -- use the default constructor.
                // we assume that no iterators that lock the cache do exist
when serializing.
                // ar & m_Lock;
                ar & m_LookupId;
                ar & m_LookupName;
                ar & m_SequenceNumber;
                //reset old state for the case we want to continue working
            }
kind regards, Oliver