RCC shared pointer class

43 views
Skip to first unread message

Daniel Moodie

unread,
Jul 2, 2015, 4:34:34 PM7/2/15
to runtimecompi...@googlegroups.com
Hello,

I just wanted to contribute a shared pointer class that I use for my RCC objects.  The class can be used like a std::shared_ptr or boost::shared_ptr.

The majority of this implementation can be found here.

This works by creating a class called IObjectNotifiable with one virtual function called updateObject. Each IObject then contains a vector of IObjectNotifiable* which is a list of all objects that need to be updated when an object swap occurs.

IObject then also has a registerNotifier, upateNotifiers, and deregisterNotifier functions.

Lastly there are two solutions for serializing the notifiers.
My original solution was to include it in the IObject::Serialize function, but this depended on the end developer to remember to always call IObject::Serialize when overriding Serialize, this wasn't reliable enough for me.
My actual solution involves creating a SerializeNotifiers function which gets called in ObjectFactorySystem::ProtectedObjectSwapper::ProtectedFunc.
ObjectFactorySystem::ProtectedObjectSwapper::ProtectedFunc also has a modification to call IObject::updateNotifiers on all new objects after construction and serialization.
I believe just swapping in my IObject.h and ObjectFactorySystem.cpp files should be sufficient to use my RCC::shared_ptr class.
I think I may also need C++11 support due to the mutex I've added to IObject to protect the Notifiers vector.
Reply all
Reply to author
Forward
0 new messages