Simple answer is that IObject has an Init function which you should use for work during initialization. This should be called with
isFirstInit set to true when you want to intialize, and during a reload is called with isFirstInit set to false. Then you use the Serialize functionality to move data from old to new objects. For more see below.
After new code is loaded, the following happens (for now not mentioning auto constructed singletons):
- Serialize() is called on all runtime objects (IObjects) to save out state.
- New objects are constructed if needed.
- Serialize() is called on all runtime objects to load back state.
- Init( isFirstInit = false ) is called on all objects - false meaning this is not a 'first' init.
- Old objects are deleted, with variable _isRuntimeDelete set to true so IsRuntimeDelete() is known.
At the moment there is no way of knowing in step 1 whether the object being serialized is going to be swapped for new code. This could be added (it would make sense to do so, so if you file a request on github I can get round to this in a week or so.
To avoid serializing out large amounts of state, I frequently just serialize out a pointer to large data structures (don't swap 10Mb, just swap a 4 or 8 byte pointer to the 10Mb). This does require a virtual dtor for that data since pointers may to to memory in the heap of another dll's allocator.
You can know if you if your object is new from 3 on by serializing the pointer to the object and then checking against your own (as mentioned above an API for this would be a good idea).
I won't be able to do much for a week or so on RCC++, but I would like improve the documentation and functionality in this area to make it easier to do what you're asking.
Cheers,
Doug.