Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
tlp::AbstractProperty< Tnode, Tedge > Class Template Reference

#include <AbstractProperty.h>

Inherits tlp::PropertyInterface.

Inherited by tlp::ColorProperty, tlp::GraphProperty, tlp::SizeProperty, and tlp::StringProperty.

Classes

class  MetaValueCalculator
 This class is used to delegate the computation of the values associated to meta nodes or edges. More...
 

Public Member Functions

 AbstractProperty (Graph *, std::string n="")
 
int compare (const node n1, const node n2) const
 
int compare (const edge e1, const edge e2) const
 
virtual void computeMetaValue (node n, Graph *sg, Graph *mg)
 
virtual void computeMetaValue (edge e, tlp::Iterator< edge > *itE, Graph *mg)
 
virtual bool copy (const node destination, const node source, PropertyInterface *property, bool ifNotDefault=false)
 
virtual bool copy (const edge destination, const edge source, PropertyInterface *property, bool ifNotDefault=false)
 
virtual void copy (PropertyInterface *property)
 
virtual void erase (const node n)
 
virtual void erase (const edge e)
 
virtual DataMem * getEdgeDataMemValue (const edge e) const
 
virtual DataMem * getEdgeDefaultDataMemValue () const
 
virtual std::string getEdgeDefaultStringValue () const
 
Tedge::RealType getEdgeDefaultValue () const
 
virtual std::string getEdgeStringValue (const edge e) const
 
tlp::StoredType< typename
Tedge::RealType >
::ReturnedConstValue 
getEdgeValue (const edge e) const
 
virtual DataMem * getNodeDataMemValue (const node n) const
 
virtual DataMem * getNodeDefaultDataMemValue () const
 
virtual std::string getNodeDefaultStringValue () const
 
Tnode::RealType getNodeDefaultValue () const
 
virtual std::string getNodeStringValue (const node n) const
 
tlp::StoredType< typename
Tnode::RealType >
::ReturnedConstValue 
getNodeValue (const node n) const
 
virtual DataMem * getNonDefaultDataMemValue (const node n) const
 
virtual DataMem * getNonDefaultDataMemValue (const edge e) const
 
virtual tlp::Iterator< edge > * getNonDefaultValuatedEdges (const Graph *g=NULL) const
 
virtual tlp::Iterator< node > * getNonDefaultValuatedNodes (const Graph *g=NULL) const
 
virtual AbstractProperty
< Tnode, Tedge > & 
operator= (AbstractProperty< Tnode, Tedge > &prop)
 
virtual void setAllEdgeDataMemValue (const DataMem *v)
 
virtual bool setAllEdgeStringValue (const std::string &inV)
 
virtual void setAllEdgeValue (const typename Tedge::RealType &v)
 
virtual void setAllNodeDataMemValue (const DataMem *v)
 
virtual bool setAllNodeStringValue (const std::string &inV)
 
virtual void setAllNodeValue (const typename Tnode::RealType &v)
 
virtual void setEdgeDataMemValue (const edge e, const DataMem *v)
 
virtual bool setEdgeStringValue (const edge inE, const std::string &inV)
 
virtual void setEdgeValue (const edge e, const typename Tedge::RealType &v)
 
virtual void setMetaValueCalculator (PropertyInterface::MetaValueCalculator *mvCalc)
 
virtual void setNodeDataMemValue (const node n, const DataMem *v)
 
virtual bool setNodeStringValue (const node inN, const std::string &inV)
 
virtual void setNodeValue (const node n, const typename Tnode::RealType &v)
 
- Public Member Functions inherited from tlp::PropertyInterface
void addPropertyObserver (Observable *pObs)
 
virtual PropertyInterfaceclonePrototype (Graph *graph, const std::string &name)=0
 
tlp::GraphgetGraph () const
 
MetaValueCalculatorgetMetaValueCalculator ()
 
const std::string & getName () const
 
virtual std::string getTypename () const =0
 
void removePropertyObserver (Observable *pObs)
 
- Public Member Functions inherited from tlp::Observable
void addListener (Observable *const listener) const
 
void addObserver (Observable *const observer) const
 
unsigned int countListeners () const
 
unsigned int countObservers () const
 
unsigned int getReceived () const
 
unsigned int getSent () const
 
void removeListener (Observable *const listener) const
 
void removeObserver (Observable *const observerver) const
 

Protected Member Functions

virtual void clone_handler (AbstractProperty< Tnode, Tedge > &)
 
