Skip to content

Instantly share code, notes, and snippets.

@malleor
Last active December 11, 2015 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malleor/4619116 to your computer and use it in GitHub Desktop.
Save malleor/4619116 to your computer and use it in GitHub Desktop.
struct UserDerivedType :
public IUserType
{
// ...
};
void CreateCustomGraph(IProject& proj)
{
// create a uniform graph; no customization at this point
IUserGraphNode* first_node = proj.CreateUserGraph();
for(int i=0; i<10; ++i)
{
// create custom data object
UserDerivedType* new_custom_data = new UserDerivedType(...);
// create a uniform node; make it point to custom data
IUserGraphNode* new_node = first_node->AddNeighbor(new_custom_data));
}
}
void UseCustomGraph(IUserGraphNode* some_node)
{
// check whether it is a compatible node
IUserType* node_data = some_node->GetLabel();
UserDerivedType* node_checked_data;
CHECK_INHERITANCE_SOMEHOW(node_data, node_checked_data); // how to to that? is static_cast safe?
// use the node data
//node_checked_data->...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment