[openrtm-commit:03114] r3189 - branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2018年 1月 23日 (火) 16:55:16 JST


Author: miyamoto
Date: 2018-01-23 16:55:15 +0900 (Tue, 23 Jan 2018)
New Revision: 3189

Modified:
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.h
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NamingManager.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortBase.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.h
Log:
[compat, ->RELENG_1_2] refs #4428

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h	2018-01-23 07:55:15 UTC (rev 3189)
@@ -325,6 +325,52 @@
       m_directNewData = true;
     }
 
+
+
+	bool getDirectData(InPortConnector *con, DataType &data)
+	{
+		OutPortBase *directOutPort = con->getOutPort();
+		ConnectorListeners& listeners = con->getListeners();
+		ConnectorListeners* outPortListeners = con->getOutportListeners();
+		ConnectorInfo& profile = con->profile();
+
+		if (directOutPort == NULL)
+		{
+			return false;
+		}
+		OutPort<DataType>* outport;
+		outport = static_cast<OutPort<DataType>*>(directOutPort);
+
+
+		if (outport->isEmpty())
+		{
+			listeners.
+				connector_[ON_BUFFER_EMPTY].notify(profile);
+			outPortListeners->
+				connector_[ON_SENDER_EMPTY].notify(profile);
+			RTC_PARANOID(("ON_BUFFER_EMPTY(InPort,OutPort), "
+				"ON_SENDER_EMPTY(InPort,OutPort) "
+				"callback called in direct mode."));
+		}
+		outport->read(data);
+		outPortListeners->connectorData_[ON_BUFFER_READ].notify(profile, data);
+		RTC_TRACE(("ON_BUFFER_READ(OutPort), "));
+		RTC_TRACE(("callback called in direct mode."));
+		outPortListeners->connectorData_[ON_SEND].notify(profile, data);
+		RTC_TRACE(("ON_SEND(OutPort), "));
+		RTC_TRACE(("callback called in direct mode."));
+		listeners.connectorData_[ON_RECEIVED].notify(profile, data);
+		RTC_TRACE(("ON_RECEIVED(InPort), "));
+		RTC_TRACE(("callback called in direct mode."));
+		listeners.connectorData_[ON_SEND].notify(profile, data);
+		RTC_TRACE(("ON_BUFFER_WRITE(InPort), "));
+		RTC_TRACE(("callback called in direct mode."));
+
+
+		return true;
+
+	};
+
     /*!
      * @if jp
      *
@@ -438,7 +484,7 @@
         
       }
 
-	  if (!m_connectors[0]->getDirectData(m_value))
+	  if (!getDirectData(m_connectors[0], m_value))
 	  {
 		  {
 			  Guard guard(m_connectorsMutex);

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.cpp	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.cpp	2018-01-23 07:55:15 UTC (rev 3189)
@@ -61,7 +61,7 @@
    *
    * @endif
    */
-  const ConnectorInfo& InPortConnector::profile()
+  ConnectorInfo& InPortConnector::profile()
   {
     RTC_TRACE(("profile()"));
     return m_profile;
@@ -169,4 +169,18 @@
 	  }
   };
 
+
+  OutPortBase* InPortConnector::getOutPort()
+  {
+	  return m_directOutPort;
+  }
+  ConnectorListeners& InPortConnector::getListeners()
+  {
+	  return m_listeners;
+  }
+  ConnectorListeners* InPortConnector::getOutportListeners()
+  {
+	  return m_outPortListeners;
+  }
+
 }; // namespace RTC

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.h	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.h	2018-01-23 07:55:15 UTC (rev 3189)
@@ -96,7 +96,7 @@
      *
      * @endif
      */
-    virtual const ConnectorInfo& profile();
+    virtual ConnectorInfo& profile();
 
     /*!
      * @if jp
@@ -254,45 +254,11 @@
 	*/
 	bool setOutPort(OutPortBase* directOutPort);
 