- Protected Member Functions inherited from tlp::PropertyInterface
void notifyAfterSetAllEdgeValue ()
 
void notifyAfterSetAllNodeValue ()
 
void notifyAfterSetEdgeValue (const edge e)
 
void notifyAfterSetNodeValue (const node n)
 
void notifyBeforeSetAllEdgeValue ()
 
void notifyBeforeSetAllNodeValue ()
 
void notifyBeforeSetEdgeValue (const edge e)
 
void notifyBeforeSetNodeValue (const node n)
 
void notifyDestroy ()
 
- Protected Member Functions inherited from tlp::Observable
 Observable (const Observable &)
 
tlp::Iterator< tlp::Observable * > * getObservables () const
 
bool hasOnlookers () const
 
void notifyObservers ()
 
void observableDeleted ()
 
Observableoperator= (const Observable &)
 
void sendEvent (const Event &message)
 
virtual void treatEvent (const Event &message)
 
virtual void treatEvents (const std::vector< Event > &events)
 

Protected Attributes

Tedge::RealType edgeDefaultValue
 
MutableContainer< typename
Tedge::RealType > 
edgeProperties
 
Tnode::RealType nodeDefaultValue
 
MutableContainer< typename
Tnode::RealType > 
nodeProperties
 
- Protected Attributes inherited from tlp::PropertyInterface
Graphgraph
 
MetaValueCalculatormetaValueCalculator
 
std::string name
 

Friends

class Graph
 
class GraphView
 

Additional Inherited Members

- Static Public Member Functions inherited from tlp::Observable
static ObservablegetObject (tlp::node n)
 
static const tlp::VectorGraph & getObservableGraph ()
 
static void holdObservers ()
 
static bool isAlive (tlp::node n)
 
static unsigned int observersHoldCounter ()
 
static void unholdObservers ()
 

Detailed Description

template<class Tnode, class Tedge>
class tlp::AbstractProperty< Tnode, Tedge >

This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edge values, through the magic of template programming.

Nodes and Edges can have different types (e.g. tlp::LayoutProperty has tlp::PointType as node type and tlp::LineType as edge type), but most of the time they have the same type (e.g. tlp::DoubleProperty, tlp::IntegerProperty).

Some of the pure virtual functions of PropertyInterface are implemented in this class (e.g. erase()).

The actual data is stored in this class, and it manages the default values.

Definition at line 54 of file AbstractProperty.h.

Member Function Documentation

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::clone_handler ( AbstractProperty< Tnode, Tedge > &  )
inlineprotectedvirtual

Enable to clone part of sub_class.

Definition at line 401 of file AbstractProperty.h.

template<class Tnode , class Tedge >
int tlp::AbstractProperty< Tnode, Tedge >::compare ( const node  n1,
const node  n2 
) const
virtual

Compares the value this property holds for the two given nodes.

Parameters
n1The first node to compare the value of.
n2The second node to compare the value of.
Returns
0 if the values are identical, a positive value if n1 is greater than n2, and a negative value if n1 is less than n2.

Implements tlp::PropertyInterface.

Reimplemented in tlp::SizeProperty, tlp::StringProperty, and tlp::ColorProperty.

Definition at line 88 of file AbstractProperty.cxx.

template<class Tnode , class Tedge >
int tlp::AbstractProperty< Tnode, Tedge >::compare ( const edge  e1,
const edge  e2 
) const
virtual

Compares the value this property holds for the two given edges.

Parameters
e1The first edge to compare the value of.
e2The second edge to compare the value of.
Returns
0 if the values are identical, a positive value if e1 is greater than e2, and a negative value if e1 is less than e2.

Implements tlp::PropertyInterface.

Reimplemented in tlp::StringProperty, and tlp::ColorProperty.

Definition at line 95 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::computeMetaValue ( node  metaNode,
Graph subgraph,
Graph metaGraph 
)
inlinevirtual

Sets the value of the metanode to a computed value.

The value is computed by this property's MetaValueCalculator.

Parameters
metaNodeThe metanode to compute a value on.
subgraphThe subgraph pointed by the metanode.
metaGraphThe graph who owns the meta node.

Implements tlp::PropertyInterface.

Definition at line 354 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::computeMetaValue ( edge  metaEdge,
tlp::Iterator< edge > *  it,
Graph metaGraph 
)
inlinevirtual

Sets the value of the metaedge to a computed value.

