OpenRTM_aist
NumberingPolicy.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# -*- coding: euc-jp -*-
3
4
16
17
import
string
18
import
OpenRTM_aist
19
20
37
class
NumberingPolicy
:
38
"""
39
"""
40
41
42
43
49
class
ObjectNotFound
:
50
pass
51
52
53
69
def
onCreate
(self, obj):
70
pass
71
72
73
87
def
onDelete
(self, obj):
88
pass
89
90
91
92
106
class
DefaultNumberingPolicy
(
NumberingPolicy
):
107
"""
108
"""
109
110
124
def
__init__
(self):
125
self.
_num
= 0
126
self.
_objects
= []
127
128
129
145
def
onCreate
(self, obj):
146
self.
_num
+= 1
147
148
pos = 0
149
try
:
150
pos = self.
find
(
None
)
151
self.
_objects
[pos] = obj
152
return
OpenRTM_aist.otos(pos)
153
except
NumberingPolicy.ObjectNotFound
:
154
self.
_objects
.
append
(obj)
155
return
OpenRTM_aist.otos(int(len(self.
_objects
) - 1))
156
157
158
172
def
onDelete
(self, obj):
173
pos = 0
174
try
:
175
pos = self.
find
(obj)
176
except
:
177
return
178
179
if
(pos < len(self.
_objects
)):
180
self.
_objects
[pos] =
None
181
self.
_num
-= 1
182
183
184
200
def
find
(self, obj):
201
i = 0
202
for
obj_
in
self.
_objects
:
203
if
obj_ == obj:
204
return
i
205
i += 1
206
raise
NumberingPolicy.ObjectNotFound
()
207
208
OpenRTM_aist.NumberingPolicy.NumberingPolicy.ObjectNotFound
Definition:
NumberingPolicy.py:49
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy._num
_num
Definition:
NumberingPolicy.py:125
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy.find
def find(self, obj)
Definition:
NumberingPolicy.py:200
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy.__init__
def __init__(self)
virtual destractor
Definition:
NumberingPolicy.py:124
OpenRTM_aist.NumberingPolicy.NumberingPolicy.onDelete
def onDelete(self, obj)
Definition:
NumberingPolicy.py:87
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy.onDelete
def onDelete(self, obj)
Definition:
NumberingPolicy.py:172
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy
Definition:
NumberingPolicy.py:106
OpenRTM_aist.NumberingPolicy.NumberingPolicy.onCreate
def onCreate(self, obj)
Definition:
NumberingPolicy.py:69
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy._objects
_objects
Definition:
NumberingPolicy.py:126
OpenRTM_aist.NumberingPolicy.NumberingPolicy
Definition:
NumberingPolicy.py:37
OpenRTM_aist.NVUtil.append
def append(dest, src)
Definition:
NVUtil.py:386
OpenRTM_aist.NumberingPolicy.DefaultNumberingPolicy.onCreate
def onCreate(self, obj)
Definition:
NumberingPolicy.py:145
openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:06