[openrtm-commit:03293] r3259 - trunk/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 3月 28日 (水) 10:52:25 JST
Author: miyamoto
Date: 2018-03-28 10:52:25 +0900 (Wed, 28 Mar 2018)
New Revision: 3259
Added:
trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.cpp
trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.h
trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.cpp
trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.h
Modified:
trunk/OpenRTM-aist/src/lib/rtm/CorbaPort.h
trunk/OpenRTM-aist/src/lib/rtm/FactoryInit.cpp
trunk/OpenRTM-aist/src/lib/rtm/NamingManager.cpp
trunk/OpenRTM-aist/src/lib/rtm/NamingManager.h
trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicy.h
trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicyBase.cpp
Log:
[merge] r3158-3160 have been merged from RELENG_1_2.
Modified: trunk/OpenRTM-aist/src/lib/rtm/CorbaPort.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/CorbaPort.h 2018-03-27 05:20:02 UTC (rev 3258)
+++ trunk/OpenRTM-aist/src/lib/rtm/CorbaPort.h 2018-03-28 01:52:25 UTC (rev 3259)
@@ -1226,11 +1226,15 @@
m_ior()
{
#ifndef ORB_IS_RTORB
- PortableServer::POA_var poa = ::RTC::Manager::instance().getPOA();
- m_oid = poa->servant_to_id(m_servant);
+#ifdef ORB_IS_OMNIORB
+ m_poa = ::RTC::Manager::instance().theShortCutPOA();
+#else
+ m_poa = ::RTC::Manager::instance().getPOA();
+#endif
+ m_oid = m_poa->servant_to_id(m_servant);
try
{
- poa->activate_object_with_id(m_oid, m_servant);
+ m_poa->activate_object_with_id(m_oid, m_servant);
}
catch(...)
{
@@ -1237,7 +1241,7 @@
;
}
CORBA::Object_var obj;
- obj = poa->id_to_reference(m_oid);
+ obj = m_poa->id_to_reference(m_oid);
CORBA::ORB_var orb = Manager::instance().getORB();
CORBA::String_var ior_var = orb->object_to_string(obj);
m_ior = ior_var;
@@ -1267,8 +1271,7 @@
{
try
{
- ::RTC::Manager::instance().
- thePOA()->activate_object_with_id(m_oid, m_servant);
+ m_poa->activate_object_with_id(m_oid, m_servant);
}
catch(const ::PortableServer::POA::ServantAlreadyActive &)
{
@@ -1283,7 +1286,7 @@
{
try
{
- ::RTC::Manager::instance().thePOA()->deactivate_object(m_oid);
+ m_poa->deactivate_object(m_oid);
}
catch(...)
{
@@ -1296,6 +1299,7 @@
PortableServer::RefCountServantBase* m_servant;
PortableServer::ObjectId_var m_oid;
std::string m_ior;
+ PortableServer::POA_var m_poa;
};
/*!
Modified: trunk/OpenRTM-aist/src/lib/rtm/FactoryInit.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/FactoryInit.cpp 2018-03-27 05:20:02 UTC (rev 3258)
+++ trunk/OpenRTM-aist/src/lib/rtm/FactoryInit.cpp 2018-03-28 01:52:25 UTC (rev 3259)
@@ -48,6 +48,8 @@
// RTC name numbering policy
#include <rtm/NumberingPolicy.h>
+#include <rtm/NamingServiceNumberingPolicy.h>
+#include <rtm/NodeNumberingPolicy.h>
void FactoryInit()
{
@@ -83,6 +85,6 @@
// Naming Policy
ProcessUniquePolicyInit();
- // NodeUniquePolicyInit();
- // NamingServiceUniquePolicyInit();
+ NamingServiceNumberingPolicyInit();
+ NodeNumberingPolicyInit();
}
Modified: trunk/OpenRTM-aist/src/lib/rtm/NamingManager.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NamingManager.cpp 2018-03-27 05:20:02 UTC (rev 3258)
+++ trunk/OpenRTM-aist/src/lib/rtm/NamingManager.cpp 2018-03-28 01:52:25 UTC (rev 3259)
@@ -51,6 +51,7 @@
coil::vstring host_port(coil::split(names, ":"));
if (coil::dest_to_endpoint(host_port[0], m_endpoint))
{
+
RTC_INFO(("Endpoint for the CORBA naming service (%s) is %s.",
host_port[0].c_str(),
m_endpoint.c_str()));
@@ -180,6 +181,350 @@
return m_cosnaming.isAlive();
}
+ /*!
+ * @if jp
+ *
+ * @brief ¥Í¡¼¥ß¥ó¥°¥µ¡¼¥Ó¥¹¤«¤éRTC¤ò¥¤¥ó¥¹¥¿¥ó¥¹Ì¾¤«¤é¸¡º÷¤·¡¢
+ * °ìÃפ¹¤ëRTC¤Î¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param context ¸½ºß¸¡º÷Ãæ¤Î¥³¥ó¥Æ¥¥¹¥È
+ * @param name RTC¤Î¥¤¥ó¥¹¥¿¥ó¥¹Ì¾
+ * @param rtcs RTC¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param context
+ * @param name
+ * @param rtcs
+ *
+ * @endif
+ */
+ void NamingOnCorba::getComponentByName(CosNaming::NamingContext_ptr context, std::string name, RTC::RTCList& rtcs)
+ {
+
+ CORBA::ULong length = 500;
+ CosNaming::BindingList_var bl;
+ CosNaming::BindingIterator_var bi;
+ context->list(length, bl, bi);
+
+ CORBA::ULong len(bl->length());
+ for (CORBA::ULong i = 0; i < len; ++i)
+ {
+ if (bl[i].binding_type == CosNaming::ncontext)
+ {
+ CosNaming::NamingContext_ptr next_context = CosNaming::NamingContext::
+ _narrow(context->resolve(bl[i].binding_name));
+ getComponentByName(next_context, name, rtcs);
+ }
+ else if (bl[i].binding_type == CosNaming::nobject)
+ {
+ if (std::string(bl[i].binding_name[0].id) == name && std::string(bl[i].binding_name[0].kind) == "rtc")
+ {
+ try
+ {
+ //RTC::CorbaConsumer<RTC::RTObject> cc;
+ //cc.setObject(context->resolve(bl[i].binding_name));
+ RTC::RTObject_ptr obj = RTC::RTObject::_narrow(context->resolve(bl[i].binding_name));
+ if (!obj->_non_existent())
+ {
+ CORBA_SeqUtil::push_back(rtcs, obj);
+ }
+ }
+ catch (...)
+ {
+ //RTC_ERROR((""));
+ }
+ }
+ }
+ }
+ }
+ /*!
+ * @if jp
+ *
+ * @brief ¥Í¡¼¥ß¥ó¥°¥µ¡¼¥Ó¥¹¤«¤éRTC¤ò¥¤¥ó¥¹¥¿¥ó¥¹Ì¾¤«¤é¸¡º÷¤·¡¢
+ * °ìÃפ¹¤ëRTC¤Î¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param context ¸½ºß¸¡º÷Ãæ¤Î¥³¥ó¥Æ¥¥¹¥È
+ * @param name RTC¤Î¥¤¥ó¥¹¥¿¥ó¥¹Ì¾
+ * @param rtcs RTC¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param context
+ * @param name
+ * @param rtcs
+ *
+ * @endif
+ */
+ RTC::RTCList NamingOnCorba::string_to_component(std::string name)
+ {
+ RTC::RTCList rtc_list;
+
+ coil::vstring tmp = coil::split(name, "://");
+ if (tmp.size() > 1)
+ {
+ if (tmp[0] == "rtcname")
+ {
+ std::string url = tmp[1];
+ coil::vstring r = coil::split(url, "/");
+ if (r.size() > 1)
+ {
+ std::string host = r[0];
+ std::string rtc_name = url.substr(host.size()+1, url.size() - host.size());
+ try
+ {
+ RTC::CorbaNaming *cns = NULL;
+ if (host == "*")
+ {
+ cns = &m_cosnaming;
+ }
+ else
+ {
+ CORBA::ORB_var orb = Manager::instance().getORB();
+ cns = new RTC::CorbaNaming(orb, host.c_str());
+ }
+ coil::vstring names = coil::split(rtc_name, "/");
+
+ if (names.size() == 2 && names[0] == "*")
+ {
+ CosNaming::NamingContext_ptr root_cxt = cns->getRootContext();
+ getComponentByName(root_cxt, names[1], rtc_list);
+ return rtc_list;
+ }
+ else
+ {
+ rtc_name += ".rtc";
+ CORBA::Object_ptr obj = cns->resolveStr(rtc_name.c_str());
+ if (CORBA::is_nil(obj))
+ {
+ return rtc_list;
+ }
+ CORBA_SeqUtil::push_back(rtc_list, RTC::RTObject::_narrow(obj));
+ return rtc_list;
+ }
+ if (cns != &m_cosnaming)
+ {
+ delete cns;
+ }
+ }
+ catch (...)
+ {
+ return rtc_list;
+ }
+ }
+ }
+ }
+ return rtc_list;
+ }
+
+
+
+ /*!
+ * @if jp
+ * @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ NamingOnManager::NamingOnManager(CORBA::ORB_ptr orb, Manager* mgr)
+ : m_orb(orb), m_mgr(mgr)
+ {
+ }
+ /*!
+ * @if jp
+ * @brief »ØÄꤷ¤¿ CORBA ¥ª¥Ö¥¸¥§¥¯¥È¤ÎNamingService¤Ø¥Ð¥¤¥ó¥É
+ * @else
+ * @brief Bind the specified CORBA objects to NamingService
+ * @endif
+ */
+ void NamingOnManager::bindObject(const char* name,
+ const RTObject_impl* rtobj)
+ {
+ RTC_TRACE(("bindObject(name = %s, rtobj)", name));
+ return;
+ }
+
+ void NamingOnManager::bindObject(const char* name,
+ const PortBase* port)
+ {
+ RTC_TRACE(("bindObject(name = %s, rtobj)", name));
+ return;
+ }
+
+ void NamingOnManager::bindObject(const char* name,
+ const RTM::ManagerServant* mgr)
+ {
+ RTC_TRACE(("bindObject(name = %s, mgr)", name));
+ return;
+ }
+
+ /*!
+ * @if jp
+ * @brief »ØÄꤷ¤¿ CORBA ¥ª¥Ö¥¸¥§¥¯¥È¤òNamingService¤«¤é¥¢¥ó¥Ð¥¤¥ó¥É
+ * @else
+ * @brief Unbind the specified CORBA object from NamingService
+ * @endif
+ */
+ void NamingOnManager::unbindObject(const char* name)
+ {
+ RTC_TRACE(("unbindObject(name = %s)", name));
+ return;
+ }
+
+ bool NamingOnManager::isAlive()
+ {
+ RTC_TRACE(("isAlive()"));
+ return true;
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief rtcname·Á¼°¤ÇRTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param name rtcloc·Á¼°¤Ç¤ÎRTC̾
+ * rtcloc://localhost:2809/example/ConsoleIn
+ * @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param name
+ * @return
+ *
+ * @endif
+ */
+ RTC::RTCList NamingOnManager::string_to_component(std::string name)
+ {
+ RTC::RTCList rtc_list;
+ coil::vstring tmp = coil::split(name, "://");
+ if (tmp.size() > 1)
+ {
+ if (tmp[0] == "rtcloc")
+ {
+ std::string url = tmp[1];
+ coil::vstring r = coil::split(url, "/");
+
+ if (r.size() > 1)
+ {
+ std::string host = r[0];
+ std::string rtc_name = url.substr(host.size()+1, url.size() - host.size());
+
+ RTM::Manager_ptr mgr = getManager(host);
+
+ if (!CORBA::is_nil(mgr))
+ {
+
+ rtc_list = (*mgr->get_components_by_name(rtc_name.c_str()));
+ RTM::ManagerList* slaves = mgr->get_slave_managers();
+ for (int i = 0; i < slaves->length(); i++)
+ {
+
+ try
+ {
+ RTC::RTCList slave_rtcs = (*(*slaves)[i]->get_components_by_name(rtc_name.c_str()));
+ CORBA_SeqUtil::push_back_list(rtc_list, slave_rtcs);
+ }
+ catch (...)
+ {
+ //RTC_DEBUG((""));
+ mgr->remove_slave_manager((*slaves)[i]);
+ }
+ }
+ }
+ return rtc_list;
+ }
+ }
+ }
+ return rtc_list;
+ }
+
+
+ /*!
+ * @if jp
+ *
+ * @brief »ØÄê¥Û¥¹¥È̾¡¢¥Ý¡¼¥È̾¤ÇManager¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ
+ *
+ * @param name ¥Û¥¹¥È̾¡¢¥Ý¡¼¥È̾
+ *
+ * @return Manager¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param name
+ * @return
+ *
+ * @endif
+ */
+ RTM::Manager_ptr NamingOnManager::getManager(std::string name)
+ {
+
+ if (name == "*")
+ {
+ RTM::Manager_ptr mgr;
+ RTM::ManagerServant& mgr_sev = m_mgr->getManagerServant();
+ if (mgr_sev.is_master())
+ {
+ mgr = mgr_sev.getObjRef();
+
+ }
+ else
+ {
+ RTM::ManagerList* masters = mgr_sev.get_master_managers();
+
+ if (masters->length() > 0)
+ {
+ mgr = (*masters)[0];
+ }
+ else
+ {
+ mgr = mgr_sev.getObjRef();
+ }
+ }
+ return mgr;
+ }
+
+
+
+
+ try
+ {
+ std::string mgrloc = "corbaloc:iiop:";
+ coil::Properties prop = m_mgr->getConfig();
+ std::string manager_name = prop.getProperty("manager.name");
+ mgrloc += name;
+ mgrloc += "/" + manager_name;
+
+ CORBA::Object_ptr mobj = m_orb->string_to_object(mgrloc.c_str());
+ RTM::Manager_ptr mgr = RTM::Manager::_narrow(mobj);
+
+ RTC_DEBUG(("corbaloc: %s", mgrloc));
+
+ return mgr;
+ }
+ catch (CORBA::SystemException& ex)
+ {
+
+ }
+ catch (...)
+ {
+ RTC_ERROR(("Unknown exception cought."));
+
+ }
+ return RTM::Manager::_nil();
+
+
+ }
+
+
+
//============================================================
// NamingManager
@@ -449,6 +794,7 @@
RTC_TRACE(("createNamingObj(method = %s, nameserver = %s",
method, name_server));
std::string m(method);
+
if (m == "corba")
{
try
@@ -468,6 +814,13 @@
return NULL;
}
}
+ else if (m == "manager")
+ {
+ NamingBase* name;
+ CORBA::ORB_var orb = m_manager->getORB();
+ name = new NamingOnManager(orb.in(), m_manager);
+ return name;
+ }
return NULL;
}
@@ -614,4 +967,42 @@
}
}
}
+ /*!
+ * @if jp
+ *
+ * @brief rtcloc·Á¼°¤ÇRTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ
+ *
+ *
+ *
+ * @param name rtcloc·Á¼°¤Ç¤ÎRTC̾
+ * rtcloc://localhost:2809/example/ConsoleIn
+ * @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ * registerMgrName
+ * @param name
+ *
+ * @return
+ *
+ *
+ * @endif
+ */
+ RTCList NamingManager::string_to_component(std::string name)
+ {
+
+ for (std::vector<NamingService*>::iterator itr = m_names.begin(); itr != m_names.end(); ++itr) {
+ if ((*itr)->ns != 0)
+ {
+ RTCList comps = (*itr)->ns->string_to_component(name);
+ if (comps.length() > 0)
+ {
+ return comps;
+ }
+ }
+ }
+
+ return RTCList();
+ }
}; // namespace RTC
Modified: trunk/OpenRTM-aist/src/lib/rtm/NamingManager.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NamingManager.h 2018-03-27 05:20:02 UTC (rev 3258)
+++ trunk/OpenRTM-aist/src/lib/rtm/NamingManager.h 2018-03-28 01:52:25 UTC (rev 3259)
@@ -170,6 +170,24 @@
* @endif
*/
virtual bool isAlive() = 0;
+ /*!
+ * @if jp
+ *
+ * @brief rtcloc·Á¼°¤ÇRTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param name RTC̾
+ * @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param name
+ * @return
+ *
+ * @endif
+ */
+ virtual RTC::RTCList string_to_component(std::string name) = 0;
};
/*!
@@ -347,6 +365,45 @@
* @endif
*/
virtual bool isAlive();
+ /*!
+ * @if jp
+ *
+ * @brief ¥Í¡¼¥ß¥ó¥°¥µ¡¼¥Ó¥¹¤«¤éRTC¤ò¥¤¥ó¥¹¥¿¥ó¥¹Ì¾¤«¤é¸¡º÷¤·¡¢
+ * °ìÃפ¹¤ëRTC¤Î¥ê¥¹¥È¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param context ¸½ºß¸¡º÷Ãæ¤Î¥³¥ó¥Æ¥¥¹¥È
+ * @param name RTC¤Î¥¤¥ó¥¹¥¿¥ó¥¹Ì¾
+ * @param rtcs RTC¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param context
+ * @param name
+ * @param rtcs
+ *
+ * @endif
+ */
+ void getComponentByName(CosNaming::NamingContext_ptr context, std::string name, RTC::RTCList& rtcs);
+ /*!
+ * @if jp
+ *
+ * @brief rtcname·Á¼°¤ÇRTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param name RTC̾
+ * @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param name
+ * @return
+ *
+ * @endif
+ */
+ virtual RTC::RTCList string_to_component(std::string name);
CorbaNaming& getCorbaNaming() { return m_cosnaming; }
private:
@@ -356,6 +413,193 @@
bool m_replaceEndpoint;
// std::map<std::string, RTObject_impl*> m_names;
};
+
+
+
+ /*!
+ * @if jp
+ *
+ * @class NamingOnManager
+ * @brief Manager ÍÑ NamingServer ´ÉÍý¥¯¥é¥¹
+ *
+ * @since 1.2.0
+ *
+ * @else
+ *
+ * @class NamingOnManager
+ * @brief
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ class NamingOnManager
+ : public virtual NamingBase
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+ *
+ *
+ * @param orb ORB
+ * @param mgr ¥Þ¥Í¡¼¥¸¥ã
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ *
+ *
+ * @param orb ORB
+ * @param mgr
+ *
+ * @endif
+ */
+ NamingOnManager(CORBA::ORB_ptr orb, Manager* mgr);
+
+ /*!
+ * @if jp
+ *
+ * @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * @endif
+ */
+ virtual ~NamingOnManager(void){};
+
+ /*!
+ * @if jp
+ *
+ * @brief »ØÄꤷ¤¿ CORBA ¥ª¥Ö¥¸¥§¥¯¥È¤ÎNamingService¤Ø¥Ð¥¤¥ó¥É
+ *
+ * »ØÄꤷ¤¿ CORBA ¥ª¥Ö¥¸¥§¥¯¥È¤ò»ØÄꤷ¤¿Ì¾¾Î¤Ç CORBA NamingService ¤Ø
+ * ¥Ð¥¤¥ó¥É¤¹¤ë¡£
+ *
+ * @param name ¥Ð¥¤¥ó¥É»þ¤Î̾¾Î
+ * @param rtobj ¥Ð¥¤¥ó¥ÉÂоݥª¥Ö¥¸¥§¥¯¥È
+ *
+ * @else
+ *
+ * @brief Bind the specified CORBA objects to NamingService
+ *
+ * Bind the specified CORBA objects to CORBA NamingService
+ * by specified names.
+ *
+ * @param name Names at the binding
+ * @param rtobj The target objects for the binding
+ *
+ * @endif
+ */
+ virtual void bindObject(const char* name, const RTObject_impl* rtobj);
+ virtual void bindObject(const char* name, const PortBase* port);
+
+ /*!
+ * @if jp
+ *
+ * @brief
+ *
+ * @param name ¥Ð¥¤¥ó¥É»þ¤Î̾¾Î
+ * @param rtobj ¥Ð¥¤¥ó¥ÉÂоÝManagerServant
+ *
+ * @else
+ *
+ * @brief Bind the specified ManagerServants to NamingService
+ *
+ * @param name Names at the binding
+ * @param mgr The target ManagerServants for the binding
+ *
+ * @endif
+ */
+ virtual void bindObject(const char* name, const RTM::ManagerServant* mgr);
+
+ /*!
+ * @if jp
+ *
+ * @brief
+ *
+ *
+ *
+ * @param name ¥¢¥ó¥Ð¥¤¥ó¥ÉÂоݥª¥Ö¥¸¥§¥¯¥È
+ *
+ * @else
+ *
+ * @brief Unbind the specified CORBA objects from NamingService
+ *
+ * Unbind the specified CORBA objects from CORBA NamingService.
+ *
+ * @param name The target objects for the unbinding
+ *
+ * @endif
+ */
+ virtual void unbindObject(const char* name);
+
+ /*!
+ * @if jp
+ *
+ * @brief
+ *
+ * @return true:À¸Â¸¤·¤Æ¤¤¤ë, false:À¸Â¸¤·¤Æ¤¤¤Ê¤¤
+ *
+ * @else
+ *
+ * @brief Check if the name service is alive
+ *
+ * @return true: alive, false:non not alive
+ *
+ * @endif
+ */
+ virtual bool isAlive();
+ /*!
+ * @if jp
+ *
+ * @brief rtcname·Á¼°¤ÇRTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ¤¹¤ë
+ *
+ * @param name rtcloc·Á¼°¤Ç¤ÎRTC̾
+ * rtcloc://localhost:2809/example/ConsoleIn
+ * @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param name
+ * @return
+ *
+ * @endif
+ */
+ RTC::RTCList string_to_component(std::string name);
+ /*!
+ * @if jp
+ *
+ * @brief »ØÄê¥Û¥¹¥È̾¡¢¥Ý¡¼¥È̾¤ÇManager¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ
+ *
+ * @param name ¥Û¥¹¥È̾¡¢¥Ý¡¼¥È̾
+ *
+ * @return Manager¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹
+ *
+ * @else
+ *
+ * @brief
+ *
+ * @param name
+ * @return
+ *
+ * @endif
+ */
+ RTM::Manager_ptr getManager(std::string name);
+
+ private:
+ Logger rtclog;
+ CORBA::ORB_ptr m_orb;
+ Manager* m_mgr;
+ // std::map<std::string, RTObject_impl*> m_names;
+ };
/*!
* @if jp
@@ -571,6 +815,30 @@
*/
std::vector<RTObject_impl*> getObjects();
std::vector<NamingService*>& getNameServices() { return m_names; }
+
+ /*!
+ * @if jp
+ *
+ * @brief rtcloc·Á¼°¤ÇRTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼èÆÀ
+ *
+ *
+ *
+ * @param name rtcloc·Á¼°¤Ç¤ÎRTC̾
+ * rtcloc://localhost:2809/example/ConsoleIn
+ * @return RTC¤Î¥ª¥Ö¥¸¥§¥¯¥È¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥ê¥¹¥È
+ *
+ * @else
+ *
+ * @brief
+ * registerMgrName
+ * @param name
+ *
+ * @return
+ *
+ *
+ * @endif
+ */
+ RTCList string_to_component(std::string name);
protected:
/*!
@@ -756,6 +1024,8 @@
*/
void retryConnection(NamingService* ns);
+
+
protected:
// Name Servers' method/name and object
/*!
Copied: trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.cpp (from rev 3160, branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.cpp)
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.cpp 2018-03-28 01:52:25 UTC (rev 3259)
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+/*!
+* @file NamingServiceNumberingPolicy.cpp
+* @brief Object numbering policy class
+* @date $Date: 2018-1-11 03:08:04 $
+* @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+*
+* Copyright (C) 2018
+* Intelligent Systems Research Institute,
+* National Institute of
+* Advanced Industrial Science and Technology (AIST), Japan
+* All rights reserved.
+*
+*
+*/
+
+#include <rtm/NamingServiceNumberingPolicy.h>
+#include <rtm/Manager.h>
+#include <coil/stringutil.h>
+#include <rtm/NamingManager.h>
+#include <rtm/RTObject.h>
+
+namespace RTM
+{
+ //============================================================
+ // NamingServiceNumberingPolicy
+ //============================================================
+ NamingServiceNumberingPolicy::NamingServiceNumberingPolicy()
+ : m_num(0)
+ {
+ m_mgr = &RTC::Manager::instance();
+ }
+ /*!
+ * @if jp
+ * @brief オブジェクト生成時の名称作成
+ * @else
+ * @brief Create the name when creating objects
+ * @endif
+ */
+ std::string NamingServiceNumberingPolicy::onCreate(void* obj)
+ {
+ int num = 0;
+ while (true)
+ {
+ std::string num_str = coil::otos<int>(num);
+ RTC::RTObject_impl *rtobj = (RTC::RTObject_impl *)obj;
+
+
+ std::string name = rtobj->getTypeName() + num_str;
+
+ if (!find(name))
+ {
+ return num_str;
+ }
+ else
+ {
+ num++;
+ }
+ }
+ return coil::otos<int>(num);
+ }
+
+ /*!
+ * @if jp
+ * @brief オブジェクト削除時の名称解放
+ * @else
+ * @brief Delete the name when deleting objects
+ * @endif
+ */
+ void NamingServiceNumberingPolicy::onDelete(void* obj)
+ {
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクトの検索
+ *
+ * 指定名のインスタンス名のRTCを検索し、
+ * 一致するRTCが存在する場合はTrueを返す
+ *
+ * @param name 検索対象オブジェクトの名前
+ *
+ * @return 判定
+ *
+ * @else
+ *
+ * @brief
+ *
+ *
+ * @param name
+ *
+ * @return
+ *
+ * @endif
+ */
+ bool NamingServiceNumberingPolicy::find(std::string name)
+ {
+ RTC::RTCList rtcs;
+ std::string rtc_name = "rtcname://*/*/";
+ rtc_name += name;
+
+ rtcs = m_mgr->getNaming()->string_to_component(rtc_name);
+
+ if (rtcs.length() > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}; //namespace RTM
+
+extern "C"
+{
+ void NamingServiceNumberingPolicyInit()
+ {
+ ::RTM::NumberingPolicyFactory::
+ instance().addFactory("ns_unique",
+ ::coil::Creator< ::RTM::NumberingPolicyBase,
+ ::RTM::NamingServiceNumberingPolicy>,
+ ::coil::Destructor< ::RTM::NumberingPolicyBase,
+ ::RTM::NamingServiceNumberingPolicy>);
+ }
+};
+
Copied: trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.h (from rev 3160, branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.h)
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/NamingServiceNumberingPolicy.h 2018-03-28 01:52:25 UTC (rev 3259)
@@ -0,0 +1,173 @@
+// -*- C++ -*-
+/*!
+ * @file NamingServiceNumberingPolicy.h
+ * @brief Object numbering policy class
+ * @date $Date: 2018-1-11 03:08:04 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2018
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_NAMINGSERVICENUMBERINGPOLICY_H
+#define RTC_NAMINGSERVICENUMBERINGPOLICY_H
+
+#include <string>
+#include <vector>
+#include <rtm/RTC.h>
+#include <rtm/NumberingPolicyBase.h>
+#include <rtm/Manager.h>
+
+namespace RTM
+{
+ /*!
+ * @if jp
+ *
+ * @class NamingServiceNumberingPolicy
+ * @brief オブジェクト生成時ネーミング・ポリシー(命名規則)管理用クラス
+ *
+ * ネーミングサービスからRTCを検索してナンバリングを行う
+ *
+ * @since 1.2.0
+ *
+ * @else
+ *
+ * @class NamingServiceNumberingPolicy
+ * @brief
+ *
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ class NamingServiceNumberingPolicy
+ : public NumberingPolicyBase
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ NamingServiceNumberingPolicy();
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * @else
+ *
+ * @brief Destractor
+ *
+ * @endif
+ */
+ virtual ~NamingServiceNumberingPolicy(void){};
+
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクト生成時の名称作成
+ *
+ * オブジェクト生成時の名称を生成する。
+ * 生成済みインスタンスの数に応じた名称を生成する。
+ *
+ * @param obj 名称生成対象オブジェクト
+ *
+ * @return 生成したオブジェクト名称
+ *
+ * @else
+ *
+ * @brief Create the name when creating object
+ *
+ * Create the name when creating object.
+ * Create the name corresponding to the number of generated instances.
+ *
+ * @param obj The target object for the name creation
+ *
+ * @return Names of the created object
+ *
+ * @endif
+ */
+ virtual std::string onCreate(void* obj);
+
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクト削除時の名称解放
+ *
+ * オブジェクト削除時に名称を解放する。
+ * オブジェクト削除時に生成済みインスタンス数を減算する。
+ *
+ * @param obj 名称解放対象オブジェクト
+ *
+ * @else
+ *
+ * @brief Delete the name when deleting object
+ *
+ * Delete the name when deleting object.
+ * Substract the generated number of instances when deleting the object.
+ *
+ * @param obj The target object for the name delete
+ *
+ * @endif
+ */
+ virtual void onDelete(void* obj);
+
+
+
+ protected:
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクトの検索
+ *
+ * 指定名のインスタンス名のRTCを検索し、
+ * 一致するRTCが存在する場合はTrueを返す
+ *
+ * @param name 検索対象オブジェクトの名前
+ *
+ * @return 判定
+ *
+ * @else
+ *
+ * @brief
+ *
+ *
+ * @param name
+ *
+ * @return
+ *
+ * @endif
+ */
+ virtual bool find(std::string name);
+
+ private:
+ int m_num;
+ std::vector<void*> m_objects;
+ RTC::Manager *m_mgr;
+ };
+}; // namespace RTM
+
+extern "C"
+{
+ void DLL_EXPORT NamingServiceNumberingPolicyInit();
+};
+
+#endif // RTC_NAMINGSERVICENUMBERINGPOLICY_H
Copied: trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.cpp (from rev 3160, branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.cpp)
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.cpp 2018-03-28 01:52:25 UTC (rev 3259)
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+/*!
+* @file NodeNumberingPolicy.cpp
+* @brief Object numbering policy class
+* @date $Date: 2018-1-11 03:08:04 $
+* @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+*
+* Copyright (C) 2018
+* Intelligent Systems Research Institute,
+* National Institute of
+* Advanced Industrial Science and Technology (AIST), Japan
+* All rights reserved.
+*
+*
+*/
+
+#include <rtm/NodeNumberingPolicy.h>
+#include <rtm/Manager.h>
+#include <coil/stringutil.h>
+#include <rtm/NamingManager.h>
+#include <rtm/RTObject.h>
+
+namespace RTM
+{
+ //============================================================
+ // NodeNumberingPolicy
+ //============================================================
+ NodeNumberingPolicy::NodeNumberingPolicy()
+ : m_num(0)
+ {
+ m_mgr = &RTC::Manager::instance();
+ }
+ /*!
+ * @if jp
+ * @brief オブジェクト生成時の名称作成
+ * @else
+ * @brief Create the name when creating objects
+ * @endif
+ */
+ std::string NodeNumberingPolicy::onCreate(void* obj)
+ {
+ int num = 0;
+ while (true)
+ {
+ std::string num_str = coil::otos<int>(num);
+ RTC::RTObject_impl *rtobj = (RTC::RTObject_impl *)obj;
+
+
+ std::string name = rtobj->getTypeName() + num_str;
+
+ if (!find(name))
+ {
+ return num_str;
+ }
+ else
+ {
+ num++;
+ }
+ }
+ return coil::otos<int>(num);
+ }
+
+ /*!
+ * @if jp
+ * @brief オブジェクト削除時の名称解放
+ * @else
+ * @brief Delete the name when deleting objects
+ * @endif
+ */
+ void NodeNumberingPolicy::onDelete(void* obj)
+ {
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクトの検索
+ *
+ * マスターマネージャ、およびスレーブマネージャに登録されたRTCを検索し、
+ * 名前が一致するRTCが存在する場合はTrueを返す
+ * このプロセスで起動したマネージャがマスターマネージャではなく、
+ * さらにマスターマネージャが1つも登録されていない場合はこのプロセスのマネージャから検索
+ *
+ * @param name 検索対象オブジェクトの名前
+ *
+ * @return 判定
+ *
+ * @else
+ *
+ * @brief
+ *
+ *
+ * @param name
+ *
+ * @return
+ *
+ * @endif
+ */
+ bool NodeNumberingPolicy::find(std::string name)
+ {
+ RTC::RTCList rtcs;
+ std::string rtc_name = "rtcloc://*/*/";
+ rtc_name += name;
+
+ rtcs = m_mgr->getNaming()->string_to_component(rtc_name);
+
+ if (rtcs.length() > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}; //namespace RTM
+
+extern "C"
+{
+ void NodeNumberingPolicyInit()
+ {
+ ::RTM::NumberingPolicyFactory::
+ instance().addFactory("node_unique",
+ ::coil::Creator< ::RTM::NumberingPolicyBase,
+ ::RTM::NodeNumberingPolicy>,
+ ::coil::Destructor< ::RTM::NumberingPolicyBase,
+ ::RTM::NodeNumberingPolicy>);
+ }
+};
+
Copied: trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.h (from rev 3160, branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.h)
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/rtm/NodeNumberingPolicy.h 2018-03-28 01:52:25 UTC (rev 3259)
@@ -0,0 +1,174 @@
+// -*- C++ -*-
+/*!
+* @file NodeNumberingPolicy.h
+* @brief Object numbering policy class
+* @date $Date: 2018-1-11 03:08:04 $
+* @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+*
+* Copyright (C) 2018
+* Intelligent Systems Research Institute,
+* National Institute of
+* Advanced Industrial Science and Technology (AIST), Japan
+* All rights reserved.
+*
+*
+*/
+
+#ifndef RTC_NODENUMBERINGPOLICY_H
+#define RTC_NODENUMBERINGPOLICY_H
+
+#include <string>
+#include <vector>
+#include <rtm/RTC.h>
+#include <rtm/NumberingPolicyBase.h>
+#include <rtm/Manager.h>
+
+
+namespace RTM
+{
+ /*!
+ * @if jp
+ *
+ * @class NodeNumberingPolicy
+ * @brief オブジェクト生成時ネーミング・ポリシー(命名規則)管理用クラス
+ *
+ * マスターマネージャ、スレーブマネージャからRTCを検索してナンバリングを行う
+ *
+ * @since 1.2.0
+ *
+ * @else
+ *
+ * @class NodeNumberingPolicy
+ * @brief Class for naming policy management when creating objects
+ *
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ class NodeNumberingPolicy
+ : public NumberingPolicyBase
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ NodeNumberingPolicy();
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * @else
+ *
+ * @brief Destractor
+ *
+ * @endif
+ */
+ virtual ~NodeNumberingPolicy(void){};
+
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクト生成時の名称作成
+ *
+ * オブジェクト生成時の名称を生成する。
+ * 生成済みインスタンスの数に応じた名称を生成する。
+ *
+ * @param obj 名称生成対象オブジェクト
+ *
+ * @return 生成したオブジェクト名称
+ *
+ * @else
+ *
+ * @brief Create the name when creating object
+ *
+ * Create the name when creating object.
+ * Create the name corresponding to the number of generated instances.
+ *
+ * @param obj The target object for the name creation
+ *
+ * @return Names of the created object
+ *
+ * @endif
+ */
+ virtual std::string onCreate(void* obj);
+
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクト削除時の名称解放
+ *
+ * オブジェクト削除時に名称を解放する。
+ * オブジェクト削除時に生成済みインスタンス数を減算する。
+ *
+ * @param obj 名称解放対象オブジェクト
+ *
+ * @else
+ *
+ * @brief Delete the name when deleting object
+ *
+ * Delete the name when deleting object.
+ * Substract the generated number of instances when deleting the object.
+ *
+ * @param obj The target object for the name delete
+ *
+ * @endif
+ */
+ virtual void onDelete(void* obj);
+
+ protected:
+ /*!
+ * @if jp
+ *
+ * @brief オブジェクトの検索
+ *
+ * マスターマネージャ、およびスレーブマネージャに登録されたRTCを検索し、
+ * 名前が一致するRTCが存在する場合はTrueを返す
+ * このプロセスで起動したマネージャがマスターマネージャではなく、
+ * さらにマスターマネージャが1つも登録されていない場合はこのプロセスのマネージャから検索
+ *
+ * @param name 検索対象オブジェクトの名前
+ *
+ * @return 判定
+ *
+ * @else
+ *
+ * @brief
+ *
+ *
+ * @param name
+ *
+ * @return
+ *
+ * @endif
+ */
+ virtual bool find(std::string name);
+
+ private:
+ int m_num;
+ std::vector<void*> m_objects;
+ RTC::Manager *m_mgr;
+ };
+}; // namespace RTM
+
+extern "C"
+{
+ void DLL_EXPORT NodeNumberingPolicyInit();
+};
+
+#endif // RTC_NODENUMBERINGPOLICY_H
Modified: trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicy.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicy.h 2018-03-27 05:20:02 UTC (rev 3258)
+++ trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicy.h 2018-03-28 01:52:25 UTC (rev 3259)
@@ -30,7 +30,7 @@
/*!
* @if jp
*
- * @class DefaultNumberingPolicy
+ * @class ProcessUniquePolicy
* @brief ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®»þ¥Í¡¼¥ß¥ó¥°¡¦¥Ý¥ê¥·¡¼(̿̾µ¬Â§)´ÉÍýÍÑ¥¯¥é¥¹
*
* ¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ëºÝ¤Î¥Í¡¼¥ß¥ó¥°¡¦¥Ý¥ê¥·¡¼(̿̾µ¬Â§)¤ò´ÉÍý¤¹¤ë¤¿¤á¤Î
@@ -40,7 +40,7 @@
*
* @else
*
- * @class DefaultNumberingPolicy
+ * @class ProcessUniquePolicy
* @brief Class for naming policy management when creating objects
*
* This is a class to manage the naming policy when creating objects.
Modified: trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicyBase.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicyBase.cpp 2018-03-27 05:20:02 UTC (rev 3258)
+++ trunk/OpenRTM-aist/src/lib/rtm/NumberingPolicyBase.cpp 2018-03-28 01:52:25 UTC (rev 3259)
@@ -20,70 +20,5 @@
#include <rtm/NumberingPolicy.h>
#include <coil/stringutil.h>
-//============================================================
-// DefaultNumberingPolicy
-//============================================================
-/*!
- * @if jp
- * @brief ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®»þ¤Î̾¾ÎºîÀ®
- * @else
- * @brief Create the name when creating objects
- * @endif
- */
-std::string DefaultNumberingPolicy::onCreate(void* obj)
-{
- std::vector<void*>::size_type pos;
-
- ++m_num;
-
- try
- {
- pos = find(NULL);
- m_objects[pos] = obj;
- return coil::otos(pos);
- }
- catch (ObjectNotFound& e)
- {
- (void)(e);
- m_objects.push_back(obj);
- return coil::otos((int)(m_objects.size() - 1));
- }
-}
-/*!
- * @if jp
- * @brief ¥ª¥Ö¥¸¥§¥¯¥Èºï½ü»þ¤Î̾¾Î²òÊü
- * @else
- * @brief Delete the name when deleting objects
- * @endif
- */
-void DefaultNumberingPolicy::onDelete(void* obj)
-{
- std::vector<void*>::size_type pos;
- pos = find(obj);
- if (pos < m_objects.size())
- {
- m_objects[pos] = NULL;
- }
- --m_num;
-}
-/*!
- * @if jp
- * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î¸¡º÷
- * @else
- * @brief Find the object
- * @endif
- */
-long int DefaultNumberingPolicy::find(void* obj)
-{
- std::vector<void*>::size_type len(m_objects.size());
- std::vector<void*>::size_type i(0);
- for (i = 0; i < len; ++i)
- {
- if (m_objects[i] == obj) return i;
- }
- throw ObjectNotFound();
- return i;
-}
-
openrtm-commit メーリングリストの案内