BinaryInput::read() implementation #1623
-
|
Hello developers, I can not understand this piece of code. Comparing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
In the case when a class member variable is a pointer that can be null when you serialize to ascii or binary you need a way of declaring this as a nullptr. You can't just write out pointers and read them back in as the objects will have a different location in memory on the read back, so you have to have a mechanism for writing out the objects associated with the pointer, then on re-load you have to load the object, then any other pointer in the scene graph that also pointed to the same original object also needs to keep pointing to the same pointer. The mechanism is what the objectIDMap[id] is for, but a nullptr is also a valid value that also needs a mechanism which is what the nullptr is about. |
Beta Was this translation helpful? Give feedback.

In the case when a class member variable is a pointer that can be null when you serialize to ascii or binary you need a way of declaring this as a nullptr.
You can't just write out pointers and read them back in as the objects will have a different location in memory on the read back, so you have to have a mechanism for writing out the objects associated with the pointer, then on re-load you have to load the object, then any other pointer in the scene graph that also pointed to the same original object also needs to keep pointing to the same pointer. The mechanism is what the objectIDMap[id] is for, but a nullptr is also a valid value that also needs a mechanism which is what the nullptr …