|
1
|
|
|
from synergine.cst import COL_ALL |
|
2
|
|
|
from synergine.synergy.object.SynergyObjectInterface import SynergyObjectInterface |
|
3
|
|
|
from synergine.lib.eint import IncrementedNamedInt |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class SynergyObject(SynergyObjectInterface): |
|
7
|
|
|
""" |
|
8
|
|
|
:ivar _collection: Foo |
|
9
|
|
|
:ivar _cycle_frequency: Bar |
|
10
|
|
|
""" |
|
11
|
|
|
|
|
12
|
|
|
def __init__(self, collection, context): |
|
13
|
|
|
self._collection = collection |
|
14
|
|
|
self._cycle_frequency = 1 |
|
15
|
|
|
self._id = IncrementedNamedInt.get(self) |
|
16
|
|
|
self._context = context |
|
17
|
|
|
self._add_col(COL_ALL) |
|
18
|
|
|
|
|
19
|
|
|
def _add_state(self, state, **kwargs): |
|
20
|
|
|
""" |
|
21
|
|
|
|
|
22
|
|
|
Shortcut to self._context.metas.states.add |
|
23
|
|
|
|
|
24
|
|
|
:param state: State |
|
25
|
|
|
:return: |
|
26
|
|
|
""" |
|
27
|
|
|
self._context.metas.states.add(self.get_id(), state, **kwargs) |
|
28
|
|
|
|
|
29
|
|
|
def _remove_state(self, state, **kwargs): |
|
30
|
|
|
""" |
|
31
|
|
|
|
|
32
|
|
|
Shortcut to self._context.metas.states.remove |
|
33
|
|
|
|
|
34
|
|
|
:param state: State |
|
35
|
|
|
:return: |
|
36
|
|
|
""" |
|
37
|
|
|
self._context.metas.states.remove(self.get_id(), state, **kwargs) |
|
38
|
|
|
|
|
39
|
|
|
def _add_col(self, col, **kwargs): |
|
40
|
|
|
""" |
|
41
|
|
|
|
|
42
|
|
|
Shortcut to self._context.metas.collections.add |
|
43
|
|
|
|
|
44
|
|
|
:param col: COL |
|
45
|
|
|
:return: |
|
46
|
|
|
""" |
|
47
|
|
|
self._context.metas.collections.add(self.get_id(), col, **kwargs) |
|
48
|
|
|
|
|
49
|
|
|
def _remove_col(self, col, **kwargs): |
|
50
|
|
|
""" |
|
51
|
|
|
|
|
52
|
|
|
Shortcut to self._context.metas.collections.remove |
|
53
|
|
|
|
|
54
|
|
|
:param col: COL |
|
55
|
|
|
:return: |
|
56
|
|
|
""" |
|
57
|
|
|
self._context.metas.collections.remove(self.get_id(), col, **kwargs) |
|
58
|
|
|
|
|
59
|
|
|
def get_collection(self): |
|
60
|
|
|
""" |
|
61
|
|
|
|
|
62
|
|
|
Return the Collection who contain this |
|
63
|
|
|
|
|
64
|
|
|
:return: The Collection who contain this |
|
65
|
|
|
:rtype: SynergyCollection |
|
66
|
|
|
""" |
|
67
|
|
|
return self._collection |
|
68
|
|
|
|
|
69
|
|
|
def get_id(self): |
|
70
|
|
|
""" |
|
71
|
|
|
|
|
72
|
|
|
Return the unique id of this object |
|
73
|
|
|
|
|
74
|
|
|
:return: Unique id of this object |
|
75
|
|
|
:rtype: int |
|
76
|
|
|
""" |
|
77
|
|
|
return self._id |
|
78
|
|
|
|
|
79
|
|
|
def initialize(self): |
|
80
|
|
|
""" |
|
81
|
|
|
|
|
82
|
|
|
You can place code here to initialize object after his creation and before simulation start. |
|
83
|
|
|
|
|
84
|
|
|
:return: |
|
85
|
|
|
""" |
|
86
|
|
|
pass |
|
87
|
|
|
|