I can't imagin how something like
 
                m_offlineMode = true;
even compiles given that save is a "const" function.
 
If you can't live without this, it suggests that your saving operation
is altering the thing its saving - which would conflict with the
the idea that only one copy of anything is actually saved.
 
From looking at this - that's the only think I can ay.
 
Robert Ramey
 
"Oliver Kania" <kania.oliver@googlemail.com> wrote in message news:1262c4ee0711090524w3a2e1a8i3355283c8c65ed98@mail.gmail.com...
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


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users