20 #ifndef MINMAXPROPERTY_H
21 #define MINMAXPROPERTY_H
23 #include <tulip/tuliphash.h>
25 #include <tulip/Observable.h>
26 #include <tulip/AbstractProperty.h>
28 #define MINMAX_PAIR(TYPE) std::pair<typename TYPE::RealType, typename TYPE::RealType>
29 #define MINMAX_MAP(TYPE) typename tlp_hash_map<unsigned int, MINMAX_PAIR(TYPE)>
31 #define NODE_VALUE typename nodeType::RealType
32 #define CONST_NODE_VALUE typename tlp::StoredType<typename nodeType::RealType>::ReturnedConstValue
33 #define EDGE_VALUE typename edgeType::RealType
34 #define CONST_EDGE_VALUE typename tlp::StoredType<typename edgeType::RealType>::ReturnedConstValue
45 template <
typename nodeType,
typename edgeType,
typename propType = PropertyInterface>
48 const MINMAX_PAIR(nodeType) & getNodeMinMax(
const Graph *graph =
nullptr);
49 const MINMAX_PAIR(edgeType) & getEdgeMinMax(
const Graph *graph =
nullptr);
63 EDGE_VALUE EdgeMin, EDGE_VALUE EdgeMax);
77 return getNodeMinMax(graph).first;
89 return getNodeMinMax(graph).second;
101 return getEdgeMinMax(graph).first;
113 return getEdgeMinMax(graph).second;
152 MINMAX_MAP(nodeType) minMaxNode;
153 MINMAX_MAP(edgeType) minMaxEdge;
161 bool needGraphListener;
163 const MINMAX_PAIR(nodeType) & computeMinMaxNode(
const Graph *graph);
164 const MINMAX_PAIR(edgeType) & computeMinMaxEdge(
const Graph *graph);
165 void removeListenersAndClearNodeMap();
166 void removeListenersAndClearEdgeMap();
170 #include "cxx/minmaxproperty.cxx"
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
Event is the base class for all events used in the Observation mechanism.
Abstracts the computation of minimal and maximal values on node and edge values of properties.
void updateNodeValue(tlp::node n, CONST_NODE_VALUE newValue)
Updates the value on a node, and updates the minimal/maximal cached values if necessary....
MinMaxProperty(tlp::Graph *graph, const std::string &name, NODE_VALUE NodeMin, NODE_VALUE NodeMax, EDGE_VALUE EdgeMin, EDGE_VALUE EdgeMax)
Constructs a MinMaxProperty.
void updateEdgeValue(tlp::edge e, CONST_EDGE_VALUE newValue)
Updates the value on an edge, and updates the minimal/maximal cached values if necessary....
void updateAllEdgesValues(CONST_EDGE_VALUE newValue)
Updates the value of all edges, setting the maximum and minimum values to this. Should be called by s...
void treatEvent(const tlp::Event &ev) override
This function is called when events are sent to the Listeners, and Listeners only.
CONST_EDGE_VALUE getEdgeMax(const Graph *graph=nullptr)
Computes the maximum value on the edges. It is only computed if it has never been retrieved before,...
void updateAllNodesValues(CONST_NODE_VALUE newValue)
Updates the value of all nodes, setting the maximum and minimum values to this. Should be called by s...
CONST_NODE_VALUE getNodeMin(const Graph *graph=nullptr)
Gets the minimum value on the nodes. It is only computed if it has never been retrieved before,...
CONST_NODE_VALUE getNodeMax(const Graph *graph=nullptr)
Computes the maximum value on the nodes. It is only computed if it has never been retrieved before,...
CONST_EDGE_VALUE getEdgeMin(const Graph *graph=nullptr)
Computes the minimum value on the edges. It is only computed if it has never been retrieved before,...
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.