Save node data in Read and Write
-
hi,this is my code ,i save data in node ,but can't read successlly ,just display 0. Where did I go wrong?
Bool TagTest::Read(GeListNode * node, HyperFile * hf, Int32 level) { BaseTag* op = (BaseTag*)node; BaseContainer* bc = op->GetDataInstance(); ApplicationOutput("Read count: @ ", bc->GetInt32(12345)); return SUPER::Read(node, hf, level); return true; } Bool TagTest::Write(GeListNode * node, HyperFile * hf) { BaseTag* op = (BaseTag*)node; BaseContainer* bc = op->GetDataInstance(); bc->SetInt32(12345,123); ApplicationOutput("Write count: @ ", bc->GetInt32(12345)); return SUPER::Write(node, hf); return true; }
Hope your help.
-
If you're storing data in the tag's BaseContainer, you don't need to override Write() and Read(). That's meant for private class member whose data would be lost otherwise.
Also, you can remove the "return true" at the end of the functions. As you already return in the previous line, it will never be called.
-
@fwilleke80 Thank you for your help! I mistakenly believe that Write is the extra func to save data.
-
Hi @mike,
This is true only for data that are not stored in a BaseContainer (e.g. you want to store a BaseArray).
For more information please read NodeData::Read() / NodeData::Write() Manual and in case you override Read/Write you may also want to override CopyTo, see NodeData::CopyTo() Manual in order to define the behavior of your NodeData when its copied. But again this is in the case you use some datatype that is not part of the BaseContainer object.Cheers,
Maxime. -
@m_adam Thank your for your answer