Main Page
Namespaces
Classes
Files
File List
OpenRTM_aist
ObjectManager.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# -*- coding: euc-jp -*-
3
4
16
17
18
import
sys
19
import
string
20
import
threading
21
22
import
OpenRTM_aist
23
24
25
26
38
class
ObjectManager
:
39
"""
40
"""
41
42
55
def
__init__
(self, predicate):
56
self.
_objects
= self.
Objects
()
57
self.
_predicate
= predicate
58
59
60
61
66
class
Objects
:
67
def
__init__
(self):
68
self.
_mutex
= threading.RLock()
69
self.
_obj
= []
70
71
72
88
def
registerObject
(self, obj):
89
guard =
OpenRTM_aist.ScopedLock
(self._objects._mutex)
90
predi = self.
_predicate
(factory=obj)
91
92
for
_obj
in
self._objects._obj:
93
if
predi(_obj):
94
return
False
95
96
self._objects._obj.append(obj)
97
return
True
98
99
100
116
def
unregisterObject
(self, id):
117
guard =
OpenRTM_aist.ScopedLock
(self._objects._mutex)
118
predi = self.
_predicate
(name=id)
119
i = 0
120
for
_obj
in
self._objects._obj:
121
if
predi(_obj):
122
ret = _obj
123
del self._objects._obj[i]
124
return
ret
125
i+=1
126
127
return
None
128
129
130
147
def
find
(self, id):
148
guard =
OpenRTM_aist.ScopedLock
(self._objects._mutex)
149
if
isinstance(id,str):
150
predi = self.
_predicate
(name=id)
151
else
:
152
predi = self.
_predicate
(prop=id)
153
154
for
_obj
in
self._objects._obj:
155
if
predi(_obj):
156
return
_obj
157
158
return
None
159
160
161
175
def
getObjects
(self):
176
guard =
OpenRTM_aist.ScopedLock
(self._objects._mutex)
177
return
self._objects._obj
178
179
180
192
def
for_each
(self,p):
193
guard =
OpenRTM_aist.ScopedLock
(self._objects._mutex)
194
predi = p()
195
196
for
_obj
in
self._objects._obj:
197
predi(_obj)
198
199
return
predi
200
OpenRTM_aist.ObjectManager.ObjectManager.Objects._mutex
_mutex
Definition:
ObjectManager.py:68
OpenRTM_aist.ObjectManager.ObjectManager.for_each
def for_each(self, p)
Definition:
ObjectManager.py:192
OpenRTM_aist.ObjectManager.ObjectManager.unregisterObject
def unregisterObject(self, id)
Definition:
ObjectManager.py:116
OpenRTM_aist.ObjectManager.ObjectManager.getObjects
def getObjects(self)
Definition:
ObjectManager.py:175
OpenRTM_aist.ObjectManager.ObjectManager._predicate
_predicate
Definition:
ObjectManager.py:57
OpenRTM_aist.ObjectManager.ObjectManager._objects
_objects
Definition:
ObjectManager.py:56
OpenRTM_aist.ObjectManager.ObjectManager.Objects
Definition:
ObjectManager.py:66
OpenRTM_aist.ObjectManager.ObjectManager.Objects.__init__
def __init__(self)
Definition:
ObjectManager.py:67
OpenRTM_aist.ObjectManager.ObjectManager.__init__
def __init__(self, predicate)
Definition:
ObjectManager.py:55
OpenRTM_aist.Guard.ScopedLock
Definition:
Guard.py:32
OpenRTM_aist.ObjectManager.ObjectManager
Definition:
ObjectManager.py:38
OpenRTM_aist.ObjectManager.ObjectManager.registerObject
def registerObject(self, obj)
Definition:
ObjectManager.py:88
OpenRTM_aist.ObjectManager.ObjectManager.Objects._obj
_obj
Definition:
ObjectManager.py:69
OpenRTM_aist.ObjectManager.ObjectManager.find
def find(self, id)
Definition:
ObjectManager.py:147
openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34