20 #ifndef PROPERTY_INTERFACE_H
21 #define PROPERTY_INTERFACE_H
27 #include <tulip/tulipconf.h>
28 #include <tulip/Observable.h>
30 #include <tulip/Edge.h>
31 #include <tulip/TlpTools.h>
39 template <
class itType>
61 friend class PropertyManager;
78 virtual void erase(
const node) = 0;
84 virtual void erase(
const edge) = 0;
96 bool ifNotDefault =
false) = 0;
107 bool ifNotDefault =
false) = 0;
132 virtual const std::string &getTypename()
const = 0;
139 virtual const std::string &getCppClassName()
const = 0;
144 #define DEFINE_GET_CPP_CLASS_NAME \
145 const std::string &getCppClassName() const override { \
146 static std::string className; \
147 if (className.empty()) { \
148 std::string dcn(demangleClassName(typeid(this).name(), false)); \
149 className = dcn.substr(0, dcn.find(' ')); \
169 bool rename(
const std::string &newName);
203 virtual std::string getNodeStringValue(
const node n)
const = 0;
210 virtual std::string getEdgeStringValue(
const edge e)
const = 0;
219 virtual bool setNodeStringValue(
const node n,
const std::string &value) = 0;
228 virtual bool setEdgeStringValue(
const edge e,
const std::string &value) = 0;
234 virtual std::string getNodeDefaultStringValue()
const = 0;
240 virtual std::string getEdgeDefaultStringValue()
const = 0;
253 virtual bool setNodeDefaultStringValue(
const std::string &value) = 0;
266 virtual bool setAllNodeStringValue(
const std::string &value) = 0;
285 virtual bool setStringValueToGraphNodes(
const std::string &value,
const Graph *graph) = 0;
298 virtual bool setEdgeDefaultStringValue(
const std::string &value) = 0;
311 virtual bool setAllEdgeStringValue(
const std::string &value) = 0;
330 virtual bool setStringValueToGraphEdges(
const std::string &value,
const Graph *graph) = 0;
337 virtual DataMem *getNodeDefaultDataMemValue()
const = 0;
344 virtual DataMem *getEdgeDefaultDataMemValue()
const = 0;
351 virtual void setAllNodeDataMemValue(
const DataMem *value) = 0;
358 virtual void setAllEdgeDataMemValue(
const DataMem *v) = 0;
367 virtual DataMem *getNodeDataMemValue(
const node n)
const = 0;
376 virtual DataMem *getEdgeDataMemValue(
const edge e)
const = 0;
385 virtual DataMem *getNonDefaultDataMemValue(
const node n)
const = 0;
394 virtual DataMem *getNonDefaultDataMemValue(
const edge e)
const = 0;
401 virtual void setNodeDataMemValue(
const node n,
const DataMem *value) = 0;
408 virtual void setEdgeDataMemValue(
const edge e,
const DataMem *v) = 0;
417 virtual tlp::Iterator<node> *getNonDefaultValuatedNodes(
const Graph * =
nullptr)
const = 0;
426 virtual bool hasNonDefaultValuatedNodes(
const Graph * =
nullptr)
const = 0;
435 virtual unsigned int numberOfNonDefaultValuatedNodes(
const Graph * =
nullptr)
const = 0;
444 virtual tlp::Iterator<edge> *getNonDefaultValuatedEdges(
const Graph * =
nullptr)
const = 0;
453 virtual bool hasNonDefaultValuatedEdges(
const Graph * =
nullptr)
const = 0;
460 virtual unsigned int numberOfNonDefaultValuatedEdges(
const Graph * =
nullptr)
const = 0;
467 virtual unsigned int nodeValueSize()
const = 0;
473 virtual void writeNodeDefaultValue(std::ostream &)
const = 0;
479 virtual void writeNodeValue(std::ostream &, node)
const = 0;
485 virtual bool readNodeDefaultValue(std::istream &) = 0;
491 virtual bool readNodeValue(std::istream &, node) = 0;
498 virtual unsigned int edgeValueSize()
const = 0;
504 virtual void writeEdgeDefaultValue(std::ostream &)
const = 0;
510 virtual void writeEdgeValue(std::ostream &, edge)
const = 0;
516 virtual bool readEdgeDefaultValue(std::istream &) = 0;
522 virtual bool readEdgeValue(std::istream &, edge) = 0;
532 virtual void computeMetaValue(node metaNode, Graph *subgraph, Graph *metaGraph) = 0;
540 virtual void computeMetaValue(edge metaEdge,
tlp::Iterator<edge> *it, Graph *metaGraph) = 0;
555 return metaValueCalculator;
566 metaValueCalculator = calculator;
576 virtual int compare(
const node n1,
const node n2)
const = 0;
585 virtual int compare(
const edge e1,
const edge e2)
const = 0;
588 MetaValueCalculator *metaValueCalculator;
591 void notifyBeforeSetNodeValue(
const node n);
592 void notifyAfterSetNodeValue(
const node n);
593 void notifyBeforeSetEdgeValue(
const edge e);
594 void notifyAfterSetEdgeValue(
const edge e);
595 void notifyBeforeSetAllNodeValue();
596 void notifyAfterSetAllNodeValue();
597 void notifyBeforeSetAllEdgeValue();
598 void notifyAfterSetAllEdgeValue();
599 void notifyDestroy();
600 void notifyRename(
const std::string &newName);
626 virtual bool tokenize(
const std::string &str, std::vector<std::string> &vect,
char openChar =
'(',
627 char sepChar =
',',
char closeChar =
')') = 0;
637 virtual bool setNodeStringValueAsVector(
const node n,
const std::vector<std::string> &values) = 0;
647 virtual bool setEdgeStringValueAsVector(
const edge e,
const std::vector<std::string> &values) = 0;
661 virtual bool setNodeStringValueAsVector(
const node n,
const std::string &value,
662 char openChar =
'(',
char sepChar =
',',
663 char closeChar =
')') = 0;
677 virtual bool setEdgeStringValueAsVector(
const edge e,
const std::string &value,
678 char openChar =
'(',
char sepChar =
',',
679 char closeChar =
')') = 0;
692 enum PropertyEventType {
693 TLP_BEFORE_SET_NODE_VALUE = 0,
694 TLP_AFTER_SET_NODE_VALUE,
695 TLP_BEFORE_SET_ALL_NODE_VALUE,
696 TLP_AFTER_SET_ALL_NODE_VALUE,
697 TLP_BEFORE_SET_ALL_EDGE_VALUE,
698 TLP_AFTER_SET_ALL_EDGE_VALUE,
699 TLP_BEFORE_SET_EDGE_VALUE,
700 TLP_AFTER_SET_EDGE_VALUE
703 Event::EventType evtType = Event::TLP_MODIFICATION,
unsigned int id = UINT_MAX)
704 :
Event(prop, evtType), evtType(propEvtType), eltId(
id) {}
710 node getNode()
const {
711 assert(evtType < TLP_BEFORE_SET_ALL_NODE_VALUE);
715 edge getEdge()
const {
716 assert(evtType > TLP_AFTER_SET_ALL_EDGE_VALUE);
720 PropertyEventType getType()
const {
725 PropertyEventType evtType;
738 struct TLP_SCOPE hash<const
tlp::PropertyInterface *> {
744 struct TLP_SCOPE hash<
tlp::PropertyInterface *> {
752 #endif // PROPERTY_INTERFACE_H