
Hello again, I actually have another question. Although the solution now works, it's still not perfect. The problem is the actual variant. Right now, i have a separate header file which has a typedef for my variant, i.e. typedef boost::variant<FWK::AGENT::Event, FWK::AGENT::EventTest, FWK::AGENT::EventBehaviourStarted> event_container; Multiple files that are involved in the messaging service use this typedef. It works perfectly well. However, in the long run, for every custom event that is derived from Event, a framework user would have to go play around in this header to add the custom type, which is definatly something i would like to avoid (for obvious reasons). Since i will have to use mpl::vectors anyway to construct my variant (there could possibly be hundreds of events), i was wondering if there would be a way of constructing the vector "along the way", i.e. if every Event derived class could add to the vector, and then i could in the end construct my variant based on that. I have barely started reading up on mpl, so i'm not really sure how to go about this. I was thinking of something like struct list_helper { typedef boost::mpl::vector< FWK::AGENT::Event > type; } This would be my starter type. But how can i push new elements into this vector, especially since all the calls would be in separate files ? I also would have to make sure that the call to boost::make_variant_over would always happen after all the events are added. I looked a little over the serialization library's BOOST_CLASS_EXPORT, which i figured is "kind" of what i want to do, but in my case, i think it's simpler. However, i'm still stuck for now. Thanks for any help in advance, Lukasz K. Ovanes Markarian wrote:
If you like, prepare me some simple example and I can correct it or help you at this point.
With Kind Regards,
Ovanes Markarian
On Tue, June 26, 2007 14:56, Lukasz wrote:
You summed it up very well with the first paragraph. I've been trying to template this from the beginning, but it just wouldn't fit into the design. However, i think i'll be able to use variant within one of my maps to store the "real" type of the event which should work perfectly for my needs. Thanks for all the input... it really helped to get some ideas together and variant will probably do the trick (but i still have to fiddle some more with the idea).
Thanks again.
Lukasz K.
Ovanes Markarian wrote:
My idea is based on fact that you (program developer or another developer) know what is going to be send. What you are trying to do is erasing the type to some base and that would not work.
So you send event must handle derived type and put it correctly to variant. A possible solution would be:
template<class EventType_> void sendEvent(EventType_ const& ev) { m_eventContainer = ev; //<- now compiler knows exactly the type of ev m_derivedHelper->dispatchEvent(&m_eventContainer); }
Best Regards, Ovanes
[...]
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/problem...-maybe-boost-could-help-tf3959613.html#a1132... Sent from the Boost - Users mailing list archive at Nabble.com.