SdoOrganization.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
20 #include <coil/UUID.h>
21 #include <rtm/SdoOrganization.h>
22 #include <rtm/CORBA_SeqUtil.h>
23 #include <memory>
24 #include <iostream>
25 
26 namespace SDOPackage
27 {
28  /* @if jp
29  * @brief コンストラクタ
30  * @else
31  * @brief Constructor
32  * @endif
33  */
34 #ifdef ORB_IS_RTORB
35  Organization_impl::Organization_impl(RTC::RTObject_ptr sdo)
36  : rtclog("organization")
37  {
38  m_varOwner = sdo.in();
39 
41  uugen.init();
42  std::auto_ptr<coil::UUID> uuid(uugen.generateUUID(2,0x01));
43  m_pId = uuid->to_string();
44 #ifdef WIN32
45  uuid->~UUID();
46 #endif // WIN32
47  m_dependency = OWN;
48  m_objref = this->_this();
49  }
50 #endif // ORB_IS_RTORB
51 
52  Organization_impl::Organization_impl(SDOSystemElement_ptr sdo)
53  : rtclog("organization"), m_varOwner(SDOSystemElement::_duplicate(sdo))
54  {
56  uugen.init();
57  std::auto_ptr<coil::UUID> uuid(uugen.generateUUID(2,0x01));
58  m_pId = uuid->to_string();
59 #ifdef WIN32
60  uuid->~UUID();
61 #endif // WIN32
62  m_dependency = OWN;
63  m_objref = this->_this();
64  }
65 
66  /* @if jp
67  * @brief 仮想デストラクタ
68  * @else
69  * @brief Virtual destructor
70  * @endif
71  */
73  {
74  }
75 
84  throw (CORBA::SystemException,
85  InvalidParameter, NotAvailable, InternalError)
86  {
87  RTC_TRACE(("get_organization_id() = %s", m_pId.c_str()));
88  return CORBA::string_dup(m_pId.c_str());
89  }
90 
99  throw (CORBA::SystemException,
100  NotAvailable, InternalError)
101  {
102  RTC_TRACE(("get_organization_property()"));
103  Guard guard(m_org_mutex);
104  OrganizationProperty_var prop;
105  prop = new OrganizationProperty(m_orgProperty);
106  return prop._retn();
107  }
108 
116  CORBA::Any*
118  throw (CORBA::SystemException,
119  InvalidParameter, NotAvailable, InternalError)
120  {
121  RTC_TRACE(("get_organization_property_value(%s)", name));
122  if (std::string(name).empty())
123  throw InvalidParameter("Empty name.");
124 
125  CORBA::Long index;
126  index = CORBA_SeqUtil::find(m_orgProperty.properties, nv_name(name));
127 
128  if (index < 0)
129  throw InvalidParameter("Not found.");
130 
131  try
132  {
133  CORBA::Any_var value;
134  value = new CORBA::Any(m_orgProperty.properties[index].value);
135  return value._retn();
136  }
137  catch (...)
138  {
139  throw InternalError("get_organization_property_value()");
140  }
141  // never reach here
142  return new CORBA::Any();
143  }
144 
152  CORBA::Boolean
154  add_organization_property(const OrganizationProperty& organization_property)
155  throw (CORBA::SystemException,
156  InvalidParameter, NotAvailable, InternalError)
157  {
158  RTC_TRACE(("add_organization_property()"));
159  try
160  {
161  Guard guard(m_org_mutex);
162  m_orgProperty = organization_property;
163  return true;
164  }
165  catch (...)
166  {
167  throw InternalError("set_organization_property()");
168  }
169  return false;
170  }
171 
179  CORBA::Boolean
181  const CORBA::Any& value)
182  throw (CORBA::SystemException,
183  InvalidParameter, NotAvailable, InternalError)
184  {
185  RTC_TRACE(("set_organization_property_value(name=%s)", name));
186  if (std::string(name).empty())
187  {
188  throw InvalidParameter("set_organization_property_value(): Enpty name.");
189  }
190 
191  CORBA::Long index;
192  index = CORBA_SeqUtil::find(m_orgProperty.properties,nv_name(name));
193  if (index < 0)
194  {
195  NameValue nv;
196  nv.name = CORBA::string_dup(name);
197  nv.value = value;
198  CORBA_SeqUtil::push_back(m_orgProperty.properties, nv);
199  }
200  else
201  {
202  m_orgProperty.properties[index].value = value;
203  }
204  return true;
205  }
206 
214  CORBA::Boolean
216  throw (CORBA::SystemException,
217  InvalidParameter, NotAvailable, InternalError)
218  {
219  RTC_TRACE(("remove_organization_property(%s)", name));
220  if (std::string(name).empty())
221  throw InvalidParameter("remove_organization_property(): Enpty name.");
222 
223  CORBA::Long index;
224  index = CORBA_SeqUtil::find(m_orgProperty.properties,nv_name(name));
225  if (index < 0)
226  throw InvalidParameter("remove_organization_property(): Not found.");
227 
228  try
229  {
230  CORBA_SeqUtil::erase(m_orgProperty.properties, index);
231  return true;
232  }
233  catch (...)
234  {
235  throw InternalError("remove_organization_property()");
236  }
237  return false;
238  }
239 
247  SDOSystemElement_ptr Organization_impl::get_owner()
248  throw (CORBA::SystemException,
249  NotAvailable, InternalError)
250  {
251  RTC_TRACE(("get_owner()"));
252  return m_varOwner._retn();
253  }
254 
262  CORBA::Boolean Organization_impl::set_owner(SDOSystemElement_ptr sdo)
263  throw (CORBA::SystemException,
264  InvalidParameter, NotAvailable, InternalError)
265  {
266  RTC_TRACE(("set_owner()"));
267  if (CORBA::is_nil(sdo))
268  throw InvalidParameter("set_owner()");
269  try
270  {
271  m_varOwner = SDOSystemElement::_duplicate(sdo);
272  return true;
273  }
274  catch (...)
275  {
276  throw InternalError("set_owner()");
277  }
278  return true;
279  }
280 
289  throw (CORBA::SystemException,
290  NotAvailable, InternalError)
291  {
292  RTC_TRACE(("get_members()"));
293  try
294  {
295  SDOList_var sdos;
296  sdos = new SDOList(m_memberList);
297  return sdos._retn();
298  }
299  catch (...)
300  {
301  throw InternalError("get_members()");
302  }
303  }
304 
312  CORBA::Boolean Organization_impl::set_members(const SDOList& sdos)
313  throw (CORBA::SystemException,
314  InvalidParameter, NotAvailable, InternalError)
315  {
316  RTC_TRACE(("set_members()"));
317  if (sdos.length() < 0)
318  throw InvalidParameter("set_members(): number of SDOList is invalid.");
319  try
320  {
321  m_memberList = sdos;
322  return true;
323  }
324  catch (...)
325  {
326  throw InternalError("set_members()");
327  }
328  return true;
329  }
330 
338  CORBA::Boolean Organization_impl::add_members(const SDOList& sdo_list)
339  throw (CORBA::SystemException,
340  InvalidParameter, NotAvailable, InternalError)
341  {
342  RTC_TRACE(("add_members()"));
343  if (sdo_list.length() < 0)
344  throw InvalidParameter("set_members(): number of SDOList is invalid.");
345  try
346  {
347  if (sdo_list.length() == 0) return true;
349  return true;
350  }
351  catch (...)
352  {
353  throw InternalError("add_members()");
354  }
355  return false;
356  }
357 
365  CORBA::Boolean Organization_impl::remove_member(const char* id)
366  throw (CORBA::SystemException,
367  InvalidParameter, NotAvailable, InternalError)
368  {
369  RTC_TRACE(("remove_member(%s)", id));
370 
371  if (std::string(id).empty())
372  {
373  RTC_ERROR(("remove_member(): Enpty name."));
374  throw InvalidParameter("remove_member(): Enpty name.");
375  }
376 
377  CORBA::Long index;
379 
380  if (index < 0)
381  {
382  RTC_ERROR(("remove_member(): Not found."));
383  throw InvalidParameter("remove_member(): Not found.");
384  }
385 
386  try
387  {
389  return true;
390  }
391  catch (...)
392  {
393  RTC_ERROR(("unknown exception"));
394  throw InternalError("remove_member(): Not found.");
395  }
396  return false;
397  }
398 
407  throw (CORBA::SystemException,
408  NotAvailable, InternalError)
409  {
410  RTC_TRACE(("get_dependency()"));
411  return m_dependency;
412  }
413 
421  CORBA::Boolean Organization_impl::set_dependency(DependencyType dependency)
422  throw (CORBA::SystemException,
423  NotAvailable, InternalError)
424  {
425  RTC_TRACE(("set_dependency()"));
426  try
427  {
428  m_dependency = dependency;
429  return true;
430  }
431  catch (...)
432  {
433  throw InternalError("set_dependency(): Unknown.");
434  }
435  return false;
436  }
437 };
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
void erase(CorbaSequence &seq, CORBA::ULong index)
Erase the element of the specified index.
virtual CORBA::Boolean add_organization_property(const OrganizationProperty &org_property)
[CORBA interface] Set OrganizationProperty
virtual SDOList * get_members()
[CORBA interface] Get the member list of the Organization
virtual SDOSystemElement_ptr get_owner()
[CORBA interface] Get the owner of Organization
void init()
Initialization.
virtual char * get_organization_id()
[CORBA interface] Get Organization ID
SDO Organization implementation class.
virtual CORBA::Boolean remove_organization_property(const char *name)
[CORBA interface] Remove specified OrganizationProperty
SDO Package.
virtual CORBA::Boolean set_organization_property_value(const char *name, const CORBA::Any &value)
[CORBA interface] Set specified value of OrganizationProperty
virtual DependencyType get_dependency()
[CORBA interface] Get the DependencyType of the Organization
coil::UUID * generateUUID(ACE_UINT16 version=0x0001, u_char variant=0x80)
Definition: ace/coil/UUID.h:45
virtual CORBA::Boolean set_members(const SDOList &sdos)
[CORBA interface] Set SDO
#define RTC_TRACE(fmt)
CORBA::Long find(const CorbaSequence &seq, Functor f)
Return the index of CORBA sequence element that functor matches.
list index
Definition: rtimages.py:10
SDOPackage::OrganizationProperty m_orgProperty
Organization property.
CORBA sequence utility template functions.
virtual CORBA::Boolean remove_member(const char *id)
[CORBA interface] Remove member SDO from Organization
SDOPackage::SDOList m_memberList
A list of SDO members associated with the Organization.
prop
Organization::get_organization_property ();.
virtual CORBA::Boolean set_owner(SDOSystemElement_ptr sdo)
[CORBA interface] Set the owner to the Organization
Organization_impl(SDOSystemElement_ptr sdo)
Constructor.
virtual ~Organization_impl(void)
Virtual destructor.
SDOPackage::SDOSystemElement_var m_varOwner
The owner of the Organization.
virtual OrganizationProperty * get_organization_property()
[CORBA interface] Get OrganizationProperty
void push_back_list(CorbaSequence &seq1, const CorbaSequence &seq2)
Merge the elements of the CORBA sequence.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
SDOPackage::DependencyType m_dependency
Dependency type.
virtual CORBA::Any * get_organization_property_value(const char *name)
[CORBA interface] Get specified value of OrganizationProperty
virtual CORBA::Boolean add_members(const SDOList &sdo_list)
[CORBA interface] Add the member SDOs
virtual CORBA::Boolean set_dependency(DependencyType dependency)
[CORBA interface] Set the DependencyType of the Organization


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:56