author | deba |
Mon, 06 Feb 2006 20:32:29 +0000 | |
changeset 1964 | df0b07457083 |
parent 1946 | 17eb3eaad9f8 |
child 1979 | c2992fd74dad |
permissions | -rw-r--r-- |
klao@946 | 1 |
/* -*- C++ -*- |
klao@946 | 2 |
* |
alpar@1956 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
alpar@1956 | 4 |
* |
alpar@1956 | 5 |
* Copyright (C) 2003-2006 |
alpar@1956 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
alpar@1956 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
klao@946 | 8 |
* |
klao@946 | 9 |
* Permission to use, modify and distribute this software is granted |
klao@946 | 10 |
* provided that this copyright notice appears in all copies. For |
klao@946 | 11 |
* precise terms see the accompanying LICENSE file. |
klao@946 | 12 |
* |
klao@946 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
klao@946 | 14 |
* express or implied, and with no claim as to its suitability for any |
klao@946 | 15 |
* purpose. |
klao@946 | 16 |
* |
klao@946 | 17 |
*/ |
klao@946 | 18 |
|
klao@946 | 19 |
#ifndef LEMON_ALTERATION_OBSERVER_REGISTRY_H |
klao@946 | 20 |
#define LEMON_ALTERATION_OBSERVER_REGISTRY_H |
klao@946 | 21 |
|
klao@946 | 22 |
#include <vector> |
klao@946 | 23 |
#include <algorithm> |
klao@946 | 24 |
|
alpar@1946 | 25 |
///\ingroup graphmapfactory |
klao@946 | 26 |
///\file |
klao@946 | 27 |
///\brief Observer registry for graph alteration observers. |
klao@946 | 28 |
|
klao@946 | 29 |
namespace lemon { |
klao@946 | 30 |
|
deba@1910 | 31 |
/// \addtogroin graphmapfactory |
klao@946 | 32 |
/// @{ |
klao@946 | 33 |
|
deba@1414 | 34 |
/// \brief Registry class to register objects observes alterations in |
deba@1414 | 35 |
/// the graph. |
deba@1414 | 36 |
/// |
klao@946 | 37 |
/// This class is a registry for the objects which observe the |
klao@946 | 38 |
/// alterations in a container. The alteration observers can be attached |
klao@946 | 39 |
/// to and detached from the registry. The observers have to inherit |
deba@1038 | 40 |
/// from the \ref AlterationNotifier::ObserverBase and override |
klao@946 | 41 |
/// the virtual functions in that. |
klao@946 | 42 |
/// |
klao@946 | 43 |
/// The most important application of the alteration observing is the |
deba@1414 | 44 |
/// dynamic map implementation. |
klao@946 | 45 |
/// |
klao@946 | 46 |
/// \param _Item The item type what the observers are observing, usually |
klao@946 | 47 |
/// edge or node. |
klao@946 | 48 |
/// |
klao@946 | 49 |
/// \author Balazs Dezso |
klao@946 | 50 |
|
klao@946 | 51 |
template <typename _Item> |
deba@1038 | 52 |
class AlterationNotifier { |
klao@946 | 53 |
public: |
klao@946 | 54 |
typedef _Item Item; |
klao@946 | 55 |
|
klao@946 | 56 |
/// ObserverBase is the base class for the observers. |
klao@946 | 57 |
|
klao@946 | 58 |
/// ObserverBase is the abstract base class for the observers. |
klao@946 | 59 |
/// It will be notified about an item was inserted into or |
klao@946 | 60 |
/// erased from the graph. |
klao@946 | 61 |
/// |
klao@946 | 62 |
/// The observer interface contains some pure virtual functions |
klao@946 | 63 |
/// to override. The add() and erase() functions are |
klao@946 | 64 |
/// to notify the oberver when one item is added or |
klao@946 | 65 |
/// erased. |
klao@946 | 66 |
/// |
klao@946 | 67 |
/// The build() and clear() members are to notify the observer |
alpar@1204 | 68 |
/// about the container is built from an empty container or |
klao@946 | 69 |
/// is cleared to an empty container. |
klao@946 | 70 |
/// |
klao@946 | 71 |
/// \author Balazs Dezso |
klao@946 | 72 |
|
klao@946 | 73 |
class ObserverBase { |
klao@946 | 74 |
protected: |
deba@1038 | 75 |
typedef AlterationNotifier Registry; |
klao@946 | 76 |
|
deba@1038 | 77 |
friend class AlterationNotifier; |
klao@946 | 78 |
|
deba@1414 | 79 |
/// \brief Default constructor. |
deba@1414 | 80 |
/// |
klao@946 | 81 |
/// Default constructor for ObserverBase. |
klao@946 | 82 |
/// |
klao@946 | 83 |
ObserverBase() : registry(0) {} |
klao@946 | 84 |
|
deba@1685 | 85 |
ObserverBase(const ObserverBase& copy) { |
deba@1685 | 86 |
if (copy.attached()) { |
deba@1685 | 87 |
copy.getRegistry()->attach(*this); |
deba@1685 | 88 |
} |
deba@1685 | 89 |
} |
deba@1685 | 90 |
|
klao@946 | 91 |
virtual ~ObserverBase() {} |
klao@946 | 92 |
|
deba@1414 | 93 |
/// \brief Attaches the observer into an AlterationNotifier. |
deba@1414 | 94 |
/// |
deba@1038 | 95 |
/// This member attaches the observer into an AlterationNotifier. |
klao@946 | 96 |
/// |
deba@1038 | 97 |
void attach(AlterationNotifier& r) { |
klao@946 | 98 |
registry = &r; |
klao@946 | 99 |
registry->attach(*this); |
klao@946 | 100 |
} |
klao@946 | 101 |
|
deba@1414 | 102 |
/// \brief Detaches the observer into an AlterationNotifier. |
deba@1414 | 103 |
/// |
deba@1038 | 104 |
/// This member detaches the observer from an AlterationNotifier. |
klao@946 | 105 |
/// |
klao@946 | 106 |
void detach() { |
klao@946 | 107 |
if (registry) { |
klao@946 | 108 |
registry->detach(*this); |
klao@946 | 109 |
} |
klao@946 | 110 |
} |
klao@946 | 111 |
|
klao@946 | 112 |
|
klao@946 | 113 |
/// Gives back a pointer to the registry what the map attached into. |
klao@946 | 114 |
|
klao@946 | 115 |
/// This function gives back a pointer to the registry what the map |
klao@946 | 116 |
/// attached into. |
klao@946 | 117 |
/// |
klao@946 | 118 |
Registry* getRegistry() const { return const_cast<Registry*>(registry); } |
klao@946 | 119 |
|
klao@946 | 120 |
/// Gives back true when the observer is attached into a registry. |
klao@946 | 121 |
bool attached() const { return registry != 0; } |
deba@1685 | 122 |
|
klao@946 | 123 |
private: |
klao@946 | 124 |
|
klao@946 | 125 |
ObserverBase& operator=(const ObserverBase& copy); |
klao@946 | 126 |
|
klao@946 | 127 |
protected: |
klao@946 | 128 |
|
klao@946 | 129 |
Registry* registry; |
klao@946 | 130 |
int registry_index; |
klao@946 | 131 |
|
klao@946 | 132 |
/// \brief The member function to notificate the observer about an |
klao@946 | 133 |
/// item is added to the container. |
klao@946 | 134 |
/// |
klao@946 | 135 |
/// The add() member function notificates the observer about an item |
klao@946 | 136 |
/// is added to the container. It have to be overrided in the |
klao@946 | 137 |
/// subclasses. |
klao@946 | 138 |
|
deba@1414 | 139 |
virtual void add(const Item&) = 0; |
klao@946 | 140 |
|
deba@1414 | 141 |
/// \brief The member function to notificate the observer about |
deba@1718 | 142 |
/// more item is added to the container. |
deba@1414 | 143 |
/// |
deba@1718 | 144 |
/// The add() member function notificates the observer about more item |
deba@1414 | 145 |
/// is added to the container. It have to be overrided in the |
deba@1414 | 146 |
/// subclasses. |
deba@1414 | 147 |
|
deba@1414 | 148 |
virtual void add(const std::vector<Item>& items) { |
deba@1414 | 149 |
for (int i = 0; i < (int)items.size(); ++i) { |
deba@1414 | 150 |
add(items[i]); |
deba@1414 | 151 |
} |
deba@1414 | 152 |
} |
klao@946 | 153 |
|
klao@946 | 154 |
/// \brief The member function to notificate the observer about an |
klao@946 | 155 |
/// item is erased from the container. |
klao@946 | 156 |
/// |
klao@946 | 157 |
/// The erase() member function notificates the observer about an |
klao@946 | 158 |
/// item is erased from the container. It have to be overrided in |
klao@946 | 159 |
/// the subclasses. |
klao@946 | 160 |
|
klao@946 | 161 |
virtual void erase(const Item&) = 0; |
klao@946 | 162 |
|
deba@1718 | 163 |
/// \brief The member function to notificate the observer about |
deba@1718 | 164 |
/// more item is erased from the container. |
deba@1718 | 165 |
/// |
deba@1718 | 166 |
/// The erase() member function notificates the observer about more item |
deba@1718 | 167 |
/// is erased from the container. It have to be overrided in the |
deba@1718 | 168 |
/// subclasses. |
deba@1414 | 169 |
virtual void erase(const std::vector<Item>& items) { |
deba@1414 | 170 |
for (int i = 0; i < (int)items.size(); ++i) { |
deba@1701 | 171 |
erase(items[i]); |
deba@1414 | 172 |
} |
deba@1414 | 173 |
} |
deba@1414 | 174 |
|
klao@946 | 175 |
/// \brief The member function to notificate the observer about the |
alpar@1204 | 176 |
/// container is built. |
klao@946 | 177 |
/// |
klao@946 | 178 |
/// The build() member function notificates the observer about the |
alpar@1204 | 179 |
/// container is built from an empty container. It have to be |
klao@946 | 180 |
/// overrided in the subclasses. |
klao@946 | 181 |
|
klao@946 | 182 |
virtual void build() = 0; |
klao@946 | 183 |
|
klao@946 | 184 |
/// \brief The member function to notificate the observer about all |
klao@946 | 185 |
/// items are erased from the container. |
klao@946 | 186 |
/// |
klao@946 | 187 |
/// The clear() member function notificates the observer about all |
klao@946 | 188 |
/// items are erased from the container. It have to be overrided in |
klao@946 | 189 |
/// the subclasses. |
klao@946 | 190 |
|
klao@946 | 191 |
virtual void clear() = 0; |
klao@946 | 192 |
|
klao@946 | 193 |
}; |
klao@946 | 194 |
|
klao@946 | 195 |
protected: |
klao@946 | 196 |
|
klao@946 | 197 |
|
klao@946 | 198 |
typedef std::vector<ObserverBase*> Container; |
klao@946 | 199 |
|
klao@946 | 200 |
Container container; |
klao@946 | 201 |
|
klao@946 | 202 |
|
klao@946 | 203 |
public: |
klao@946 | 204 |
|
klao@946 | 205 |
/// Default constructor. |
klao@946 | 206 |
|
klao@946 | 207 |
/// |
deba@1038 | 208 |
/// The default constructor of the AlterationNotifier. |
klao@946 | 209 |
/// It creates an empty registry. |
deba@1038 | 210 |
AlterationNotifier() {} |
klao@946 | 211 |
|
deba@1038 | 212 |
/// Copy Constructor of the AlterationNotifier. |
klao@946 | 213 |
|
deba@1038 | 214 |
/// Copy constructor of the AlterationNotifier. |
klao@946 | 215 |
/// It creates only an empty registry because the copiable |
klao@946 | 216 |
/// registry's observers have to be registered still into that registry. |
deba@1039 | 217 |
AlterationNotifier(const AlterationNotifier&) {} |
klao@946 | 218 |
|
klao@946 | 219 |
/// Assign operator. |
klao@946 | 220 |
|
deba@1038 | 221 |
/// Assign operator for the AlterationNotifier. |
deba@1040 | 222 |
/// It makes the notifier only empty because the copiable |
deba@1040 | 223 |
/// notifier's observers have to be registered still into that registry. |
deba@1039 | 224 |
AlterationNotifier& operator=(const AlterationNotifier&) { |
klao@946 | 225 |
typename Container::iterator it; |
klao@946 | 226 |
for (it = container.begin(); it != container.end(); ++it) { |
klao@946 | 227 |
(*it)->registry = 0; |
klao@946 | 228 |
} |
klao@946 | 229 |
} |
klao@946 | 230 |
|
klao@946 | 231 |
/// Destructor. |
klao@946 | 232 |
|
deba@1038 | 233 |
/// Destructor of the AlterationNotifier. |
klao@946 | 234 |
/// |
deba@1038 | 235 |
~AlterationNotifier() { |
klao@946 | 236 |
typename Container::iterator it; |
klao@946 | 237 |
for (it = container.begin(); it != container.end(); ++it) { |
klao@946 | 238 |
(*it)->registry = 0; |
klao@946 | 239 |
} |
klao@946 | 240 |
} |
klao@946 | 241 |
|
klao@946 | 242 |
|
klao@946 | 243 |
protected: |
klao@946 | 244 |
|
klao@946 | 245 |
void attach(ObserverBase& observer) { |
klao@946 | 246 |
container.push_back(&observer); |
klao@946 | 247 |
observer.registry = this; |
klao@946 | 248 |
observer.registry_index = container.size()-1; |
klao@946 | 249 |
} |
klao@946 | 250 |
|
klao@946 | 251 |
void detach(ObserverBase& base) { |
klao@946 | 252 |
container.back()->registry_index = base.registry_index; |
klao@946 | 253 |
container[base.registry_index] = container.back(); |
klao@946 | 254 |
container.pop_back(); |
klao@946 | 255 |
base.registry = 0; |
klao@946 | 256 |
} |
klao@946 | 257 |
|
klao@946 | 258 |
public: |
klao@946 | 259 |
|
deba@1414 | 260 |
/// \brief Notifies all the registered observers about an Item added to |
deba@1414 | 261 |
/// the container. |
deba@1414 | 262 |
/// |
deba@1414 | 263 |
/// It notifies all the registered observers about an Item added to |
deba@1414 | 264 |
/// the container. |
klao@946 | 265 |
/// |
deba@1414 | 266 |
void add(const Item& item) { |
klao@946 | 267 |
typename Container::iterator it; |
klao@946 | 268 |
for (it = container.begin(); it != container.end(); ++it) { |
deba@1414 | 269 |
(*it)->add(item); |
klao@946 | 270 |
} |
klao@946 | 271 |
} |
klao@946 | 272 |
|
deba@1414 | 273 |
/// \brief Notifies all the registered observers about more Item added to |
deba@1414 | 274 |
/// the container. |
deba@1414 | 275 |
/// |
deba@1414 | 276 |
/// It notifies all the registered observers about more Item added to |
deba@1414 | 277 |
/// the container. |
deba@1414 | 278 |
/// |
deba@1414 | 279 |
void add(const std::vector<Item>& items) { |
deba@1414 | 280 |
typename Container::iterator it; |
deba@1414 | 281 |
for (it = container.begin(); it != container.end(); ++it) { |
deba@1414 | 282 |
(*it)->add(items); |
deba@1414 | 283 |
} |
deba@1414 | 284 |
} |
deba@1414 | 285 |
|
deba@1414 | 286 |
/// \brief Notifies all the registered observers about an Item erased from |
deba@1414 | 287 |
/// the container. |
deba@1414 | 288 |
/// |
deba@1414 | 289 |
/// It notifies all the registered observers about an Item erased from |
deba@1414 | 290 |
/// the container. |
klao@946 | 291 |
/// |
klao@946 | 292 |
void erase(const Item& key) { |
klao@946 | 293 |
typename Container::iterator it; |
klao@946 | 294 |
for (it = container.begin(); it != container.end(); ++it) { |
klao@946 | 295 |
(*it)->erase(key); |
klao@946 | 296 |
} |
klao@946 | 297 |
} |
deba@1414 | 298 |
|
deba@1414 | 299 |
/// \brief Notifies all the registered observers about more Item erased |
deba@1414 | 300 |
/// from the container. |
deba@1414 | 301 |
/// |
deba@1414 | 302 |
/// It notifies all the registered observers about more Item erased from |
deba@1414 | 303 |
/// the container. |
deba@1414 | 304 |
/// |
deba@1414 | 305 |
void erase(const std::vector<Item>& items) { |
deba@1414 | 306 |
typename Container::iterator it; |
deba@1414 | 307 |
for (it = container.begin(); it != container.end(); ++it) { |
deba@1414 | 308 |
(*it)->erase(items); |
deba@1414 | 309 |
} |
deba@1414 | 310 |
} |
klao@946 | 311 |
|
deba@1414 | 312 |
/// \brief Notifies all the registered observers about the container is |
deba@1414 | 313 |
/// built. |
deba@1414 | 314 |
/// |
alpar@1204 | 315 |
/// Notifies all the registered observers about the container is built |
klao@946 | 316 |
/// from an empty container. |
klao@946 | 317 |
void build() { |
klao@946 | 318 |
typename Container::iterator it; |
klao@946 | 319 |
for (it = container.begin(); it != container.end(); ++it) { |
klao@946 | 320 |
(*it)->build(); |
klao@946 | 321 |
} |
klao@946 | 322 |
} |
klao@946 | 323 |
|
klao@946 | 324 |
|
deba@1414 | 325 |
/// \brief Notifies all the registered observers about all Items are |
deba@1414 | 326 |
/// erased. |
deba@1414 | 327 |
/// |
klao@946 | 328 |
/// Notifies all the registered observers about all Items are erased |
klao@946 | 329 |
/// from the container. |
klao@946 | 330 |
void clear() { |
klao@946 | 331 |
typename Container::iterator it; |
klao@946 | 332 |
for (it = container.begin(); it != container.end(); ++it) { |
klao@946 | 333 |
(*it)->clear(); |
klao@946 | 334 |
} |
klao@946 | 335 |
} |
klao@946 | 336 |
}; |
klao@946 | 337 |
|
klao@946 | 338 |
|
klao@962 | 339 |
/// \brief Class to extend a graph with the functionality of alteration |
klao@962 | 340 |
/// observing. |
klao@962 | 341 |
/// |
klao@962 | 342 |
/// AlterableGraphExtender extends the _Base graphs functionality with |
klao@962 | 343 |
/// the possibility of alteration observing. It defines two observer |
klao@962 | 344 |
/// registrys for the nodes and mapes. |
klao@962 | 345 |
/// |
klao@962 | 346 |
/// \todo Document what "alteration observing" is. And probably find a |
klao@962 | 347 |
/// better (shorter) name. |
klao@946 | 348 |
/// |
klao@946 | 349 |
/// \param _Base is the base class to extend. |
klao@946 | 350 |
/// |
klao@946 | 351 |
/// \pre _Base is conform to the BaseGraphComponent concept. |
klao@946 | 352 |
/// |
klao@962 | 353 |
/// \post AlterableGraphExtender<_Base> is conform to the |
klao@962 | 354 |
/// AlterableGraphComponent concept. |
klao@946 | 355 |
/// |
klao@946 | 356 |
/// \author Balazs Dezso |
klao@946 | 357 |
|
klao@946 | 358 |
template <typename _Base> |
klao@946 | 359 |
class AlterableGraphExtender : public _Base { |
klao@946 | 360 |
public: |
klao@946 | 361 |
|
klao@946 | 362 |
typedef AlterableGraphExtender Graph; |
klao@946 | 363 |
typedef _Base Parent; |
klao@946 | 364 |
|
klao@946 | 365 |
typedef typename Parent::Node Node; |
klao@946 | 366 |
typedef typename Parent::Edge Edge; |
klao@946 | 367 |
|
klao@962 | 368 |
/// The edge observer registry. |
deba@1039 | 369 |
typedef AlterationNotifier<Edge> EdgeNotifier; |
klao@946 | 370 |
/// The node observer registry. |
deba@1039 | 371 |
typedef AlterationNotifier<Node> NodeNotifier; |
klao@946 | 372 |
|
klao@946 | 373 |
|
klao@946 | 374 |
protected: |
klao@946 | 375 |
|
deba@1040 | 376 |
mutable EdgeNotifier edge_notifier; |
klao@946 | 377 |
|
deba@1040 | 378 |
mutable NodeNotifier node_notifier; |
klao@946 | 379 |
|
klao@946 | 380 |
public: |
klao@946 | 381 |
|
deba@1134 | 382 |
/// \brief Gives back the edge alteration notifier. |
deba@1134 | 383 |
/// |
deba@1134 | 384 |
/// Gives back the edge alteration notifier. |
deba@1134 | 385 |
EdgeNotifier& getNotifier(Edge) const { |
deba@1040 | 386 |
return edge_notifier; |
klao@946 | 387 |
} |
klao@946 | 388 |
|
deba@1134 | 389 |
/// \brief Gives back the node alteration notifier. |
deba@1134 | 390 |
/// |
deba@1134 | 391 |
/// Gives back the node alteration notifier. |
deba@1134 | 392 |
NodeNotifier& getNotifier(Node) const { |
deba@1040 | 393 |
return node_notifier; |
klao@946 | 394 |
} |
klao@946 | 395 |
|
klao@946 | 396 |
~AlterableGraphExtender() { |
deba@1040 | 397 |
node_notifier.clear(); |
deba@1040 | 398 |
edge_notifier.clear(); |
klao@946 | 399 |
} |
klao@946 | 400 |
|
klao@946 | 401 |
}; |
klao@946 | 402 |
|
deba@1842 | 403 |
|
deba@1842 | 404 |
template <typename _Base> |
deba@1842 | 405 |
class AlterableEdgeSetExtender : public _Base { |
deba@1842 | 406 |
public: |
deba@1842 | 407 |
|
deba@1842 | 408 |
typedef AlterableEdgeSetExtender Graph; |
deba@1842 | 409 |
typedef _Base Parent; |
deba@1842 | 410 |
|
deba@1842 | 411 |
typedef typename Parent::Edge Edge; |
deba@1842 | 412 |
|
deba@1842 | 413 |
/// The edge observer registry. |
deba@1842 | 414 |
typedef AlterationNotifier<Edge> EdgeNotifier; |
deba@1842 | 415 |
|
deba@1842 | 416 |
protected: |
deba@1842 | 417 |
|
deba@1842 | 418 |
mutable EdgeNotifier edge_notifier; |
deba@1842 | 419 |
|
deba@1842 | 420 |
public: |
deba@1842 | 421 |
|
deba@1842 | 422 |
/// \brief Gives back the edge alteration notifier. |
deba@1842 | 423 |
/// |
deba@1842 | 424 |
/// Gives back the edge alteration notifier. |
deba@1842 | 425 |
EdgeNotifier& getNotifier(Edge) const { |
deba@1842 | 426 |
return edge_notifier; |
deba@1842 | 427 |
} |
deba@1842 | 428 |
|
deba@1842 | 429 |
~AlterableEdgeSetExtender() { |
deba@1842 | 430 |
edge_notifier.clear(); |
deba@1842 | 431 |
} |
deba@1842 | 432 |
|
deba@1842 | 433 |
}; |
deba@1842 | 434 |
|
klao@962 | 435 |
/// \brief Class to extend an undirected graph with the functionality of |
klao@962 | 436 |
/// alteration observing. |
klao@962 | 437 |
/// |
klao@962 | 438 |
/// \todo Document. |
klao@962 | 439 |
/// |
klao@962 | 440 |
/// \sa AlterableGraphExtender |
klao@962 | 441 |
/// |
klao@962 | 442 |
/// \bug This should be done some other way. Possibilities: template |
klao@962 | 443 |
/// specialization (not very easy, if at all possible); some kind of |
klao@962 | 444 |
/// enable_if boost technique? |
klao@962 | 445 |
|
klao@962 | 446 |
template <typename _Base> |
klao@1909 | 447 |
class AlterableUGraphExtender |
klao@962 | 448 |
: public AlterableGraphExtender<_Base> { |
klao@962 | 449 |
public: |
klao@962 | 450 |
|
klao@1909 | 451 |
typedef AlterableUGraphExtender Graph; |
klao@962 | 452 |
typedef AlterableGraphExtender<_Base> Parent; |
klao@962 | 453 |
|
klao@1909 | 454 |
typedef typename Parent::UEdge UEdge; |
klao@962 | 455 |
|
klao@962 | 456 |
/// The edge observer registry. |
klao@1909 | 457 |
typedef AlterationNotifier<UEdge> UEdgeNotifier; |
klao@962 | 458 |
|
klao@962 | 459 |
protected: |
klao@962 | 460 |
|
klao@1909 | 461 |
mutable UEdgeNotifier u_edge_notifier; |
klao@962 | 462 |
|
klao@1022 | 463 |
public: |
klao@1022 | 464 |
|
deba@1038 | 465 |
using Parent::getNotifier; |
klao@1909 | 466 |
UEdgeNotifier& getNotifier(UEdge) const { |
klao@1909 | 467 |
return u_edge_notifier; |
klao@962 | 468 |
} |
klao@962 | 469 |
|
klao@1909 | 470 |
~AlterableUGraphExtender() { |
klao@1909 | 471 |
u_edge_notifier.clear(); |
klao@962 | 472 |
} |
klao@962 | 473 |
}; |
deba@1820 | 474 |
|
deba@1842 | 475 |
template <typename _Base> |
klao@1909 | 476 |
class AlterableUEdgeSetExtender |
deba@1842 | 477 |
: public AlterableEdgeSetExtender<_Base> { |
deba@1842 | 478 |
public: |
deba@1842 | 479 |
|
klao@1909 | 480 |
typedef AlterableUEdgeSetExtender Graph; |
deba@1842 | 481 |
typedef AlterableEdgeSetExtender<_Base> Parent; |
deba@1842 | 482 |
|
klao@1909 | 483 |
typedef typename Parent::UEdge UEdge; |
deba@1842 | 484 |
|
klao@1909 | 485 |
typedef AlterationNotifier<UEdge> UEdgeNotifier; |
deba@1842 | 486 |
|
deba@1842 | 487 |
protected: |
deba@1842 | 488 |
|
klao@1909 | 489 |
mutable UEdgeNotifier u_edge_notifier; |
deba@1842 | 490 |
|
deba@1842 | 491 |
public: |
deba@1842 | 492 |
|
deba@1842 | 493 |
using Parent::getNotifier; |
klao@1909 | 494 |
UEdgeNotifier& getNotifier(UEdge) const { |
klao@1909 | 495 |
return u_edge_notifier; |
deba@1842 | 496 |
} |
deba@1842 | 497 |
|
klao@1909 | 498 |
~AlterableUEdgeSetExtender() { |
klao@1909 | 499 |
u_edge_notifier.clear(); |
deba@1842 | 500 |
} |
deba@1842 | 501 |
}; |
deba@1842 | 502 |
|
deba@1842 | 503 |
|
deba@1820 | 504 |
|
deba@1820 | 505 |
template <typename _Base> |
deba@1910 | 506 |
class AlterableBpUGraphExtender : public _Base { |
deba@1820 | 507 |
public: |
deba@1820 | 508 |
|
deba@1820 | 509 |
typedef _Base Parent; |
deba@1910 | 510 |
typedef AlterableBpUGraphExtender Graph; |
deba@1820 | 511 |
|
deba@1820 | 512 |
typedef typename Parent::Node Node; |
deba@1910 | 513 |
typedef typename Parent::BNode BNode; |
deba@1910 | 514 |
typedef typename Parent::ANode ANode; |
deba@1820 | 515 |
typedef typename Parent::Edge Edge; |
klao@1909 | 516 |
typedef typename Parent::UEdge UEdge; |
deba@1820 | 517 |
|
deba@1820 | 518 |
|
deba@1820 | 519 |
typedef AlterationNotifier<Node> NodeNotifier; |
deba@1910 | 520 |
typedef AlterationNotifier<BNode> BNodeNotifier; |
deba@1910 | 521 |
typedef AlterationNotifier<ANode> ANodeNotifier; |
deba@1820 | 522 |
typedef AlterationNotifier<Edge> EdgeNotifier; |
klao@1909 | 523 |
typedef AlterationNotifier<UEdge> UEdgeNotifier; |
deba@1820 | 524 |
|
deba@1820 | 525 |
protected: |
deba@1820 | 526 |
|
deba@1820 | 527 |
mutable NodeNotifier nodeNotifier; |
deba@1910 | 528 |
mutable BNodeNotifier bNodeNotifier; |
deba@1910 | 529 |
mutable ANodeNotifier aNodeNotifier; |
deba@1820 | 530 |
mutable EdgeNotifier edgeNotifier; |
klao@1909 | 531 |
mutable UEdgeNotifier uEdgeNotifier; |
deba@1820 | 532 |
|
deba@1820 | 533 |
public: |
deba@1820 | 534 |
|
deba@1820 | 535 |
NodeNotifier& getNotifier(Node) const { |
deba@1820 | 536 |
return nodeNotifier; |
deba@1820 | 537 |
} |
deba@1820 | 538 |
|
deba@1910 | 539 |
BNodeNotifier& getNotifier(BNode) const { |
deba@1910 | 540 |
return bNodeNotifier; |
deba@1820 | 541 |
} |
deba@1820 | 542 |
|
deba@1910 | 543 |
ANodeNotifier& getNotifier(ANode) const { |
deba@1910 | 544 |
return aNodeNotifier; |
deba@1820 | 545 |
} |
deba@1820 | 546 |
|
deba@1820 | 547 |
EdgeNotifier& getNotifier(Edge) const { |
deba@1820 | 548 |
return edgeNotifier; |
deba@1820 | 549 |
} |
deba@1820 | 550 |
|
klao@1909 | 551 |
UEdgeNotifier& getNotifier(UEdge) const { |
klao@1909 | 552 |
return uEdgeNotifier; |
deba@1820 | 553 |
} |
deba@1820 | 554 |
|
deba@1910 | 555 |
~AlterableBpUGraphExtender() { |
deba@1820 | 556 |
nodeNotifier.clear(); |
deba@1910 | 557 |
bNodeNotifier.clear(); |
deba@1910 | 558 |
aNodeNotifier.clear(); |
deba@1820 | 559 |
edgeNotifier.clear(); |
klao@1909 | 560 |
uEdgeNotifier.clear(); |
deba@1820 | 561 |
} |
deba@1820 | 562 |
|
deba@1820 | 563 |
}; |
klao@946 | 564 |
|
klao@946 | 565 |
/// @} |
klao@946 | 566 |
|
klao@946 | 567 |
|
klao@946 | 568 |
} |
klao@946 | 569 |
|
klao@946 | 570 |
#endif |