-	template <typename DataType>
-	bool getDirectData(DataType &data)
-	{
-		if (m_directOutPort == NULL)
-		{
-			return false;
-		}
-		OutPort<DataType>* outport;
-		outport = static_cast<OutPort<DataType>*>(m_directOutPort);
-		
-		
-		if (outport->isEmpty())
-		{
-			m_listeners.
-				connector_[ON_BUFFER_EMPTY].notify(m_profile);
-			m_outPortListeners->
-				connector_[ON_SENDER_EMPTY].notify(m_profile);
-			RTC_PARANOID(("ON_BUFFER_EMPTY(InPort,OutPort), "
-				"ON_SENDER_EMPTY(InPort,OutPort) "
-				"callback called in direct mode."));
-		}
-		outport->read(data);
-		m_outPortListeners->connectorData_[ON_BUFFER_READ].notify(m_profile, data);
-		RTC_TRACE(("ON_BUFFER_READ(OutPort), "));
-		RTC_TRACE(("callback called in direct mode."));
-		m_outPortListeners->connectorData_[ON_SEND].notify(m_profile, data);
-		RTC_TRACE(("ON_SEND(OutPort), "));
-		RTC_TRACE(("callback called in direct mode."));
-		m_listeners.connectorData_[ON_RECEIVED].notify(m_profile, data);
-		RTC_TRACE(("ON_RECEIVED(InPort), "));
-		RTC_TRACE(("callback called in direct mode."));
-		m_listeners.connectorData_[ON_SEND].notify(m_profile, data);
-		RTC_TRACE(("ON_BUFFER_WRITE(InPort), "));
-		RTC_TRACE(("callback called in direct mode."));
-		
 
-		return true;
 
-	};
+	virtual OutPortBase* getOutPort();
+	virtual ConnectorListeners& getListeners();
+	virtual ConnectorListeners* getOutportListeners();
 
   protected:
     /*!

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NamingManager.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NamingManager.cpp	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/NamingManager.cpp	2018-01-23 07:55:15 UTC (rev 3189)
@@ -429,7 +429,7 @@
 					 
 					  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++)
+					  for (unsigned int i = 0; i < slaves->length(); i++)
 					  {
 						  
 						  try

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h	2018-01-23 07:55:15 UTC (rev 3189)
@@ -165,6 +165,55 @@
     virtual ~OutPort(void)
     {
     }
+
+	ReturnCode write(OutPortConnector *con, DataType& data)
+	{
+		InPortBase* directInPort = con->getInPort();
+		ConnectorListeners &listeners = con->getListeners();
+		ConnectorListeners *inPortListeners = con->getInportListeners();
+		ConnectorInfo& profile = con->profile();
+
+		if (directInPort != NULL)
+		{
+			InPort<DataType>* inport;
+			inport = static_cast<InPort<DataType>*>(directInPort);
+			if (inport->isNew())
+			{
+				// ON_BUFFER_OVERWRITE(In,Out), ON_RECEIVER_FULL(In,Out) callback
+				listeners.
+					connectorData_[ON_BUFFER_OVERWRITE].notify(profile, data);
+				inPortListeners->
+					connectorData_[ON_BUFFER_OVERWRITE].notify(profile, data);
+				listeners.
+					connectorData_[ON_RECEIVER_FULL].notify(profile, data);
+				inPortListeners->
+					connectorData_[ON_RECEIVER_FULL].notify(profile, data);
+				RTC_PARANOID(("ON_BUFFER_OVERWRITE(InPort,OutPort), "
+					"ON_RECEIVER_FULL(InPort,OutPort) "
+					"callback called in direct mode."));
+			}
+			// ON_BUFFER_WRITE(In,Out) callback
+			listeners.
+				connectorData_[ON_BUFFER_WRITE].notify(profile, data);
+			inPortListeners->
+				connectorData_[ON_BUFFER_WRITE].notify(profile, data);
+			RTC_PARANOID(("ON_BUFFER_WRITE(InPort,OutPort), "
+				"callback called in direct mode."));
+			inport->write(data); // write to InPort variable!!
+			// ON_RECEIVED(In,Out) callback
+			listeners.
+				connectorData_[ON_RECEIVED].notify(profile, data);
+			inPortListeners->
+				connectorData_[ON_RECEIVED].notify(profile, data);
+			RTC_PARANOID(("ON_RECEIVED(InPort,OutPort), "
+				"callback called in direct mode."));
+			return PORT_OK;
+		}
+		else
+		{
+			return con->write(data);
+		}
+	}
     
     /*!
      * @if jp
@@ -232,17 +281,17 @@
           {
 
             ReturnCode ret;
-			if (!m_connectors[i]->directMode())
+			if (!m_connectors[i]->pullDirectMode())
 			{
 				if (m_onWriteConvert != NULL)
 				{
 					RTC_DEBUG(("m_connectors.OnWriteConvert called"));
-					ret = m_connectors[i]->write(((*m_onWriteConvert)(value)));
+					ret = write(m_connectors[i], ((*m_onWriteConvert)(value)));
 				}
 				else
 				{
 					RTC_DEBUG(("m_connectors.write called"));
-					ret = m_connectors[i]->write(value);
+					ret = write(m_connectors[i], value);
 				}
 			}
 			else

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortBase.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortBase.cpp	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortBase.cpp	2018-01-23 07:55:15 UTC (rev 3189)
@@ -1052,7 +1052,7 @@
 
 		if (coil::normalize(prop["interface_type"]) == "direct")
 		{
-			connector->setDirectMode();
+			connector->setPullDirectMode();
 		}
 
         m_connectors.push_back(connector);

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.cpp	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.cpp	2018-01-23 07:55:15 UTC (rev 3189)
@@ -59,7 +59,7 @@
    *
    * @endif
    */
