Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
IntegerProperty.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_INT_H
22 #define TULIP_INT_H
23 
24 #include <tulip/tuliphash.h>
25 #include <tulip/PropertyTypes.h>
26 #include <tulip/AbstractProperty.h>
27 #include <tulip/PropertyAlgorithm.h>
28 #include <tulip/Observable.h>
29 #include <tulip/minmaxproperty.h>
30 
31 namespace tlp {
32 
33 class Graph;
34 class PropertyContext;
35 
36 typedef MinMaxProperty<tlp::IntegerType, tlp::IntegerType> IntegerMinMaxProperty;
37 
38 /**
39  * @ingroup Graph
40  * @brief A graph property that maps an integer value to graph elements.
41  */
42 class TLP_SCOPE IntegerProperty : public IntegerMinMaxProperty {
43 
44 public :
45  IntegerProperty(Graph *, std::string n = "");
46 
47  PropertyInterface* clonePrototype(Graph *, const std::string& );
48  static const std::string propertyTypename;
49  std::string getTypename() const {
50  return propertyTypename;
51  }
52  virtual void setNodeValue(const node n, const int &v);
53  virtual void setEdgeValue(const edge e, const int &v);
54  virtual void setAllNodeValue(const int &v);
55  virtual void setAllEdgeValue(const int &v);
56 
57  int compare(const node n1, const node n2) const;
58  int compare(const edge e1, const edge e2) const;
59 
60 protected:
61  virtual void clone_handler(AbstractProperty<tlp::IntegerType, tlp::IntegerType> &);
62 
63 private:
64  // override Observable::treatEvent
65  void treatEvent(const Event&);
66 };
67 
68 /**
69  * @ingroup Graph
70  * @brief A graph property that maps a std::vector<int> value to graph elements.
71  */
72 class TLP_SCOPE IntegerVectorProperty:public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> {
73 public :
74  IntegerVectorProperty(Graph *g, std::string n =""):AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {}
75  // redefinition of some PropertyInterface methods
76  PropertyInterface* clonePrototype(Graph *, const std::string& );
77  static const std::string propertyTypename;
78  std::string getTypename() const {
79  return propertyTypename;
80  }
81 
82 };
83 
84 
85 }
86 #endif
87 ///@endcond