Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GraphAbstract.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef TULIP_SUPERGRAPHABSTRACT_H
22 #define TULIP_SUPERGRAPHABSTRACT_H
23 
24 #ifndef DOXYGEN_NOTFOR_USER
25 
26 #include <set>
27 #include <tulip/Graph.h>
28 #include <tulip/DataSet.h>
29 
30 namespace tlp {
31 
32 #define GRAPH_SEQ std::vector<Graph *>
33 
34 template<class C>struct Iterator;
35 class PropertyManager;
36 class GraphProperty;
37 
38 ///Abstract class for default graph operations.
39 class GraphAbstract:public Graph {
40  friend class PropertyManager;
41 protected:
42  GraphAbstract(Graph *supergraph, unsigned int id);
43 public:
44  virtual ~GraphAbstract();
45  virtual void clear();
46  virtual Graph *addSubGraph(BooleanProperty *selection=0,
47  unsigned int id = 0);
48  virtual void delSubGraph(Graph *);
49  virtual void delAllSubGraphs(Graph *);
50  virtual Graph* getSuperGraph()const;
51  virtual Graph* getRoot() const;
52  virtual Iterator<Graph *>* getSubGraphs() const;
53  virtual bool isSubGraph(const Graph* sg) const;
54  virtual bool isDescendantGraph(const Graph* sg) const;
55  virtual Graph* getSubGraph(unsigned int id) const;
56  virtual Graph* getSubGraph(const std::string &name) const;
57  virtual Graph* getDescendantGraph(unsigned int id) const;
58  virtual Graph* getDescendantGraph(const std::string &name) const;
59  virtual Graph *getNthSubGraph(unsigned int n) const;
60  virtual unsigned int numberOfSubGraphs() const;
61  virtual unsigned int numberOfDescendantGraphs() const;
62 
63  //=======================================
64  virtual unsigned int deg(const node) const;
65  virtual unsigned int indeg(const node) const;
66  virtual unsigned int outdeg(const node) const;
67  virtual bool isMetaNode(const node) const;
68  virtual Graph* getNodeMetaInfo(const node) const;
69  virtual void delNodes(Iterator<node>* itN, bool deleteInAllGraphs);
70  virtual node source(const edge) const;
71  virtual void setSource(const edge, const node);
72  virtual node target(const edge) const;
73  virtual void setTarget(const edge, const node);
74  virtual const std::pair<node, node>& ends(const edge) const;
75  virtual void setEnds(const edge, const node, const node);
76  virtual node opposite(const edge, const node)const;
77  virtual edge existEdge(const node , const node, bool)const;
78  virtual void reverse(const edge);
79  virtual bool isMetaEdge(const edge) const;
80  virtual Iterator<edge>* getEdgeMetaInfo(const edge) const;
81  virtual void delEdges(Iterator<edge>* itE, bool deleteInAllGraphs = false);
82  //=======================================
83  virtual node getOneNode() const;
84  virtual node getInNode(const node,unsigned int ) const;
85  virtual node getOutNode(const node,unsigned int ) const;
86  virtual edge getOneEdge() const;
87  virtual unsigned int numberOfNodes() const;
88  virtual unsigned int numberOfEdges() const;
89  //========================================
90  bool existProperty(const std::string&) const;
91  bool existLocalProperty(const std::string&) const;
92  void delLocalProperty(const std::string&);
93  void addLocalProperty(const std::string &name, PropertyInterface *prop);
94  Iterator<std::string>* getLocalProperties() const;
95  Iterator<std::string>* getInheritedProperties() const;
96  Iterator<std::string>* getProperties() const;
97  Iterator<PropertyInterface*>* getLocalObjectProperties() const;
98  Iterator<PropertyInterface*>* getInheritedObjectProperties() const;
99  Iterator<PropertyInterface*>* getObjectProperties() const;
100  PropertyInterface* getProperty(const std::string &) const;
101 
102  // to get viewMetaGraph property
103  GraphProperty* getMetaGraphProperty();
104 
105  virtual void setName(const std::string &name);
106  virtual std::string getName() const;
107 
108 protected:
109  DataSet& getNonConstAttributes();
110  void setSuperGraph(Graph *);
111  PropertyManager *propertyContainer;
112  const std::set<edge>& getReferencedEdges(const edge) const;
113 
114  // internally used to deal with sub graph deletion
115  virtual void clearSubGraphs();
116  virtual void removeSubGraph(Graph*);
117  virtual void restoreSubGraph(Graph*);
118  virtual void setSubGraphToKeep(Graph*);
119 
120 private:
121  DataSet attributes;
122  Graph *supergraph;
123  Graph* const root;
124  GRAPH_SEQ subgraphs;
125  Graph* subGraphToKeep;
126  // pointer to root viewMetaGraph property
127  GraphProperty* metaGraphProperty;
128  // notification of addition/deletion of inherited properties
129  void notifyBeforeAddInheritedProperty(const std::string& prop);
130  void notifyAddInheritedProperty(const std::string& prop);
131  void notifyBeforeDelInheritedProperty(const std::string& prop);
132  void notifyAfterDelInheritedProperty(const std::string& prop);
133 };
134 
135 }
136 #endif // DOXYGEN_NOTFOR_USER
137 
138 #endif
139 ///@endcond