NAP
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ObjectGraph< ITEM > Class Template Referencefinal

#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
 
NodefindNode (const std::string &ID) const
 
const std::vector< Node * > getSortedNodes () const
 

Static Public Member Functions

static void addIncomingObjectsRecursive (Node *node, std::set< Node * > &incomingObjects)
 

Description

template<typename ITEM>
class nap::ObjectGraph< ITEM >

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.

Member Typedef Documentation

◆ ItemCreationFunction

using ItemCreationFunction = std::function<ITEM(typename ITEM::Type)>

◆ ItemList

using ItemList = std::vector<typename ITEM::Type>

Member Function Documentation

◆ addIncomingObjectsRecursive()

static void addIncomingObjectsRecursive ( Node node,
std::set< Node * > &  incomingObjects 
)
static

Walks object graph by traversing incoming edges and pushing the results in an array.

Parameters
nodestart node to traverse incoming edges from.
incomingObjectsoutput of the function.

◆ build()

bool build ( const ItemList objectList,
const ItemCreationFunction creationFunction,
utility::ErrorState errorState 
)

◆ findNode()

Node* findNode ( const std::string &  ID) const

◆ getSortedNodes()

const std::vector<Node*> getSortedNodes ( ) const

◆ rebuild()

bool rebuild ( utility::ErrorState errorState)

◆ visitNodes()

void visitNodes ( const std::function< void(const Node &)> &  visitor) const