Last active
December 11, 2015 15:08
-
-
Save malleor/4619116 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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