438 ///\warning Edge and node deletions cannot be restored. |
440 ///\warning Edge and node deletions cannot be restored. |
439 ///\warning Snapshots cannot be nested. |
441 ///\warning Snapshots cannot be nested. |
440 class Snapshot : protected AlterationNotifier<Node>::ObserverBase, |
442 class Snapshot : protected AlterationNotifier<Node>::ObserverBase, |
441 protected AlterationNotifier<Edge>::ObserverBase |
443 protected AlterationNotifier<Edge>::ObserverBase |
442 { |
444 { |
|
445 public: |
|
446 |
|
447 class UnsupportedOperation : public LogicError { |
|
448 public: |
|
449 virtual const char* exceptionName() const { |
|
450 return "lemon::ListGraph::Snapshot::UnsupportedOperation"; |
|
451 } |
|
452 }; |
|
453 |
|
454 |
443 protected: |
455 protected: |
444 |
456 |
445 ListGraph *g; |
457 ListGraph *g; |
446 std::list<Node> added_nodes; |
458 std::list<Node> added_nodes; |
447 std::list<Edge> added_edges; |
459 std::list<Edge> added_edges; |
448 |
460 |
449 bool active; |
461 bool active; |
450 virtual void add(const Node& n) { |
462 virtual void add(const Node& n) { |
451 added_nodes.push_back(n); |
463 added_nodes.push_back(n); |
452 }; |
464 }; |
453 ///\bug Exception... |
|
454 /// |
|
455 virtual void erase(const Node&) |
465 virtual void erase(const Node&) |
456 { |
466 { |
457 exit(1); |
467 throw UnsupportedOperation(); |
458 } |
468 } |
459 virtual void add(const Edge& n) { |
469 virtual void add(const Edge& n) { |
460 added_edges.push_back(n); |
470 added_edges.push_back(n); |
461 }; |
471 }; |
462 ///\bug Exception... |
|
463 /// |
|
464 virtual void erase(const Edge&) |
472 virtual void erase(const Edge&) |
465 { |
473 { |
466 exit(1); |
474 throw UnsupportedOperation(); |
467 } |
475 } |
468 |
476 |
469 ///\bug What is this used for? |
477 ///\bug What is this used for? |
470 /// |
478 /// |
471 virtual void build() {} |
479 virtual void build() {} |