[openrtm-commit:02576] r2981 - trunk/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 4月 14日 (金) 18:09:03 JST
Author: n-ando
Date: 2017-04-14 18:09:03 +0900 (Fri, 14 Apr 2017)
New Revision: 2981
Modified:
trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp
trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.h
Log:
[incompat,newfunc] A new operation implemented to the ManagerServant. refs #3273
Modified: trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp 2017-04-14 07:52:39 UTC (rev 2980)
+++ trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.cpp 2017-04-14 09:09:03 UTC (rev 2981)
@@ -765,6 +765,61 @@
// m_mgr.restart();
return ::RTC::RTC_OK;
}
+
+ /*!
+ * @if jp
+ * @brief 指定名のRTCオブジェクトリファレンスを取得
+ * @else
+ * @brief Obtain specific RTObject reference by name
+ * @endig
+ */
+ RTC::RTCList* ManagerServant::get_components_by_name(const char* name)
+ {
+ RTC_TRACE(("get_components_by_name()"));
+ ::RTC::RTCList_var crtcs = new ::RTC::RTCList();
+
+ // check argument
+ std::string tmp(name);
+ coil::eraseHeadBlank(tmp);
+ if (tmp.empty()) { return crtcs._retn(); }
+
+ std::vector<RTC::RTObject_impl*> rtcs = m_mgr.getComponents();
+ coil::vstring rtc_name = coil::split(tmp, "/");
+ for (size_t i(0); i < rtcs.size(); ++i)
+ {
+ // name = ConsoleIn0, instancename = ConsoleIn0
+ if (rtc_name.size() == 1 &&
+ rtc_name[0] == rtcs[i]->getInstanceName())
+ {
+ RTC::RTObject_var rtcref =
+ RTC::RTObject::_duplicate(rtcs[i]->getObjRef());
+#ifndef ORB_IS_RTORB
+ CORBA_SeqUtil::push_back(crtcs.inout(), rtcref.in());
+#else // ORB_IS_RTORB
+ CORBA_SeqUtil::push_back(crtcs, rtcref);
+#endif // ORB_IS_RTORB
+ continue;
+ }
+ if (rtc_name.size() < 2) { continue; } // size != 0
+
+ // name = */ConsoleIn0 instancename = ConsoleIn0 OR
+ // naem = sample/ConsoleIn0 category = sample && instance == ConsoleIn0
+ if ((rtc_name[0] == "*" &&
+ rtc_name[1] == rtcs[i]->getInstanceName()) ||
+ (rtc_name[0] == rtcs[i]->getCategory() &&
+ rtc_name[1] == rtcs[i]->getInstanceName()))
+ {
+ RTC::RTObject_var rtcref =
+ RTC::RTObject::_duplicate(rtcs[i]->getObjRef());
+#ifndef ORB_IS_RTORB
+ CORBA_SeqUtil::push_back(crtcs.inout(), rtcref.in());
+#else // ORB_IS_RTORB
+ CORBA_SeqUtil::push_back(crtcs, rtcref);
+#endif // ORB_IS_RTORB
+ }
+ }
+ return crtcs._retn();
+ }
CORBA::Object_ptr ManagerServant::get_service(const char* name)
{
Modified: trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.h 2017-04-14 07:52:39 UTC (rev 2980)
+++ trunk/OpenRTM-aist/src/lib/rtm/ManagerServant.h 2017-04-14 09:09:03 UTC (rev 2981)
@@ -498,8 +498,6 @@
*/
RTC::ReturnCode_t remove_slave_manager(RTM::Manager_ptr mgr);
-
-
/*!
* @if jp
* @brief プロセスのコピーを生成する
@@ -531,6 +529,23 @@
*/
RTC::ReturnCode_t restart();
+ /*!
+ * @if jp
+ * @brief 指定名のRTCオブジェクトリファレンスを取得
+ *
+ * @param name RTC名
+ * @return RTCリスト
+ *
+ * @else
+ * @brief
+ *
+ * @param name name
+ * @return list of RTC
+ *
+ * @endig
+ */
+ RTC::RTCList* get_components_by_name(const char* name);
+
/*!
* @if jp
* @brief RTCのリファレンスを取得する。
openrtm-commit メーリングリストの案内