Tulip  4.10.0
Better Visualization Through Research
GraphProperty.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
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 
20 #ifndef TULIP_METAGRAPH_H
21 #define TULIP_METAGRAPH_H
22 
23 #include <tulip/PropertyTypes.h>
24 #include <tulip/AbstractProperty.h>
25 
26 namespace tlp {
27 
28 class PropertyContext;
29 class GraphAbstract;
30 
31 typedef AbstractProperty<tlp::GraphType, tlp::EdgeSetType> AbstractGraphProperty;
32 
33 /**
34  * @ingroup Graph
35  * @brief A graph property that maps a tlp::Graph* value to graph elements.
36  *
37  * @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.
38  */
39 class TLP_SCOPE GraphProperty : public AbstractGraphProperty {
40  friend class GraphAbstract;
41 
42 public :
43  GraphProperty (Graph *, const std::string& n="");
44  virtual ~GraphProperty();
45  // override Observable::treatEvent
46  void treatEvent(const Event&);
47 
48  // redefinition of some PropertyInterface methods
49  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
50  bool setNodeStringValue(const node n, const std::string & v);
51  bool setAllNodeStringValue(const std::string & v, tlp::Graph *graph = NULL);
52  bool setEdgeStringValue( const edge e, const std::string & v);
53  bool setAllEdgeStringValue(const std::string & v, tlp::Graph *graph = NULL);
54  static const std::string propertyTypename;
55  const std::string& getTypename() const {
56  return propertyTypename;
57  }
58 
59 
60  // redefinition of some AbstractProperty methods
61  virtual void setNodeValue(const node n, const GraphType::RealType& g);
62  virtual void setAllNodeValue(const GraphType::RealType& g, Graph *graph = NULL);
63  virtual bool readNodeDefaultValue(std::istream& iss);
64  virtual bool readNodeValue(std::istream& iss, node n);
65  // tlp::GraphType encapsulates a tlp::Graph pointer but that is the graph id
66  // that gets serialized when using the TLPB format
67  virtual unsigned int nodeValueSize() const {
68  return sizeof(unsigned int);
69  }
70  virtual unsigned int edgeValueSize() const {
71  return 0;
72  }
73 
74  // for optimizations purpose
75  bool hasNonDefaultValue(const node n) const {
76  return nodeProperties.hasNonDefaultValue(n.id);
77  }
78  bool hasNonDefaultValue(const edge e) const {
79  return !edgeProperties.get(e.id).empty();
80  }
81 
82 private:
83  MutableContainer<std::set<node> > referencedGraph;
84  const std::set<edge>& getReferencedEdges(const edge) const;
85 };
86 
87 
88 }
89 #endif
PropertyInterface describes the interface of a graph property.
The edge struct represents an edge in a Graph object.
Definition: Edge.h:39
The node struct represents a node in a Graph object.
Definition: Node.h:39
A graph property that maps a tlp::Graph* value to graph elements.
Definition: GraphProperty.h:39
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:47
unsigned int id
id The identifier of the node.
Definition: Node.h:43
unsigned int id
id The identifier of the edge.
Definition: Edge.h:43