Parameters
metaEdgeThe meta edge to compute a value on.
itThe edges represented by the meta edge.
metaGraphThe graph who owns the meta edge.

Implements tlp::PropertyInterface.

Definition at line 361 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual bool tlp::AbstractProperty< Tnode, Tedge >::copy ( const node  destination,
const node  source,
PropertyInterface property,
bool  ifNotDefault = false 
)
inlinevirtual

Copies the value of a node in another property to a node in this property.

Parameters
destinationThe node whose value will be set.
sourceThe node whose value to copy.
propertyThe property from which to copy the source node value.
ifNotDefaultIf true, the copy will only be performed if the source node's value is not the default value.
Returns
True if the copy was performed, false otherwise.

Implements tlp::PropertyInterface.

Definition at line 265 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual bool tlp::AbstractProperty< Tnode, Tedge >::copy ( const edge  destination,
const edge  source,
PropertyInterface property,
bool  ifNotDefault = false 
)
inlinevirtual

Copies the value of an edge in another property to an edge in this property.

Parameters
destinationThe edge whose value will be set.
sourceThe edge whose value to copy.
propertyThe property from which to copy the source edge value.
ifNotDefaultIf true, the copy will only be performed if the source edge's value is not the default value.
Returns
True if the copy was performed, false otherwise.

Implements tlp::PropertyInterface.

Definition at line 283 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::copy ( PropertyInterface source)
inlinevirtual

Copies the values of the passed property to this property.

Parameters
sourceThe property from which to copy values.

Implements tlp::PropertyInterface.

Definition at line 301 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::erase ( const node  n)
inlinevirtual

Resets the value of a node to the default value.

Parameters
nThe node to reset the value of.

Implements tlp::PropertyInterface.

Definition at line 130 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::erase ( const edge  e)
inlinevirtual

Resets the value of an edge to the default value.

Parameters
eThe edge to reset the value of.

Implements tlp::PropertyInterface.

Definition at line 141 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual DataMem* tlp::AbstractProperty< Tnode, Tedge >::getEdgeDataMemValue ( const edge  e) const
inlinevirtual

Gets the edge value, contained in a tlp::DataMem structure.

Parameters
nThe edge to get the value of.
Returns
The value of the edge, in a tlp::DataMem.
Warning
The ownership of this pointer is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 317 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual DataMem* tlp::AbstractProperty< Tnode, Tedge >::getEdgeDefaultDataMemValue ( ) const
inlinevirtual

Gets a pointer to the tlp::DataMem structure that contains the edge default value.

Returns
The DataMem structure containing the edge default value.
Warning
The ownership of this pointer is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 311 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual std::string tlp::AbstractProperty< Tnode, Tedge >::getEdgeDefaultStringValue ( ) const
inlinevirtual

Gets a string representation of the edge default value.

Returns
A string representation of the edge default value.

Implements tlp::PropertyInterface.

Definition at line 215 of file AbstractProperty.h.

template<class Tnode , class Tedge >
Tedge::RealType tlp::AbstractProperty< Tnode, Tedge >::getEdgeDefaultValue ( ) const

Gets the default edge value of the property.

Returns
The default value of edges.

Definition at line 39 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual std::string tlp::AbstractProperty< Tnode, Tedge >::getEdgeStringValue ( const edge  e) const
inlinevirtual

Gets a string representation of the edge default value.

Parameters
eThe edge to get the value of.
Returns
A string representation of the edge default value.

Implements tlp::PropertyInterface.

Definition at line 223 of file AbstractProperty.h.

template<class Tnode , class Tedge >
tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue tlp::AbstractProperty< Tnode, Tedge >::getEdgeValue ( const edge  e) const

Returns the value associated to the edge e in this property. If there is no value, it returns the default edge value.

Parameters
eThe edge for which we want to get the value of the property.
Returns
:StoredType< Tedge::RealType >::ReturnedConstValue The value of the property for this edge.

Definition at line 50 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual DataMem* tlp::AbstractProperty< Tnode, Tedge >::getNodeDataMemValue ( const node  n) const
inlinevirtual

Gets the node value, contained in a tlp::DataMem structure.

Parameters
nThe node to get the value of.
Returns
The value of the node, in a tlp::DataMem.
Warning
The ownership of this pointer is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 314 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual DataMem* tlp::AbstractProperty< Tnode, Tedge >::getNodeDefaultDataMemValue ( ) const
inlinevirtual