-  const ConnectorInfo& OutPortConnector::profile()
+  ConnectorInfo& OutPortConnector::profile()
   {
     RTC_TRACE(("profile()"));
     return m_profile;
@@ -145,7 +145,7 @@
   *
   * @endif
   */
-  void OutPortConnector::setDirectMode()
+  void OutPortConnector::setPullDirectMode()
   {
 	  m_directMode = true;
   }
@@ -162,7 +162,7 @@
   *
   * @endif
   */
-  bool OutPortConnector::directMode()
+  bool OutPortConnector::pullDirectMode()
   {
 	  return m_directMode;
   }
@@ -177,4 +177,17 @@
 	  m_inPortListeners = &(m_directInPort->getListeners());
 	  return true;
   }
+
+  InPortBase* OutPortConnector::getInPort()
+  {
+	  return m_directInPort;
+  }
+  ConnectorListeners& OutPortConnector::getListeners()
+  {
+	  return m_listeners;
+  }
+  ConnectorListeners* OutPortConnector::getInportListeners()
+  {
+	  return m_inPortListeners;
+  }
 }; // namespace RTC

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.h	2018-01-23 06:50:19 UTC (rev 3188)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.h	2018-01-23 07:55:15 UTC (rev 3189)
@@ -85,7 +85,7 @@
      *
      * @endif
      */
-    const ConnectorInfo& profile();
+    ConnectorInfo& profile();
 
     /*!
      * @if jp
@@ -212,42 +212,7 @@
     template <class DataType>
     ReturnCode write(DataType& data)
     {
-      if (m_directInPort != NULL)
-        {
-          InPort<DataType>* inport;
-          inport = static_cast<InPort<DataType>*>(m_directInPort);
-          if (inport->isNew())
-            {
-              // ON_BUFFER_OVERWRITE(In,Out), ON_RECEIVER_FULL(In,Out) callback
-              m_listeners.
-                connectorData_[ON_BUFFER_OVERWRITE].notify(m_profile, data);
-              m_inPortListeners->
-                connectorData_[ON_BUFFER_OVERWRITE].notify(m_profile, data);
-              m_listeners.
-                connectorData_[ON_RECEIVER_FULL].notify(m_profile, data);
-              m_inPortListeners->
-                connectorData_[ON_RECEIVER_FULL].notify(m_profile, data);
-              RTC_PARANOID(("ON_BUFFER_OVERWRITE(InPort,OutPort), "
-                            "ON_RECEIVER_FULL(InPort,OutPort) "
-                            "callback called in direct mode."));
-            }
-          // ON_BUFFER_WRITE(In,Out) callback
-          m_listeners.
-            connectorData_[ON_BUFFER_WRITE].notify(m_profile, data);
-          m_inPortListeners->
-            connectorData_[ON_BUFFER_WRITE].notify(m_profile, data);
-          RTC_PARANOID(("ON_BUFFER_WRITE(InPort,OutPort), "
-                            "callback called in direct mode."));
-          inport->write(data); // write to InPort variable!!
-          // ON_RECEIVED(In,Out) callback
-          m_listeners.
-            connectorData_[ON_RECEIVED].notify(m_profile, data);
-          m_inPortListeners->
-            connectorData_[ON_RECEIVED].notify(m_profile, data);
-          RTC_PARANOID(("ON_RECEIVED(InPort,OutPort), "
-                        "callback called in direct mode."));
-          return PORT_OK;
-        }
+ 
       // normal case
       m_cdr.rewindPtrs();
       RTC_TRACE(("connector endian: %s", isLittleEndian() ? "little":"big"));
@@ -268,7 +233,7 @@
 	*
 	* @endif
 	*/
-	virtual void setDirectMode();
+	virtual void setPullDirectMode();
 	/*!
 	* @if jp
 	* @brief ¥À¥¤¥ì¥¯¥ÈÀܳ¥â¡¼¥É¤«¤ÎȽÄê
@@ -281,7 +246,11 @@
 	*
 	* @endif
 	*/
-	virtual bool directMode();
+	virtual bool pullDirectMode();
+	virtual InPortBase* getInPort();
+	virtual ConnectorListeners& getListeners();
+	virtual ConnectorListeners* getInportListeners();
+
   protected:
     /*!
      * @if jp



More information about the openrtm-commit mailing list