File: PropertyInterface.sip

package info (click to toggle)
tulip 4.8.0dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 179,264 kB
  • ctags: 64,517
  • sloc: cpp: 600,444; ansic: 36,311; makefile: 22,136; python: 1,304; sh: 946; yacc: 522; xml: 337; pascal: 157; php: 66; lex: 55
file content (403 lines) | stat: -rw-r--r-- 13,939 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/**
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 */

// +-------------------------------------------------------------------------+
// | Tulip Python Bindings                                                   |
// | inspired from bindings by the Booggie project development team          |
// | (http://booggie.org/)                                                   |
// +-------------------------------------------------------------------------+

namespace tlp {

class PropertyInterface : tlp::Observable /Abstract/ {
%TypeHeaderCode
#include <tulip/PropertyInterface.h>
%End

%ConvertToSubClassCode
    if (dynamic_cast<tlp::BooleanProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::BooleanProperty");
    } else if (dynamic_cast<tlp::ColorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::ColorProperty");
    } else if (dynamic_cast<tlp::DoubleProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::DoubleProperty");
    } else if (dynamic_cast<tlp::GraphProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::GraphProperty");
    } else if (dynamic_cast<tlp::IntegerProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::IntegerProperty");
    } else if (dynamic_cast<tlp::LayoutProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::LayoutProperty");
    } else if (dynamic_cast<tlp::SizeProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::SizeProperty");
    } else if (dynamic_cast<tlp::StringProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::StringProperty");
    } else if (dynamic_cast<tlp::BooleanVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::BooleanVectorProperty");
    } else if (dynamic_cast<tlp::ColorVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::ColorVectorProperty");
    } else if (dynamic_cast<tlp::DoubleVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::DoubleVectorProperty");
    } else if (dynamic_cast<tlp::IntegerVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::IntegerVectorProperty");
    } else if (dynamic_cast<tlp::CoordVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::CoordVectorProperty");
    } else if (dynamic_cast<tlp::SizeVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::SizeVectorProperty");
    } else if (dynamic_cast<tlp::StringVectorProperty *>(sipCpp)) {
        sipType = sipFindType("tlp::StringVectorProperty");
    } else {
        sipType = NULL;
    }
%End

public:
 
 	tlp::Graph * getGraph();
%Docstring
tlp.PropertyInterface.getGraph()

Returns the graph on which the property has been defined.

:rtype: :class:`tlp.Graph`

.. warning:: If the property is inherited the graph could be different
             that the one used to get that property.
%End  

 //===========================================================================================

   virtual unsigned int numberOfNonDefaultValuatedNodes(const tlp::Graph* subgraph= NULL) const = 0;
 %Docstring
 tlp.PropertyInterface.numberOfNonDefaultValuatedNodes([subgraph = None])

.. versionadded:: 4.8

 Returns the number of nodes whose value is different
 from the default value.

 :param subgraph: a sub-graph can be given in parameter. In that case, only the number of nodes in this sub-graph whose value is different from the default one is returned.
 :type subgraph: :class:`tlp.Graph`
 :rtype: integer
 %End

//===========================================================================================

	virtual tlp::Iterator<tlp::node>* getNonDefaultValuatedNodes(const tlp::Graph* subgraph= NULL) const = 0;
%Docstring
tlp.PropertyInterface.getNonDefaultValuatedNodes([subgraph = None])

Returns an iterator on all nodes whose value is different
from the default value. 

:param subgraph: a sub-graph can be given in parameter. In that case, only the nodes owned by this sub-graph are returned by the iterator.
:type subgraph: :class:`tlp.Graph`
:rtype: :class:`tlp.IteratorNode`
%End	

 //===========================================================================================

   virtual unsigned int numberOfNonDefaultValuatedEdges(const tlp::Graph* subgraph= NULL) const = 0;
 %Docstring
 tlp.PropertyInterface.numberOfNonDefaultValuatedEdges([subgraph = None])

.. versionadded:: 4.8

 Returns the number of edges whose value is different
 from the default value.

 :param subgraph: a sub-graph can be given in parameter. In that case, only the number of edges in this sub-graph whose value is different from the default one is returned.
 :type subgraph: :class:`tlp.Graph`
 :rtype: integer
 %End

//===========================================================================================
	
	virtual tlp::Iterator<tlp::edge>* getNonDefaultValuatedEdges(const tlp::Graph* subgraph= NULL) const = 0;
%Docstring
tlp.PropertyInterface.getNonDefaultValuatedEdges([subgraph = None])

Returns an iterator on all edges whose value is different
from the default value. 

:param subgraph: a sub-graph can be given in parameter. In that case, only the edges owned by this sub-graph are returned by the iterator.
:type subgraph: :class:`tlp.Graph`
:rtype: :class:`tlp.IteratorEdge`
%End	
	
//===========================================================================================	
	
	virtual const std::string& getTypename() const = 0;
%Docstring
tlp.PropertyInterface.getTypename()

Returns a string describing the type of the property,
i.e. "graph", "double", "layout", "string", "integer", "color", "size", ...

:rtype: string
%End

//===========================================================================================

	const std::string& getName() const = 0;
%Docstring
tlp.PropertyInterface.getName()

Returns the name of the property.

:rtype: string
%End

//===========================================================================================

	virtual std::string getNodeDefaultStringValue() const = 0;
%Docstring
tlp.PropertyInterface.getNodeDefaultStringValue()

Returns a string representation of the node default value.

:rtype: string
%End
	
//===========================================================================================	
	
	virtual std::string getEdgeDefaultStringValue() const = 0;
%Docstring
tlp.PropertyInterface.getEdgeDefaultStringValue()

Returns a string representation of the edge default value.

:rtype: string
%End	
//===========================================================================================	
	
	virtual bool setAllNodeStringValue( const std::string & strVal ) = 0;
%Docstring
tlp.PropertyInterface.setAllNodeStringValue(str)

Clears all nodes registered values, and sets a new node default value
in converting the given string representation of a value.
Returns :const:`True` if the given string representation has been successfully converted to a value, :const:`False` otherwise.

:param str: a string representation of a value
:type str: string
:rtype: boolean
%End
	
//===========================================================================================	
	
	virtual bool setAllEdgeStringValue( const std::string & strVal ) = 0;
%Docstring
tlp.PropertyInterface.setAllEdgeStringValue(str)

Clears all edges registered values, and sets a new edge default value
in converting the given string representation of a value.
Returns :const:`True` if the given string representation has been successfully converted to a value, :const:`False` otherwise.

:param str: a string representation of a value
:type str: string
:rtype: boolean
%End
//===========================================================================================

	virtual void erase(const tlp::node node) = 0;
%Docstring
tlp.PropertyInterface.erase(node)

Removes the value stored for the node given in parameter.
The new value for the node is the default one.

:param node: an existing node
:type node: :class:`tlp.node`
:throws: an exception if the node does not belong to the graph attached to the property
%End	
	
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipCpp->erase(*a0);
	} else {
		sipIsErr = throwInvalidNodeException(sipCpp->getGraph(), *a0);
	}
%End	
	
//===========================================================================================	
	
	virtual void erase(const tlp::edge edge) = 0;
%Docstring
tlp.PropertyInterface.erase(edge)

Removes the value stored for the edge given in parameter.
The new value for the edge is the default one.

:param edge: an existing edge
:type edge: :class:`tlp.edge`
:throws: an exception if the edge does not belong to the graph attached to the property
%End	
	
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipCpp->erase(*a0);
	} else {
		sipIsErr = throwInvalidEdgeException(sipCpp->getGraph(), *a0);
	}
%End

//===========================================================================================

    virtual std::string getNodeStringValue( const tlp::node node )  = 0;
