What is the preferred way to bind an object as variable within another object?
I'm looking at the PF resource object and how it has an internal list. In the resource class, it looks like it might initially bind it as a node:
FlexSim::TreeNode* list = 0
In the PF library tree, it does not already have the list object created or even a placeholder for 'list'. I'm assuming the magic happens in Resource::onCreate().
My working solution is the following:
treenode myobjectcontainer; ... // bind container object as a treenode void MyPFObject::bindVariables() { bindVariable(myobjectcontainer); } ... // create instance of object (delay, for example), inside my bound container void MyPFObject::onCreate() { treenode newobject = createinstance(library().find("?Delay"), myobjectcontainer); } // referencing would be something like this: myobjectcontainer->subnodes[1]->objectAs(Delay)->doStuff();
Maybe another option would be to save defaults with an instance of the object already loaded into my library object. I'm wondering what is generally the preferred way.