21 #ifndef DOXYGEN_NOTFOR_DEVEL 
   22 #ifndef TLPGRAPHRECORDER_H 
   23 #define TLPGRAPHRECORDER_H 
   31 #include <tulip/Node.h> 
   33 #include <tulip/Graph.h> 
   35 #include <tulip/MutableContainer.h> 
   39 struct less<tlp::Graph*> {
 
   54   std::set<tlp::Graph*> graphs;
 
   57   EdgeRecord(Graph* g, node s, node t) : source(s), target(t) {
 
   62 struct GraphEltsRecord {
 
   64   MutableContainer<bool> elts;
 
   66   GraphEltsRecord(Graph* g): graph(g) {}
 
   73 struct less<tlp::GraphEltsRecord*> {
 
   74   size_t  operator()(
const tlp::GraphEltsRecord* g1, 
const tlp::GraphEltsRecord* g2)
 const {
 
   75     return g1->graph->getId() < g2->graph->getId();
 
   82 class GraphStorageIdsMemento;
 
   84 class GraphUpdatesRecorder :
public Observable {
 
   85   friend class GraphImpl;
 
   88   bool recordingStopped;
 
   92   bool newValuesRecorded;
 
   95   MutableContainer<GraphEltsRecord*> graphAddedNodes;
 
   97   MutableContainer<bool> addedNodes;
 
   99   MutableContainer<GraphEltsRecord*> graphDeletedNodes;
 
  101   MutableContainer<GraphEltsRecord*> graphAddedEdges;
 
  103   MutableContainer<std::pair<node, node>*> addedEdgesEnds;
 
  105   MutableContainer<GraphEltsRecord*> graphDeletedEdges;
 
  107   MutableContainer<std::pair<node, node>*> deletedEdgesEnds;
 
  109   std::set<edge> revertedEdges;
 
  111   TLP_HASH_MAP<edge, std::pair<node, node> > oldEdgesEnds;
 
  113   TLP_HASH_MAP<edge, std::pair<node, node> > newEdgesEnds;
 
  115   MutableContainer<std::vector<edge>*> oldContainers;
 
  117   MutableContainer<std::vector<edge>*> newContainers;
 
  120   const GraphStorageIdsMemento* oldIdsState;
 
  122   const GraphStorageIdsMemento* newIdsState;
 
  125   std::list<std::pair<Graph*, Graph*> > addedSubGraphs;
 
  127   std::list<std::pair<Graph*, Graph*> > deletedSubGraphs;
 
  130   TLP_HASH_MAP<Graph*,  std::set<PropertyInterface*> > addedProperties;
 
  132   TLP_HASH_MAP<Graph*,  std::set<PropertyInterface*> > deletedProperties;
 
  134   TLP_HASH_MAP<Graph*, DataSet> oldAttributeValues;
 
  136   TLP_HASH_MAP<Graph*, DataSet> newAttributeValues;
 
  139   TLP_HASH_MAP<PropertyInterface*, std::set<node> > updatedPropsAddedNodes;
 
  142   TLP_HASH_MAP<PropertyInterface*, std::set<edge> > updatedPropsAddedEdges;
 
  145   TLP_HASH_MAP<PropertyInterface*, DataMem*> oldNodeDefaultValues;
 
  147   TLP_HASH_MAP<PropertyInterface*, DataMem*> newNodeDefaultValues;
 
  149   TLP_HASH_MAP<PropertyInterface*, DataMem*> oldEdgeDefaultValues;
 
  151   TLP_HASH_MAP<PropertyInterface*, DataMem*> newEdgeDefaultValues;
 
  153   TLP_HASH_MAP<PropertyInterface*, std::string> renamedProperties;
 
  155   struct RecordedValues {
 
  156     PropertyInterface* values;
 
  157     MutableContainer<bool>* recordedNodes;
 
  158     MutableContainer<bool>* recordedEdges;
 
  160     RecordedValues(PropertyInterface* prop = NULL,
 
  161                    MutableContainer<bool>* rn = NULL,
 
  162                    MutableContainer<bool>* re = NULL):
 
  163       values(prop), recordedNodes(rn), recordedEdges(re) {}
 
  167   TLP_HASH_MAP<PropertyInterface*, RecordedValues> oldValues;
 
  169   TLP_HASH_MAP<PropertyInterface*, RecordedValues> newValues;
 
  174   void deleteDeletedObjects();
 
  176   void deleteValues(TLP_HASH_MAP<PropertyInterface*, RecordedValues>& values);
 
  178   void deleteDefaultValues(TLP_HASH_MAP<PropertyInterface*, DataMem*>& values);
 
  181   void deleteContainerValues(MutableContainer<T>& ctnr) {
 
  182     IteratorValue* it = ctnr.findAllValues(NULL, 
false);
 
  184     while(it->hasNext()) {
 
  185       TypedValueContainer<T> tvc;
 
  193   void recordEdgeContainer(MutableContainer<std::vector<edge>*>&,
 
  196   void removeFromEdgeContainer(MutableContainer<std::vector<edge>*>& containers,
 
  199   void removeGraphData(Graph *);
 
  203   void recordNewValues(GraphImpl*);
 
  204   void recordNewNodeValues(PropertyInterface* p);
 
  205   void recordNewEdgeValues(PropertyInterface* p);
 
  208   void startRecording(GraphImpl*);
 
  211   void stopRecording(Graph*);
 
  213   void restartRecording(Graph*);
 
  215   void doUpdates(GraphImpl*, 
bool undo);
 
  218   bool dontObserveProperty(PropertyInterface *);
 
  220   bool isAddedOrDeletedProperty(Graph*, PropertyInterface *);
 
  223   GraphUpdatesRecorder(
bool allowRestart = 
true);
 
  224   ~GraphUpdatesRecorder();
 
  228   void addNode(Graph* g, 
const node n);
 
  231   void addEdge(Graph* g, 
const edge e);
 
  234   void delNode(Graph* g, 
const node n);
 
  237   void delEdge(Graph* g, 
const edge e);
 
  240   void reverseEdge(Graph* g, 
const edge e);
 
  243   void beforeSetEnds(Graph* g, 
const edge e);
 
  246   void afterSetEnds(Graph* g, 
const edge e);
 
  249   void addSubGraph(Graph* g, Graph* sg);
 
  252   void delSubGraph(Graph* g, Graph* sg);
 
  255   void addLocalProperty(Graph* g, 
const std::string& name);
 
  258   void delLocalProperty(Graph* g, 
const std::string& name);
 
  261   void beforeSetAttribute(Graph* g, 
const std::string& name);
 
  264   void removeAttribute(Graph* g, 
const std::string& name);
 
  268   void beforeSetNodeValue(PropertyInterface* p, 
const node n);
 
  271   void beforeSetAllNodeValue(PropertyInterface* p);
 
  274   void beforeSetEdgeValue(PropertyInterface* p, 
const edge e);
 
  277   void beforeSetAllEdgeValue(PropertyInterface* p);
 
  280   void propertyRenamed(PropertyInterface* p);
 
  284   virtual void treatEvent(
const Event& ev);
 
  289 #endif // TLPGRAPHRECORDER_H 
  290 #endif // DOXYGEN_NOTFOR_DEVEL