Tulip  5.1.0
Large graphs analysis and drawing
GraphProperty.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
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 <set>
24 
25 #include <tulip/PropertyTypes.h>
26 #include <tulip/AbstractProperty.h>
27 
28 namespace tlp {
29 
30 class PropertyContext;
31 class GraphAbstract;
32 
33 typedef AbstractProperty<tlp::GraphType, tlp::EdgeSetType> AbstractGraphProperty;
34 
35 /**
36  * @ingroup Graph
37  * @brief A graph property that maps a tlp::Graph* value to graph elements.
38  *
39  * @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.
40  */
41 class TLP_SCOPE GraphProperty : public AbstractGraphProperty {
42  friend class GraphAbstract;
43 
44 public :
45  GraphProperty (Graph *, const std::string& n="");
46  virtual ~GraphProperty();
47  // override Observable::treatEvent
48  void treatEvent(const Event&);
49 
50  // redefinition of some PropertyInterface methods
51  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
52  bool setNodeStringValue(const node n, const std::string & v);
53  bool setAllNodeStringValue(const std::string & v);
54  bool setStringValueToGraphNodes(const std::string & v, const tlp::Graph *graph);
55  bool setEdgeStringValue( const edge e, const std::string & v);
56  bool setAllEdgeStringValue(const std::string & v);
57  bool setStringValueToGraphEdges(const std::string & v, const tlp::Graph *graph);
58  static const std::string propertyTypename;
59  const std::string& getTypename() const {
60  return propertyTypename;
61  }
62 
63 
64  // redefinition of some AbstractProperty methods
65  virtual void setNodeValue(const node n, tlp::StoredType<GraphType::RealType>::ReturnedConstValue g);
66  virtual void setAllNodeValue(tlp::StoredType<GraphType::RealType>::ReturnedConstValue g);
67  virtual void setValueToGraphNodes(tlp::StoredType<GraphType::RealType>::ReturnedConstValue g, const Graph *graph);
68  virtual bool readNodeDefaultValue(std::istream& iss);
69  virtual bool readNodeValue(std::istream& iss, node n);
70  // tlp::GraphType encapsulates a tlp::Graph pointer but that is the graph id
71  // that gets serialized when using the TLPB format
72  virtual unsigned int nodeValueSize() const {
73  return sizeof(unsigned int);
74  }
75  virtual unsigned int edgeValueSize() const {
76  return 0;
77  }
78 
79  // for optimizations purpose
80  bool hasNonDefaultValue(const node n) const {
81  return nodeProperties.hasNonDefaultValue(n.id);
82  }
83  bool hasNonDefaultValue(const edge e) const {
84  return !edgeProperties.get(e.id).empty();
85  }
86 
87 private:
88  MutableContainer<std::set<node> > referencedGraph;
89  const std::set<edge>& getReferencedEdges(const edge) const;
90 };
91 
92 
93 }
94 #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:41
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