lemon/list_graph.h
changeset 1784 d9eb186547d7
parent 1770 657de7e5043c
child 1791 62e7d237e1fb
equal deleted inserted replaced
10:f6d07de47328 11:b85bd6b73833
    28 #include <lemon/bits/alteration_notifier.h>
    28 #include <lemon/bits/alteration_notifier.h>
    29 #include <lemon/bits/default_map.h>
    29 #include <lemon/bits/default_map.h>
    30 
    30 
    31 #include <lemon/bits/undir_graph_extender.h>
    31 #include <lemon/bits/undir_graph_extender.h>
    32 
    32 
       
    33 #include <lemon/error.h>
       
    34 
    33 #include <list>
    35 #include <list>
    34 
    36 
    35 namespace lemon {
    37 namespace lemon {
    36 
    38 
    37   class ListGraphBase {
    39   class ListGraphBase {
   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() {}
   486 	  detach();
   494 	  detach();
   487 	AlterationNotifier<Edge>::ObserverBase::
   495 	AlterationNotifier<Edge>::ObserverBase::
   488 	  detach();
   496 	  detach();
   489 	g=0;
   497 	g=0;
   490       }
   498       }
   491             
   499 
   492     public:
   500     public:
   493       ///Default constructur.
   501       ///Default constructur.
   494       
   502       
   495       ///Default constructur.
   503       ///Default constructur.
   496       ///To actually make a snapshot you must call save().
   504       ///To actually make a snapshot you must call save().