Overview     Modules     Class Hierarchy     Classes     Members  

PrintObserver

This is a small example of an observer that displays a message on the standard output each time a a node is added to a graph.

 class PrintObs : public GraphObserver {
    void addNode(Graph *g, const node n) {
       cout << "node " << n.id << " added in " << g << endl << flush;
    }
 };

 int main() {
   Graph *g = tlp::newGraph();
   PrintObs obs;
   g->addGraphObserver(&obs);
   g->addNode(); //output node 0 added in 0x
   g->addNode(); //output node 0 added in 0x
 }


Tulip Software by LaBRI Visualization Team    2001 - 2011