#include <nap/objectgraph.h>
Classes | |
struct | Edge |
struct | Node |
Public Types | |
using | ItemList = std::vector< typename ITEM::Type > |
using | ItemCreationFunction = std::function< ITEM(typename ITEM::Type)> |
Public Member Functions | |
bool | build (const ItemList &objectList, const ItemCreationFunction &creationFunction, utility::ErrorState &errorState) |
bool | rebuild (utility::ErrorState &errorState) |
void | visitNodes (const std::function< void(const Node &)> &visitor) const |
Node * | findNode (const std::string &ID) const |
const std::vector< Node * > | getSortedNodes () const |
Static Public Member Functions | |
static void | addIncomingObjectsRecursive (Node *node, std::set< Node * > &incomingObjects) |
Builds an ObjectGraph based on a list of ITEMS. Each item returns what other item it points to through ITEM::GetPointees(). After calling ObjectGraph::build(), the nodes and edges of the graph can be traversed. Each Node contains an item that can be inspected. The template parameter ITEM represent the user data that is stored in a node. The user data can contain any data that is required for a node. ITEM::Type refers to the internal type that you are wrapping in the ITEM structure. This is also the type that is used a input for the build() function. ITEMS must be constructed using a creation function that is passed to build(). This way, additional user data can be passed onto the internal items.
using ItemCreationFunction = std::function<ITEM(typename ITEM::Type)> |
using ItemList = std::vector<typename ITEM::Type> |
|
static |
Walks object graph by traversing incoming edges and pushing the results in an array.
node | start node to traverse incoming edges from. |
incomingObjects | output of the function. |
bool build | ( | const ItemList & | objectList, |
const ItemCreationFunction & | creationFunction, | ||
utility::ErrorState & | errorState | ||
) |
Node* findNode | ( | const std::string & | ID | ) | const |
const std::vector<Node*> getSortedNodes | ( | ) | const |
bool rebuild | ( | utility::ErrorState & | errorState | ) |
void visitNodes | ( | const std::function< void(const Node &)> & | visitor | ) | const |