20 #ifndef PROPERTY_INTERFACE_H
21 #define PROPERTY_INTERFACE_H
27 #include <tulip/tulipconf.h>
28 #include <tulip/Observable.h>
29 #include <tulip/Edge.h>
30 #include <tulip/TlpTools.h>
38 template <
class itType>
46 enum StandardMetaValueCalculator :
unsigned int {
73 friend class PropertyManager;
108 bool ifNotDefault =
false) = 0;
119 bool ifNotDefault =
false) = 0;
156 #define DEFINE_GET_CPP_CLASS_NAME \
157 const std::string &getCppClassName() const override { \
158 static std::string className; \
159 if (className.empty()) { \
160 std::string dcn(demangleClassName(typeid(this).name(), false)); \
161 className = dcn.substr(0, dcn.find(' ')); \
567 return metaValueCalculator;
578 metaValueCalculator = calculator;
603 void notifyBeforeSetNodeValue(
const node n);
604 void notifyAfterSetNodeValue(
const node n);
605 void notifyBeforeSetEdgeValue(
const edge e);
606 void notifyAfterSetEdgeValue(
const edge e);
607 void notifyBeforeSetAllNodeValue();
608 void notifyAfterSetAllNodeValue();
609 void notifyBeforeSetAllEdgeValue();
610 void notifyAfterSetAllEdgeValue();
611 void notifyDestroy();
612 void notifyRename(
const std::string &newName);
638 virtual bool tokenize(
const std::string &str, std::vector<std::string> &vect,
char openChar =
'(',
639 char sepChar =
',',
char closeChar =
')') = 0;
674 char openChar =
'(',
char sepChar =
',',
675 char closeChar =
')') = 0;
690 char openChar =
'(',
char sepChar =
',',
691 char closeChar =
')') = 0;
704 enum PropertyEventType {
705 TLP_BEFORE_SET_NODE_VALUE = 0,
706 TLP_AFTER_SET_NODE_VALUE,
707 TLP_BEFORE_SET_ALL_NODE_VALUE,
708 TLP_AFTER_SET_ALL_NODE_VALUE,
709 TLP_BEFORE_SET_ALL_EDGE_VALUE,
710 TLP_AFTER_SET_ALL_EDGE_VALUE,
711 TLP_BEFORE_SET_EDGE_VALUE,
712 TLP_AFTER_SET_EDGE_VALUE
715 Event::EventType evtType = Event::TLP_MODIFICATION,
unsigned int id = UINT_MAX)
716 :
Event(prop, evtType), evtType(propEvtType), eltId(
id) {}
722 node getNode()
const {
723 assert(evtType < TLP_BEFORE_SET_ALL_NODE_VALUE);
727 edge getEdge()
const {
728 assert(evtType > TLP_AFTER_SET_ALL_EDGE_VALUE);
732 PropertyEventType getType()
const {
737 PropertyEventType evtType;
750 struct TLP_SCOPE hash<const
tlp::PropertyInterface *> {
756 struct TLP_SCOPE hash<
tlp::PropertyInterface *> {
Event is the base class for all events used in the Observation mechanism.
The Observable class is the base of Tulip's observation system.
Contains additional information about events on a property, such as the property it happened on,...
PropertyInterface describes the interface of a graph property.
virtual void writeEdgeValue(std::ostream &, edge) const =0
Writes the value of an edge.
virtual std::string getNodeStringValue(const node n) const =0
Gets a string representation of the node value.
virtual bool readEdgeValue(std::istream &, edge)=0
Reads the value of an edge.
virtual tlp::Iterator< node > * getNonDefaultValuatedNodes(const Graph *=nullptr) const =0
Gets an Iterator on all non-default valuated nodes. When given a Graph as parameter,...
virtual DataMem * getEdgeDefaultDataMemValue() const =0
Gets a pointer to the tlp::DataMem structure that contains the edge default value.
virtual unsigned int numberOfNonDefaultValuatedNodes(const Graph *=nullptr) const =0
Returns the number of nodes with a non default value. When given a Graph as parameter,...
virtual void writeNodeDefaultValue(std::ostream &) const =0
Writes the nodes default value.
virtual std::string getNodeDefaultStringValue() const =0
Gets a string representation of the node default value.
virtual void setAllEdgeDataMemValue(const DataMem *v)=0
Sets all the edges value to the value contained in the given DataMem structure. All previous values a...
virtual bool setAllEdgeStringValue(const std::string &value)=0
Sets all the edges value to the value represented by the string. For some types, some parsing will be...
const std::string & getName() const
Gets the name of the property (e.g. viewLayout).
MetaValueCalculator * getMetaValueCalculator()
Gets the MetaValueCalculator of this property.
virtual bool setNodeDefaultStringValue(const std::string &value)=0
Sets the value assigned as the default one to the future added nodes from a string representation.
virtual unsigned int edgeValueSize() const =0
Returns the size in bytes of an edge's value.
virtual void writeEdgeDefaultValue(std::ostream &) const =0
Writes the edges default value.
virtual void setAllNodeDataMemValue(const DataMem *value)=0
Sets all the nodes value to the value contained in the given DataMem structure. All previous values a...
virtual bool setStringValueToGraphEdges(const std::string &value, const Graph *graph)=0
Sets all the edges value to the value represented by the string for a graph. For some types,...
virtual bool hasNonDefaultValuatedEdges(const Graph *=nullptr) const =0
Returns whether the property has edges with a non default value. When given a Graph as parameter,...
virtual void setMetaValueCalculator(MetaValueCalculator *calculator)
Sets the Calculator for meta nodes and edges.
virtual void computeMetaValue(node metaNode, Graph *subgraph, Graph *metaGraph)=0
Sets the value of the metanode to a computed value.
virtual DataMem * getEdgeDataMemValue(const edge e) const =0
Gets the edge value, contained in a tlp::DataMem structure.
virtual void erase(const node)=0
Erases the value stored for the given node. The new value for the node is the default value.
virtual void setNodeDataMemValue(const node n, const DataMem *value)=0
Sets the node value.
virtual const std::string & getTypename() const =0
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
virtual DataMem * getNodeDataMemValue(const node n) const =0
Gets the node value, contained in a tlp::DataMem structure.
virtual bool setEdgeDefaultStringValue(const std::string &value)=0
Sets the value assigned as the default one to the future added edges from a string representation.
virtual void writeNodeValue(std::ostream &, node) const =0
Writes the value of a node.
virtual bool setStringValueToGraphNodes(const std::string &value, const Graph *graph)=0
Sets all the nodes value to the value represented by the string for a graph. For some types,...
virtual bool setEdgeStringValue(const edge e, const std::string &value)=0
Sets a new value on the edge, represented by the string parameter.
virtual bool readEdgeDefaultValue(std::istream &)=0
Reads the edges default value.
virtual unsigned int nodeValueSize() const =0
Returns the size in bytes of a node's value.
virtual tlp::Iterator< edge > * getNonDefaultValuatedEdges(const Graph *=nullptr) const =0
Gets an Iterator on all non-default valuated edges. When given a Graph as parameter,...
virtual const std::string & getCppClassName() const =0
Gets a string giving the name of a the PropertyInterface subclass (e.g "tlp::BooleanProperty",...
virtual DataMem * getNonDefaultDataMemValue(const node n) const =0
Returns the value in a DataMem if it is not default, otherwise returns nullptr.
virtual DataMem * getNonDefaultDataMemValue(const edge e) const =0
Returns the value in a DataMem if it is not default, otherwise returns nullptr.
virtual std::string getEdgeDefaultStringValue() const =0
Gets a string representation of the edge default value.
virtual bool readNodeValue(std::istream &, node)=0
Reads the value of a node.
virtual bool copy(const edge destination, const edge source, PropertyInterface *property, bool ifNotDefault=false)=0
Copies the value of an edge in another property to an edge in this property.
virtual unsigned int numberOfNonDefaultValuatedEdges(const Graph *=nullptr) const =0
Returns the number of edges with a non default value.
virtual std::string getEdgeStringValue(const edge e) const =0
Gets a string representation of the edge value.
virtual int compare(const edge e1, const edge e2) const =0
Compares the value this property holds for the two given edges.
virtual PropertyInterface * clonePrototype(Graph *graph, const std::string &name) const =0
Creates a property of the same type (e.g. tlp::DoubleProperty) in the graph. The new property will no...
virtual void setEdgeDataMemValue(const edge e, const DataMem *v)=0
Sets the edge value.
virtual DataMem * getNodeDefaultDataMemValue() const =0
Gets a pointer to the tlp::DataMem structure that contains the node default value.
virtual void computeMetaValue(edge metaEdge, tlp::Iterator< edge > *it, Graph *metaGraph)=0
Sets the value of the metaedge to a computed value.
virtual void copy(PropertyInterface *source)=0
Copies the values of the source property to this property.
virtual void erase(const edge)=0
Erases the value stored for the given edge. The new value for the edge is the default value.
bool rename(const std::string &newName)
Rename a property.
virtual bool setAllNodeStringValue(const std::string &value)=0
Sets all the nodes value to the value represented by the string. For some types, some parsing will be...
virtual bool hasNonDefaultValuatedNodes(const Graph *=nullptr) const =0
Returns whether the property has nodes with a non default value. When given a Graph as parameter,...
virtual bool copy(const node destination, const node source, PropertyInterface *property, bool ifNotDefault=false)=0
Copies the value of a node in another property to a node in this property.
virtual bool setNodeStringValue(const node n, const std::string &value)=0
Sets a new value on the node, represented by the string parameter.
virtual int compare(const node n1, const node n2) const =0
Compares the value this property holds for the two given nodes.
virtual bool readNodeDefaultValue(std::istream &)=0
Reads the nodes default value.
VectorPropertyInterface describes the interface of a graph property whose holded value is a vector (s...
virtual bool setEdgeStringValueAsVector(const edge e, const std::vector< std::string > &values)=0
Sets a new vector represented by the vector of string parameter as the edge value.
virtual bool tokenize(const std::string &str, std::vector< std::string > &vect, char openChar='(', char sepChar=',', char closeChar=')')=0
split an input string into a vector of strings
virtual bool setNodeStringValueAsVector(const node n, const std::string &value, char openChar='(', char sepChar=',', char closeChar=')')=0
Sets a new vector represented by the string parameter as the node value.
virtual bool setNodeStringValueAsVector(const node n, const std::vector< std::string > &values)=0
Sets a new vector represented by the vector of string parameter as the node value.
virtual bool setEdgeStringValueAsVector(const edge e, const std::string &value, char openChar='(', char sepChar=',', char closeChar=')')=0
Sets a new vector represented by the string parameter as the edge value.
Interface for Tulip iterators. Allows basic iteration operations only.
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.