%Docstring
tlp.PropertyInterface.getNodeStringValue(node)

Returns a string conversion of the value registered for the given node.

:param node: an existing node
:type node: :class:`tlp.node`
:rtype: string
:throws: an exception if the node does not belong to the graph attached to the property
%End	
	
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipRes = new std::string(sipCpp->getNodeStringValue(*a0));
	} else {
		sipIsErr = throwInvalidNodeException(sipCpp->getGraph(), *a0);
	}
%End	
	
//===========================================================================================	
	
    virtual std::string getEdgeStringValue( const tlp::edge edge )  = 0;
%Docstring
tlp.PropertyInterface.getEdgeStringValue(edge)

Returns a string conversion of the value registered for the given edge.

:param edge: an existing edge
:type edge: :class:`tlp.edge`
:rtype: string
:throws: an exception if the edge does not belong to the graph attached to the property
%End	
	
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipRes = new std::string(sipCpp->getEdgeStringValue(*a0));
	} else {
		sipIsErr = throwInvalidEdgeException(sipCpp->getGraph(), *a0);
	}
%End
	
//===========================================================================================	
	
	virtual bool setNodeStringValue( const tlp::node node, const std::string & strVal ) = 0;
%Docstring
tlp.PropertyInterface.setNodeStringValue(node, str)

Registers a new value for the given node in converting
the given string representation.
Returns :const:`True` if the given string representation has been successfully converted to a value, :const:`False` otherwise.

:param node: an existing node
:type node: :class:`tlp.node`
:param str: a string representation of a value
:type str: string
:rtype: boolean
:throws: an exception if the node does not belong to the graph attached to the property
%End	
	
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipCpp->setNodeStringValue(*a0, *a1);
	} else {
		sipIsErr = throwInvalidNodeException(sipCpp->getGraph(), *a0);
	}
%End	
	
//===========================================================================================	
	
	virtual bool setEdgeStringValue( const tlp::edge edge, const std::string & strVal) = 0;
%Docstring
tlp.PropertyInterface.setEdgeStringValue(edge, str)

Registers a new value for the given edge in converting
the given string representation.
Returns :const:`True` if the given string representation has been successfully converted to a value, :const:`False` otherwise.

:param edge: an existing edge
:type edge: :class:`tlp.edge`
:param str: a string representation of a value
:type str: string
:rtype: boolean
:throws: an exception if the edge does not belong to the graph attached to the property
%End	
	
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipCpp->setEdgeStringValue(*a0, *a1);
	} else {
		sipIsErr = throwInvalidEdgeException(sipCpp->getGraph(), *a0);
	}
%End
	
//===========================================================================================

    std::string __getitem__(const tlp::node node) ;
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipRes = new std::string(sipCpp->getNodeStringValue(*a0));     	
    } else {
    	sipIsErr = throwInvalidNodeException(sipCpp->getGraph(), *a0);
    }
%End

//===========================================================================================

    void __setitem__(const tlp::node node, const std::string &strVal) ;
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipCpp->setNodeStringValue(*a0, *a1);     	
    } else {
    	sipIsErr = throwInvalidNodeException(sipCpp->getGraph(), *a0);
    }
%End

//===========================================================================================	
		
    std::string __getitem__(const tlp::edge edge) ;
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipRes = new std::string(sipCpp->getEdgeStringValue(*a0));     	
    } else {
    	sipIsErr = throwInvalidEdgeException(sipCpp->getGraph(), *a0);
    }
%End


//===========================================================================================

    void __setitem__(const tlp::edge edge, const std::string &strVal) ;
%MethodCode
	if (sipCpp->getGraph()->isElement(*a0)) {
		sipCpp->setEdgeStringValue(*a0, *a1);     	
    } else {
    	sipIsErr = throwInvalidEdgeException(sipCpp->getGraph(), *a0);
    }
%End 
  	
};

};