00001
00017 #ifndef HIERARCHY__HPP
00018 #define HIERARCHY__HPP
00019
00020 #include <map>
00021 #include "ConstGraph.hpp"
00022 #include "ObservableGraph.hpp"
00023 #include "Subject.hpp"
00024 #include "Observer.hpp"
00025
00026
00027 namespace gns {
00028
00074 class Hierarchy : public ConstGraph, public Subject, public Observer
00075 {
00076 private:
00078 std::hash_map<Node, Node> *graphnodes;
00080 std::hash_map<Node, Node> *hierarchynodes;
00082 ObservableGraph *obsgraph;
00084 bool own_obsgraph;
00085
00087 void init(ObservableGraph *g, PropertyFacility *p);
00088
00089
00090 public:
00092 Hierarchy();
00094 Hierarchy(ObservableGraph *g, PropertyFacility *p = NULL);
00096 Hierarchy(const Hierarchy &h);
00097
00099 virtual ~Hierarchy();
00100
00101 using ConstGraph::node_id;
00102 using ConstGraph::edge_id;
00103
00105 virtual void node_id(Node n, NodeID id);
00106
00108 virtual void edge_id(Edge e, EdgeID id);
00109
00111 void update(Subject *sub, long msg, Item item);
00112
00114 Node step(std::vector<Node>::const_iterator children_begin,
00115 std::vector<Node>::const_iterator children_end, NodeID id = NodeID(""));
00116
00118 Node step(std::vector<Node> *children, NodeID id = NodeID("")) {
00119 return this->step(children->begin(), children->end(), id);
00120 }
00121
00123 void unstep(Node node);
00124
00126 void connect(Node node, Node parent);
00127
00129 void disconnect(Node node);
00130
00132 Node hierarchy_node(const Node node) const;
00133
00135 Node graph_node(const Node node) const;
00136
00138 ObservableGraph* get_graph() const;
00139
00141 void set_graph(ObservableGraph *g);
00142
00143 private:
00145 void del_node_update(Node node);
00146
00147 };
00148
00149 }
00150
00151 #endif