Gets a pointer to the tlp::DataMem structure that contains the node default value.

Returns
The DataMem structure containing the node default value.
Warning
The ownership of this pointer is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 308 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual std::string tlp::AbstractProperty< Tnode, Tedge >::getNodeDefaultStringValue ( ) const
inlinevirtual

Gets a string representation of the node default value.

Returns
A string representation of the node default value.

Implements tlp::PropertyInterface.

Definition at line 211 of file AbstractProperty.h.

template<class Tnode , class Tedge >
Tnode::RealType tlp::AbstractProperty< Tnode, Tedge >::getNodeDefaultValue ( ) const

Gets the default node value of the property.

Returns
The default value of nodes.

Definition at line 34 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual std::string tlp::AbstractProperty< Tnode, Tedge >::getNodeStringValue ( const node  n) const
inlinevirtual

Gets a string representation of the node default value.

Parameters
nThe node to get the value of.
Returns
A string representation of the node default value.

Implements tlp::PropertyInterface.

Definition at line 219 of file AbstractProperty.h.

template<class Tnode , class Tedge >
tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue tlp::AbstractProperty< Tnode, Tedge >::getNodeValue ( const node  n) const

Returns the value associated with the node n in this property. If there is no value, it returns the default node value.

Parameters
nThe node for which we want to get the value of the property.
Returns
:StoredType< Tnode::RealType >::ReturnedConstValue The value of the property for this node.

Definition at line 44 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual DataMem* tlp::AbstractProperty< Tnode, Tedge >::getNonDefaultDataMemValue ( const node  n) const
inlinevirtual

Returns the value in a DataMem if it is not default, otherwise returns NULL.

Parameters
nThe node to get the value of.
Returns
The value of the node if it is not default, or NULL.
Warning
The ownership of this pointer is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 320 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual DataMem* tlp::AbstractProperty< Tnode, Tedge >::getNonDefaultDataMemValue ( const edge  e) const
inlinevirtual

Returns the value in a DataMem if it is not default, otherwise returns NULL.

Parameters
eThe edge to get the value of.
Returns
The value of the edge if it is not default, or NULL.
Warning
The ownership of this pointer is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 329 of file AbstractProperty.h.

template<class Tnode , class Tedge >
tlp::Iterator< tlp::edge > * tlp::AbstractProperty< Tnode, Tedge >::getNonDefaultValuatedEdges ( const Graph = NULL) const
virtual

Gets an Iterator on all non-default valuated edges. When given a Graph as parameter, only edges belonging to this graph are iterated over.

Returns
An Iterator over edges whose value is not default.
Warning
The ownership of the iterator is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 158 of file AbstractProperty.cxx.

template<class Tnode , class Tedge >
tlp::Iterator< tlp::node > * tlp::AbstractProperty< Tnode, Tedge >::getNonDefaultValuatedNodes ( const Graph = NULL) const
virtual

Gets an Iterator on all non-default valuated nodes. When given a Graph as parameter, only nodes belonging to this graph are iterated over.

Returns
An Iterator over nodes whose value is not default.
Warning
The ownership of the iterator is given to the caller.

Implements tlp::PropertyInterface.

Definition at line 144 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual AbstractProperty<Tnode,Tedge>& tlp::AbstractProperty< Tnode, Tedge >::operator= ( AbstractProperty< Tnode, Tedge > &  prop)
inlinevirtual

This operator overload allows to copy a property using the following syntax :

IntegerProperty* shape = graph->getProperty<IntegerProperty>("viewShape");
IntegerProperty* backup = graph->getProperty<IntegerProperty>("shapeBackup");
*backup = *shape; // all the values from 'shape' will be copied into 'backup'.
Parameters
propThe property nto copy the values from.
Returns
This property with the values copied.

Definition at line 156 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::setAllEdgeDataMemValue ( const DataMem *  v)
inlinevirtual

Sets all the edges value to the value contained in the given DataMem structure. All previous values are lost.

Parameters
valueThe value to set on all the edges.

Implements tlp::PropertyInterface.

Definition at line 347 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual bool tlp::AbstractProperty< Tnode, Tedge >::setAllEdgeStringValue ( const std::string &  value)
inlinevirtual

Sets all the edges value to the value described by the string. For some types, some parsing will be necessary (e.g. LayoutPorperty). All previous values are lost.

Parameters
valueA string describing the new value to set on all the edges.
Returns
Whether the given string was a correct representation for this property's type. If not, the values are not set.

