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 00020 #ifndef TULIP_METAGRAPH_H 00021 #define TULIP_METAGRAPH_H 00022 00023 #include <tulip/PropertyTypes.h> 00024 #include <tulip/AbstractProperty.h> 00025 00026 namespace tlp { 00027 00028 class PropertyContext; 00029 class GraphAbstract; 00030 00031 typedef AbstractProperty<tlp::GraphType, tlp::EdgeSetType> AbstractGraphProperty; 00032 00033 /** 00034 * @ingroup Graph 00035 * @brief A graph property that maps a tlp::Graph* value to graph elements. 00036 * 00037 * @warning This property is mainly used into the meta node engine. Using GraphProperty outside of this system is strongly discouraged since it could lead to unwanted behavior. 00038 */ 00039 class TLP_SCOPE GraphProperty : public AbstractGraphProperty { 00040 friend class GraphAbstract; 00041 00042 public : 00043 GraphProperty (Graph *, const std::string& n=""); 00044 virtual ~GraphProperty(); 00045 // override Observable::treatEvent 00046 void treatEvent(const Event&); 00047 00048 // redefinition of some PropertyInterface methods 00049 PropertyInterface* clonePrototype(Graph *, const std::string& ); 00050 bool setNodeStringValue(const node n, const std::string & v); 00051 bool setAllNodeStringValue(const std::string & v); 00052 bool setEdgeStringValue( const edge e, const std::string & v); 00053 bool setAllEdgeStringValue(const std::string & v); 00054 static const std::string propertyTypename; 00055 const std::string& getTypename() const { 00056 return propertyTypename; 00057 } 00058 00059 00060 // redefinition of some AbstractProperty methods 00061 virtual void setNodeValue(const node n, const GraphType::RealType& g); 00062 virtual void setAllNodeValue(const GraphType::RealType& g); 00063 virtual bool readNodeDefaultValue(std::istream& iss); 00064 virtual bool readNodeValue(std::istream& iss, node n); 00065 virtual unsigned int edgeValueSize() const { 00066 return 0; 00067 } 00068 00069 // for optimizations purpose 00070 bool hasNonDefaultValue(const node n) const { 00071 return nodeProperties.hasNonDefaultValue(n.id); 00072 } 00073 bool hasNonDefaultValue(const edge e) const { 00074 return !edgeProperties.get(e.id).empty(); 00075 } 00076 00077 private: 00078 MutableContainer<std::set<node> > referencedGraph; 00079 const std::set<edge>& getReferencedEdges(const edge) const; 00080 }; 00081 00082 00083 } 00084 #endif