|
Boost Users : |
Subject: [Boost-users] [serialization] Sending user data to serialize()?
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-02-03 10:30:52
Hi,
I have a complex case I'm trying to work with. I may be doing this
completely wrong so if there is a better design for this I'm always open for
that. However for now I'm going to assume my particular problem can be
solved.
There exists two classes: A and B. Class A is defined as such:
class A
{
public:
template< typename Archive >
void load( Archive& archive, unsigned int )
{
archive & m_listOfB;
}
private:
std::vector<int> m_listOfInt;
boost::ptr_vector<B> m_listOfB;
};
And class B is defined roughly as:
class B
{
public:
template< typename Archive >
void load( Archive& archive, unsigned int )
{
// Code isn't important here
}
};
Here's the problem:
For each B that is deserialized by A::load(), I need to pass in a reference
to m_listOfInt. So, essentially the load() function in B would look
something like this:
void load( Archive& archive, unsigned int, std::vector<int>& listOfInt )
{
}
I was hoping boost.bind could be used somewhere, but I just don't see how.
One way to solve the problem is to call B::load() explicitly with the extra
parameter, but I don't think that's an appropriate solution. Any ideas on
how to solve this? Or perhaps I'm trying to solve the wrong problem.
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