Boost logo

Boost Users :

From: Robert Bielik (robert.bielik_at_[hidden])
Date: 2008-03-15 11:13:02


I have a structure like:

class A
{
        int m_position;
        int m_value;

        template<class Archive>
        void save(Archive & ar, const unsigned int version) const
        {
                ar & BOOST_SERIALIZATION("pos", m_position);

                B* b = somehow_get_hold_of_my_object_of_class_B;

                int temp = b->convertToSerializedFormat(m_value);
                ar & BOOST_SERIALIZATION("value", temp);
        }

        template<class Archive>
        void load(Archive & ar, const unsigned int version)
        {
                ar & BOOST_SERIALIZATION("pos", m_position);

                B* b = somehow_get_hold_of_my_object_of_class_B;

                int temp;
                ar & BOOST_SERIALIZATION("value", temp);
                m_value = b->convertFromSerializedFormat(temp);
        }
}

class B
{
        std::vector<A> m_vector;

        template<class Archive>
        void serialize(Archive & ar, const unsigned int version)
        {
                ar & BOOST_SERIALIZATION("posvalues", m_vector);
        }

        int convertToSerializedFormat(int value);
        int convertFromSerializedFormat(int value);
        
}

I could have a B* pointer in each of my A objects, but cannot afford that due to tough memory constraints.

So the issue is how to get hold of a B* pointer (which is the object that holds the vector of A objects) ??

TIA
/R


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net