[openrtm-commit:03118] r3193 - branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2018年 1月 23日 (火) 17:41:59 JST


Author: miyamoto
Date: 2018-01-23 17:41:59 +0900 (Tue, 23 Jan 2018)
New Revision: 3193

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/OutPort.h
   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 08:35:59 UTC (rev 3192)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h	2018-01-23 08:41:59 UTC (rev 3193)
@@ -325,52 +325,6 @@
       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
      *
@@ -484,7 +438,7 @@
         
       }
 
-	  if (!getDirectData(m_connectors[0], m_value))
+	  if (!m_connectors[0]->getDirectData(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 08:35:59 UTC (rev 3192)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.cpp	2018-01-23 08:41:59 UTC (rev 3193)
@@ -61,7 +61,7 @@
    *
    * @endif
    */
-  ConnectorInfo& InPortConnector::profile()
+  const ConnectorInfo& InPortConnector::profile()
   {
     RTC_TRACE(("profile()"));
     return m_profile;
@@ -169,18 +169,4 @@
 	  }
   };
 
-
-  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 08:35:59 UTC (rev 3192)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.h	2018-01-23 08:41:59 UTC (rev 3193)
@@ -96,7 +96,7 @@
      *
      * @endif
      */
-    virtual ConnectorInfo& profile();
+    virtual const ConnectorInfo& profile();
 
     /*!
      * @if jp
@@ -254,11 +254,45 @@
 	*/
 	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/OutPort.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h	2018-01-23 08:35:59 UTC (rev 3192)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h	2018-01-23 08:41:59 UTC (rev 3193)
@@ -166,55 +166,6 @@
     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
@@ -287,12 +238,12 @@
 				if (m_onWriteConvert != NULL)
 				{
 					RTC_DEBUG(("m_connectors.OnWriteConvert called"));
-					ret = write(m_connectors[i], ((*m_onWriteConvert)(value)));
+					ret = m_connectors[i]->write(((*m_onWriteConvert)(value)));
 				}
 				else
 				{
 					RTC_DEBUG(("m_connectors.write called"));
-					ret = write(m_connectors[i], value);
+					ret = m_connectors[i]->write(value);
 				}
 			}
 			else

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 08:35:59 UTC (rev 3192)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.cpp	2018-01-23 08:41:59 UTC (rev 3193)
@@ -59,7 +59,7 @@
    *
    * @endif
    */
-  ConnectorInfo& OutPortConnector::profile()
+  const ConnectorInfo& OutPortConnector::profile()
   {
     RTC_TRACE(("profile()"));
     return m_profile;
@@ -177,17 +177,4 @@
 	  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 08:35:59 UTC (rev 3192)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.h	2018-01-23 08:41:59 UTC (rev 3193)
@@ -85,7 +85,7 @@
      *
      * @endif
      */
-    ConnectorInfo& profile();
+    const ConnectorInfo& profile();
 
     /*!
      * @if jp
@@ -212,7 +212,42 @@
     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"));
@@ -247,10 +282,6 @@
 	* @endif
 	*/
 	virtual bool pullDirectMode();
-	virtual InPortBase* getInPort();
-	virtual ConnectorListeners& getListeners();
-	virtual ConnectorListeners* getInportListeners();
-
   protected:
     /*!
      * @if jp



More information about the openrtm-commit mailing list