Implements tlp::PropertyInterface.

Reimplemented in tlp::GraphProperty.

Definition at line 254 of file AbstractProperty.h.

template<class Tnode , class Tedge>
void tlp::AbstractProperty< Tnode, Tedge >::setAllEdgeValue ( const typename Tedge::RealType &  v)
virtual

Sets the value of all edges and notify the observers.

Parameters
vThe value to set to all edges.

Definition at line 80 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::setAllNodeDataMemValue ( const DataMem *  value)
inlinevirtual

Sets all the nodes value to the value contained in the given DataMem structure. All previous values are lost.

Parameters
valueThe value to set on all the nodes.

Implements tlp::PropertyInterface.

Definition at line 344 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual bool tlp::AbstractProperty< Tnode, Tedge >::setAllNodeStringValue ( const std::string &  value)
inlinevirtual

Sets all the nodes value to the value described by the string. For some types, some parsing will be necessary (e.g. LayoutPorperty). All previous values are lost.

Parameters
valueA string describing the new value to set on all the nodes.
Returns
Whether the given string was a correct representation for this property's type. If not, the values are not set.

Implements tlp::PropertyInterface.

Reimplemented in tlp::GraphProperty.

Definition at line 245 of file AbstractProperty.h.

template<class Tnode, class Tedge >
void tlp::AbstractProperty< Tnode, Tedge >::setAllNodeValue ( const typename Tnode::RealType &  v)
virtual

Sets the value of all nodes and notify the observers.

Parameters
vThe value to set to all nodes.

Definition at line 72 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::setEdgeDataMemValue ( const edge  e,
const DataMem *  v 
)
inlinevirtual

Sets the edge value.

Parameters
eThe edge to set the value of.
valueThe value to set to this edge.

Implements tlp::PropertyInterface.

Definition at line 341 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual bool tlp::AbstractProperty< Tnode, Tedge >::setEdgeStringValue ( const edge  e,
const std::string &  value 
)
inlinevirtual

Sets a new value on the edge, described by the string parameter.

Parameters
eThe edge on which to set value on.
valueA string describing the value to set on the edge.
Returns
Whether the string was a correct representation for this property's type. If not, the value is not set.

Implements tlp::PropertyInterface.

Reimplemented in tlp::GraphProperty.

Definition at line 236 of file AbstractProperty.h.

template<class Tnode , class Tedge>
void tlp::AbstractProperty< Tnode, Tedge >::setEdgeValue ( const edge  e,
const typename Tedge::RealType &  v 
)
virtual

Set the value of an edge and notify the observers of a modification.

Parameters
eThe edge to set the value of.
vThe value to affect for this edge.

Definition at line 64 of file AbstractProperty.cxx.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::setMetaValueCalculator ( PropertyInterface::MetaValueCalculator calculator)
inlinevirtual

Sets the Calculator for meta nodes and edges.

Parameters
calculatorThe object containing the logic for computing the meta values for the nodes and edges.
Warning
The ownership of the MetaValueCalculator is not taken by the property.

Reimplemented from tlp::PropertyInterface.

Reimplemented in tlp::DoubleProperty.

Definition at line 365 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual void tlp::AbstractProperty< Tnode, Tedge >::setNodeDataMemValue ( const node  n,
const DataMem *  value 
)
inlinevirtual

Sets the node value.

Parameters
nThe node to set the value of.
valueThe value to set to this node.

Implements tlp::PropertyInterface.

Definition at line 338 of file AbstractProperty.h.

template<class Tnode, class Tedge>
virtual bool tlp::AbstractProperty< Tnode, Tedge >::setNodeStringValue ( const node  n,
const std::string &  value 
)
inlinevirtual

Sets a new value on the node, described by the string parameter.

Parameters
nThe node on which to set the new value.
valueA string describing the value to set on the node.
Returns
Whether the string was a correct representation for this property's type. If not, the value is not set.

Implements tlp::PropertyInterface.

Reimplemented in tlp::GraphProperty.

Definition at line 227 of file AbstractProperty.h.

template<class Tnode, class Tedge >
void tlp::AbstractProperty< Tnode, Tedge >::setNodeValue ( const node  n,
const typename Tnode::RealType &  v 
)
virtual

Sets the value of a node and notify the observers of a modification.

Parameters
nThe node to set the value of.
vThe value to affect for this node.

Definition at line 56 of file AbstractProperty.cxx.