![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef TULIP_SUPERGRAPHABSTRACT_H 00022 #define TULIP_SUPERGRAPHABSTRACT_H 00023 00024 #ifndef DOXYGEN_NOTFOR_USER 00025 00026 #include <set> 00027 #include <vector> 00028 #include <tulip/Graph.h> 00029 #include <tulip/DataSet.h> 00030 00031 namespace tlp { 00032 00033 #define GRAPH_SEQ std::vector<Graph *> 00034 00035 template<class C>struct Iterator; 00036 class PropertyManager; 00037 class GraphProperty; 00038 00039 ///Abstract class for default graph operations. 00040 class TLP_SCOPE GraphAbstract:public Graph { 00041 friend class PropertyManager; 00042 protected: 00043 GraphAbstract(Graph *supergraph, unsigned int id); 00044 public: 00045 virtual ~GraphAbstract(); 00046 virtual void clear(); 00047 virtual Graph *addSubGraph(BooleanProperty *selection=NULL, 00048 const std::string& name = "unnamed"); 00049 // used to force the id of the newly created subgraph 00050 // when importing (tlp/tlpjson) 00051 Graph *addSubGraph(unsigned int id, 00052 BooleanProperty *selection=NULL, 00053 const std::string& name = ""); 00054 virtual void delSubGraph(Graph *); 00055 virtual void delAllSubGraphs(Graph *); 00056 virtual Graph* getSuperGraph()const; 00057 virtual Graph* getRoot() const; 00058 virtual Iterator<Graph *>* getSubGraphs() const; 00059 virtual bool isSubGraph(const Graph* sg) const; 00060 virtual bool isDescendantGraph(const Graph* sg) const; 00061 virtual Graph* getSubGraph(unsigned int id) const; 00062 virtual Graph* getSubGraph(const std::string& name) const; 00063 virtual Graph* getDescendantGraph(unsigned int id) const; 00064 virtual Graph* getDescendantGraph(const std::string &name) const; 00065 virtual Graph *getNthSubGraph(unsigned int n) const; 00066 virtual unsigned int numberOfSubGraphs() const; 00067 virtual unsigned int numberOfDescendantGraphs() const; 00068 00069 //======================================= 00070 virtual unsigned int deg(const node) const; 00071 virtual unsigned int indeg(const node) const; 00072 virtual unsigned int outdeg(const node) const; 00073 virtual bool isMetaNode(const node) const; 00074 virtual Graph* getNodeMetaInfo(const node) const; 00075 virtual void delNodes(Iterator<node>* itN, bool deleteInAllGraphs); 00076 virtual node source(const edge) const; 00077 virtual void setSource(const edge, const node); 00078 virtual node target(const edge) const; 00079 virtual void setTarget(const edge, const node); 00080 virtual const std::pair<node, node>& ends(const edge) const; 00081 virtual void setEnds(const edge, const node, const node); 00082 virtual node opposite(const edge, const node)const; 00083 virtual void reverse(const edge); 00084 virtual bool isMetaEdge(const edge) const; 00085 virtual Iterator<edge>* getEdgeMetaInfo(const edge) const; 00086 virtual void delEdges(Iterator<edge>* itE, bool deleteInAllGraphs = false); 00087 //======================================= 00088 virtual node getOneNode() const; 00089 virtual node getInNode(const node,unsigned int ) const; 00090 virtual node getOutNode(const node,unsigned int ) const; 00091 virtual edge getOneEdge() const; 00092 virtual unsigned int numberOfNodes() const; 00093 virtual unsigned int numberOfEdges() const; 00094 //======================================== 00095 bool existProperty(const std::string&) const; 00096 bool existLocalProperty(const std::string&) const; 00097 void delLocalProperty(const std::string&); 00098 void addLocalProperty(const std::string &name, PropertyInterface *prop); 00099 Iterator<std::string>* getLocalProperties() const; 00100 Iterator<std::string>* getInheritedProperties() const; 00101 Iterator<std::string>* getProperties() const; 00102 Iterator<PropertyInterface*>* getLocalObjectProperties() const; 00103 Iterator<PropertyInterface*>* getInheritedObjectProperties() const; 00104 Iterator<PropertyInterface*>* getObjectProperties() const; 00105 PropertyInterface* getProperty(const std::string &) const; 00106 00107 // to get viewMetaGraph property 00108 GraphProperty* getMetaGraphProperty(); 00109 00110 virtual void setName(const std::string &name); 00111 virtual std::string getName() const; 00112 00113 virtual Iterator<node>* bfs(const node root = node()) const; 00114 virtual Iterator<node>* dfs(const node root = node()) const; 00115 00116 protected: 00117 DataSet& getNonConstAttributes(); 00118 void setSuperGraph(Graph *); 00119 PropertyManager *propertyContainer; 00120 const std::set<edge>& getReferencedEdges(const edge) const; 00121 00122 virtual bool renameLocalProperty(PropertyInterface *prop, 00123 const std::string& newName); 00124 00125 // internally used to deal with sub graph deletion 00126 virtual void clearSubGraphs(); 00127 virtual void removeSubGraph(Graph*); 00128 virtual void restoreSubGraph(Graph*); 00129 virtual void setSubGraphToKeep(Graph*); 00130 00131 private: 00132 DataSet attributes; 00133 Graph *supergraph; 00134 Graph* const root; 00135 GRAPH_SEQ subgraphs; 00136 Graph* subGraphToKeep; 00137 // pointer to root viewMetaGraph property 00138 GraphProperty* metaGraphProperty; 00139 // notification of addition/deletion of inherited properties 00140 void notifyBeforeAddInheritedProperty(const std::string& prop); 00141 void notifyAddInheritedProperty(const std::string& prop); 00142 void notifyBeforeDelInheritedProperty(const std::string& prop); 00143 void notifyAfterDelInheritedProperty(const std::string& prop); 00144 // notification of property renaming 00145 void notifyBeforeRenameLocalProperty(PropertyInterface* prop, 00146 const std::string& newName); 00147 void notifyAfterRenameLocalProperty(PropertyInterface* prop, 00148 const std::string& oldName); 00149 }; 00150 00151 } 00152 #endif // DOXYGEN_NOTFOR_USER 00153 00154 #endif 00155 ///@endcond