1.1 --- a/src/lemon/concept/graph_component.h Mon Feb 07 10:48:14 2005 +0000
1.2 +++ b/src/lemon/concept/graph_component.h Mon Feb 07 10:49:44 2005 +0000
1.3 @@ -25,6 +25,8 @@
1.4 #include <lemon/invalid.h>
1.5 #include <lemon/concept/maps.h>
1.6
1.7 +#include <lemon/alteration_notifier.h>
1.8 +
1.9 namespace lemon {
1.10 namespace concept {
1.11
1.12 @@ -571,9 +573,11 @@
1.13 /// Copy constructor.
1.14 ///
1.15 GraphIncIterator(GraphIncIterator const&) {}
1.16 - /// Sets the iterator to the first edge incoming into or outgoing from the node.
1.17 + /// Sets the iterator to the first edge incoming into or outgoing
1.18 + /// from the node.
1.19
1.20 - /// Sets the iterator to the first edge incoming into or outgoing from the node.
1.21 + /// Sets the iterator to the first edge incoming into or outgoing
1.22 + /// from the node.
1.23 ///
1.24 explicit GraphIncIterator(const Graph&, const typename Graph::Node&) {}
1.25 /// Invalid constructor \& conversion.
1.26 @@ -671,13 +675,46 @@
1.27 void constraints() {
1.28 checkConcept< BaseGraphComponent, _Graph>();
1.29
1.30 - checkConcept<GraphIterator<_Graph, typename _Graph::Edge>, typename _Graph::EdgeIt >();
1.31 - checkConcept<GraphIterator<_Graph, typename _Graph::Node>, typename _Graph::NodeIt >();
1.32 + checkConcept<GraphIterator<_Graph, typename _Graph::Edge>,
1.33 + typename _Graph::EdgeIt >();
1.34 + checkConcept<GraphIterator<_Graph, typename _Graph::Node>,
1.35 + typename _Graph::NodeIt >();
1.36 checkConcept<GraphIncIterator<_Graph>, typename _Graph::InEdgeIt >();
1.37 checkConcept<GraphIncIterator<_Graph>, typename _Graph::OutEdgeIt >();
1.38 }
1.39 };
1.40
1.41 + /// An empty alteration notifier base graph class.
1.42 +
1.43 + /// This class provides beside the core graph features
1.44 + /// alteration notifier interface for the graph structure.
1.45 + /// This is an observer-notifier pattern. More Obsevers can
1.46 + /// be registered into the notifier and whenever an alteration
1.47 + /// occured in the graph all the observers will notified about it.
1.48 + class AlterableGraphComponent : virtual public BaseGraphComponent {
1.49 + public:
1.50 +
1.51 + /// The edge observer registry.
1.52 + typedef AlterationNotifier<Edge> EdgeNotifier;
1.53 + /// The node observer registry.
1.54 + typedef AlterationNotifier<Node> NodeNotifier;
1.55 +
1.56 + /// \brief Gives back the edge alteration notifier.
1.57 + ///
1.58 + /// Gives back the edge alteration notifier.
1.59 + EdgeNotifier getNotifier(Edge) const {
1.60 + return EdgeNotifier();
1.61 + }
1.62 +
1.63 + /// \brief Gives back the node alteration notifier.
1.64 + ///
1.65 + /// Gives back the node alteration notifier.
1.66 + NodeNotifier getNotifier(Node) const {
1.67 + return NodeNotifier();
1.68 + }
1.69 +
1.70 + };
1.71 +
1.72
1.73 /// Class describing the concept of graph maps
1.74
1.75 @@ -689,10 +726,22 @@
1.76 protected:
1.77 GraphMap() {}
1.78 public:
1.79 + /// \brief Construct a new map.
1.80 + ///
1.81 + /// Construct a new map for the graph.
1.82 explicit GraphMap(const Graph&) {}
1.83 + /// \brief Construct a new map with default value.
1.84 + ///
1.85 + /// Construct a new map for the graph and initalise the values.
1.86 GraphMap(const Graph&, const _Value&) {}
1.87 + /// \brief Copy constructor.
1.88 + ///
1.89 + /// Copy Constructor.
1.90 GraphMap(const GraphMap&) {}
1.91
1.92 + /// \brief Assign operator.
1.93 + ///
1.94 + /// Assign operator.
1.95 GraphMap& operator=(const GraphMap&) { return *this;}
1.96
1.97 template<typename _Map>
1.98 @@ -740,11 +789,23 @@
1.99 private:
1.100 NodeMap();
1.101 public:
1.102 - // \todo call the right parent class constructor
1.103 + /// \brief Construct a new map.
1.104 + ///
1.105 + /// Construct a new map for the graph.
1.106 + /// \todo call the right parent class constructor
1.107 explicit NodeMap(const Graph&) {}
1.108 + /// \brief Construct a new map with default value.
1.109 + ///
1.110 + /// Construct a new map for the graph and initalise the values.
1.111 NodeMap(const Graph&, const _Value&) {}
1.112 + /// \brief Copy constructor.
1.113 + ///
1.114 + /// Copy Constructor.
1.115 NodeMap(const NodeMap&) {}
1.116
1.117 + /// \brief Assign operator.
1.118 + ///
1.119 + /// Assign operator.
1.120 NodeMap& operator=(const NodeMap&) { return *this;}
1.121
1.122 };
1.123 @@ -758,11 +819,23 @@
1.124 private:
1.125 EdgeMap();
1.126 public:
1.127 - // \todo call the right parent class constructor
1.128 + /// \brief Construct a new map.
1.129 + ///
1.130 + /// Construct a new map for the graph.
1.131 + /// \todo call the right parent class constructor
1.132 explicit EdgeMap(const Graph&) {}
1.133 + /// \brief Construct a new map with default value.
1.134 + ///
1.135 + /// Construct a new map for the graph and initalise the values.
1.136 EdgeMap(const Graph&, const _Value&) {}
1.137 + /// \brief Copy constructor.
1.138 + ///
1.139 + /// Copy Constructor.
1.140 EdgeMap(const EdgeMap&) {}
1.141
1.142 + /// \brief Assign operator.
1.143 + ///
1.144 + /// Assign operator.
1.145 EdgeMap& operator=(const EdgeMap&) { return *this;}
1.146
1.147 };
1.148 @@ -780,24 +853,30 @@
1.149 checkConcept<BaseGraphComponent, _Graph>();
1.150 { // int map test
1.151 typedef typename _Graph::template NodeMap<int> IntNodeMap;
1.152 - checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, IntNodeMap >();
1.153 + checkConcept<GraphMap<_Graph, typename _Graph::Node, int>,
1.154 + IntNodeMap >();
1.155 } { // bool map test
1.156 typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
1.157 - checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>, BoolNodeMap >();
1.158 + checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
1.159 + BoolNodeMap >();
1.160 } { // Type map test
1.161 typedef typename _Graph::template NodeMap<Type> TypeNodeMap;
1.162 - checkConcept<GraphMap<_Graph, typename _Graph::Node, Type>, TypeNodeMap >();
1.163 + checkConcept<GraphMap<_Graph, typename _Graph::Node, Type>,
1.164 + TypeNodeMap >();
1.165 }
1.166
1.167 { // int map test
1.168 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1.169 - checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>, IntEdgeMap >();
1.170 + checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1.171 + IntEdgeMap >();
1.172 } { // bool map test
1.173 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1.174 - checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>, BoolEdgeMap >();
1.175 + checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1.176 + BoolEdgeMap >();
1.177 } { // Type map test
1.178 typedef typename _Graph::template EdgeMap<Type> TypeEdgeMap;
1.179 - checkConcept<GraphMap<_Graph, typename _Graph::Edge, Type>, TypeEdgeMap >();
1.180 + checkConcept<GraphMap<_Graph, typename _Graph::Edge, Type>,
1.181 + TypeEdgeMap >();
1.182 }
1.183 }
1.184
1.185 @@ -805,7 +884,13 @@
1.186 };
1.187 };
1.188
1.189 -
1.190 + /// \brief An empty extendable extended graph class.
1.191 + ///
1.192 + /// This class provides beside the core graph features
1.193 + /// item addition interface for the graph structure.
1.194 + /// The difference between this class and the
1.195 + /// \c BaseExtendableGraphComponent is that it should
1.196 + /// notify the item alteration observers.
1.197 class ExtendableGraphComponent : virtual public BaseGraphComponent {
1.198 public:
1.199
1.200 @@ -814,10 +899,16 @@
1.201 typedef BaseGraphComponent::Node Node;
1.202 typedef BaseGraphComponent::Edge Edge;
1.203
1.204 + /// \brief Add a node to the graph.
1.205 + ///
1.206 + /// Add a node to the graph and notify the observers.
1.207 Node addNode() {
1.208 return INVALID;
1.209 }
1.210
1.211 + /// \brief Add an edge to the graph.
1.212 + ///
1.213 + /// Add an edge to the graph and notify the observers.
1.214 Edge addEdge(const Node& from, const Node& to) {
1.215 return INVALID;
1.216 }
1.217 @@ -834,6 +925,14 @@
1.218 _Graph& graph;
1.219 };
1.220 };
1.221 +
1.222 + /// \brief An empty erasable extended graph class.
1.223 + ///
1.224 + /// This class provides beside the core graph features
1.225 + /// item erase interface for the graph structure.
1.226 + /// The difference between this class and the
1.227 + /// \c BaseErasableGraphComponent is that it should
1.228 + /// notify the item alteration observers.
1.229 class ErasableGraphComponent : virtual public BaseGraphComponent {
1.230 public:
1.231
1.232 @@ -842,7 +941,14 @@
1.233 typedef BaseGraphComponent::Node Node;
1.234 typedef BaseGraphComponent::Edge Edge;
1.235
1.236 + /// \brief Erase the Node and notify the node alteration observers.
1.237 + ///
1.238 + /// Erase the Node and notify the node alteration observers.
1.239 void erase(const Node&) {}
1.240 +
1.241 + /// \brief Erase the Edge and notify the edge alteration observers.
1.242 + ///
1.243 + /// Erase the Edge and notify the edge alteration observers.
1.244 void erase(const Edge&) {}
1.245
1.246 template <typename _Graph>