18 Jul 2013, 15:54
Hi!
You can do so by deriving from Graph::Node.
In the header file, write:
Then implement in the CPP file:
You may want to override the InitSelf, ProcessLogicSelf, etc. methods from Graph::Node to add custom behavior.
Finally, you need to register/unregister the node in your App class by overriding these methods from AppBase:
Now you can use:
Or:
You can do so by deriving from Graph::Node.
In the header file, write:
#include "murl_graph_node.h"
#include "app_i_my_node.h"
namespace Murl
{
namespace App
{
class MyNode : public IMyNode, public Graph::Node
{
// Declare the attributes here:
MURL_DECLARE_FACTORY_OBJECT_BEGIN(App::MyNode)
MURL_DECLARE_FACTORY_OBJECT_PROPERTY(PROPERTY_MY_ATTR)
MURL_DECLARE_FACTORY_OBJECT_END(App::MyNode)
static INode* Create(const Graph::IFactory* factory);
public:
virtual Graph::INode* GetNodeInterface();
virtual const Graph::INode* GetNodeInterface() const;
protected:
MyNode(const Graph::IFactory* factory);
virtual ~MyNode();
virtual Bool DeserializeBaseAttribute(Graph::IDeserializeAttributeTracker* tracker);
// Use member variables to store attribute values.
SInt32 mMyAttr;
};
}
}
Then implement in the CPP file:
using namespace Murl;
// Define the attributes here:
MURL_DEFINE_FACTORY_OBJECT_BEGIN(App::MyNode)
MURL_DEFINE_FACTORY_OBJECT_PROPERTY(PROPERTY_MY_ATTR, "myAttr")
MURL_DEFINE_FACTORY_OBJECT_END(App::MyNode)
Graph::INode* App::MyNode::Create(const Graph::IFactory* factory)
{
return new MyNode(factory);
}
App::MyNode::MyNode(const Graph::IFactory* factory)
: Graph::Node(factory)
, mMyAttr(0)
{
}
App::MyNode::~MyNode()
{
}
Graph::INode* App::MyNode::GetNodeInterface()
{
return this;
}
const Graph::INode* App::MyNode::GetNodeInterface() const
{
return this;
}
Bool App::MyNode::DeserializeBaseAttribute(Graph::IDeserializeAttributeTracker* tracker)
{
switch(tracker->GetBaseAttributeProperty(GetProperties()))
{
case PROPERTY_MY_ATTR:
tracker->GetAttributeValue(mMyAttr);
return true;
// handle other attributes here
default:
return Graph::Node::DeserializeBaseAttribute(tracker);
}
}
You may want to override the InitSelf, ProcessLogicSelf, etc. methods from Graph::Node to add custom behavior.
Finally, you need to register/unregister the node in your App class by overriding these methods from AppBase:
Bool App::MyApp::RegisterCustomFactoryClasses(IAppFactoryRegistry* factoryRegistry)
{
factoryRegistry->GetGraphFactoryRegistry()->RegisterNodeClass(App::MyNode::GetClassInfo());
return true;
}
Bool App::MyApp::UnregisterCustomFactoryClasses(IAppFactoryRegistry* factoryRegistry)
{
factoryRegistry->GetGraphFactoryRegistry()->UnregisterNodeClass(App::MyNode::GetClassInfo());
return true;
}
Now you can use:
<App::MyNode myAttr="42"/>
Or:
<MyNode myAttr="42"/>