[openrtm-commit:03119] r3194 - branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 1月 23日 (火) 19:20:54 JST
Author: miyamoto
Date: 2018-01-23 19:20:54 +0900 (Tue, 23 Jan 2018)
New Revision: 3194
Added:
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectInPortBase.h
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectOutPortBase.h
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectPortBase.h
Modified:
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h
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.h
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.cpp
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.h
Log:
[compat, ->RELENG_1_2] refs #4428
Added: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectInPortBase.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectInPortBase.h (rev 0)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectInPortBase.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -0,0 +1,183 @@
+// -*- C++ -*-
+/*!
+ * @file DirectInPortBase.h
+ * @brief DirectInPortBase class
+ * @date $Date: 2018-1-23 03:08:05 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2018
+ * Nobuhiko Miyamoto
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_DIRECTINPORTBASE_H
+#define RTC_DIRECTINPORTBASE_H
+
+
+
+#include <coil/Mutex.h>
+
+
+
+namespace RTC
+{
+ /*!
+ * @if jp
+ * @class DirectInPortBase
+ * @brief direct接続用InPort基底クラス
+ *
+ *
+ * @since 1.2.0
+ *
+ * @else
+ * @class DirectOutPortBase
+ * @brief
+ *
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ template <class DataType>
+ class DirectInPortBase : public DirectPortBase
+ {
+ public:
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ *
+ * @param value
+ *
+ * @else
+ * @brief Constructor
+ *
+ * @param value
+ *
+ * @endif
+ */
+ DirectInPortBase(DataType& value):
+ m_directNewData(false), m_value(value)
+ {
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ *
+ *
+ * @else
+ * @brief Destructor
+ *
+ *
+ * @endif
+ */
+ virtual ~DirectInPortBase(void){};
+
+
+
+
+ /*!
+ * @if jp
+ *
+ * @brief 最新データが存在するか確認する
+ *
+ * InPortに未読の最新データが到着しているかをbool値で返す。
+ * InPortが未接続の場合、および接続コネクタのバッファがEmpty
+ * の場合にはfalseを返す。
+ *
+ * @return true 未読の最新データが存在する
+ * false 未接続またはバッファにデータが存在しない。
+ *
+ * @else
+ *
+ * @brief Check whether the data is newest
+ *
+ * Check whether the data stored at a current buffer position is newest.
+ *
+ * @return Newest data check result
+ * ( true:Newest data. Data has not been readout yet.
+ * false:Past data.Data has already been readout.)
+ *
+ * @endif
+ */
+ virtual bool isNew()
+ {
+ return m_directNewData;
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief バッファが空かどうか確認する
+ *
+ * InPortのバッファが空かどうかを bool 値で返す。
+ * 空の場合は true, 未読データがある場合は false を返す。
+ *
+ * @return true バッファは空
+ * false バッファに未読データがある
+ *
+ * @else
+ *
+ * @brief Check whether the data is newest
+ *
+ * Check whether the data stored at a current buffer position is newest.
+ *
+ * @return Newest data check result
+ * ( true:Newest data. Data has not been readout yet.
+ * false:Past data.Data has already been readout.)
+ *
+ * @endif
+ */
+ virtual bool isEmpty()
+ {
+ return !m_directNewData;
+ }
+
+ /*!
+ * @if jp
+ * @brief データの書き込み
+ *
+ * @param data データ
+ *
+ * @else
+ * @brief
+ *
+ * @param data
+ *
+ * @endif
+ */
+ virtual void write(const DataType& data)
+ {
+ }
+
+
+ protected:
+
+ /*!
+ * @if jp
+ * @brief バインドされる T 型の変数への参照
+ * @else
+ * @brief The reference to type-T value bound this OutPort
+ * @endif
+ */
+ DataType& m_value;
+ mutable coil::Mutex m_valueMutex;
+
+
+ /*!
+ * @if jp
+ * @brief ダイレクトデータ転送フラグ
+ * @else
+ * @brief A flag for direct data transfer
+ * @endif
+ */
+ bool m_directNewData;
+ };
+}; // End of namesepace RTM
+
+#endif // RTC_DIRECTINPORTBASE_H
Added: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectOutPortBase.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectOutPortBase.h (rev 0)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectOutPortBase.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -0,0 +1,141 @@
+// -*- C++ -*-
+/*!
+ * @file DirectOutPortBase.h
+ * @brief DirectOutPortBase class
+ * @date $Date: 2018-1-23 03:08:05 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2018
+ * Nobuhiko Miyamoto
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_DIRECTOUTPORTBASE_H
+#define RTC_DIRECTOUTPORTBASE_H
+
+
+#include <coil/Mutex.h>
+#include <rtm/DirectPortBase.h>
+
+
+
+
+namespace RTC
+{
+ /*!
+ * @if jp
+ * @class DirectOutPortBase
+ * @brief directÚ±pOutPortîêNX
+ *
+ *
+ * @since 1.2.0
+ *
+ * @else
+ * @class DirectOutPortBase
+ * @brief
+ *
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ template <class DataType>
+ class DirectOutPortBase : public DirectPortBase
+ {
+ typedef coil::Guard<coil::Mutex> Guard;
+ public:
+ /*!
+ * @if jp
+ * @brief RXgN^
+ *
+ * @param value
+ *
+ * @else
+ * @brief Constructor
+ *
+ * @param value
+ *
+ * @endif
+ */
+ DirectOutPortBase(DataType& value):
+ m_directNewData(false), m_directValue(value)
+ {
+ }
+ /*!
+ * @if jp
+ * @brief fXgN^
+ *
+ *
+ * @else
+ * @brief Destructor
+ *
+ *
+ * @endif
+ */
+ virtual ~DirectOutPortBase(void)
+ {
+ }
+ /*!
+ * @if jp
+ * @brief f[^Ìæ¾
+ *
+ * @param data f[^ði[·éÏ
+ *
+ * @else
+ * @brief
+ *
+ * @param data
+ *
+ * @endif
+ */
+ virtual void read(DataType& data)
+ {
+ }
+ /*!
+ * @if jp
+ * @brief VKf[^̶ÝmF
+ *
+ * @return trueFVKf[^ è
+ *
+ * @else
+ * @brief
+ *
+ * @return
+ *
+ * @endif
+ */
+ virtual bool isNew()
+ {
+ return !m_directNewData;
+ }
+ /*!
+ * @if jp
+ * @brief VKf[^ª³¢±ÆðmF
+ *
+ * @return trueFVKf[^ȵ
+ *
+ * @else
+ * @brief
+ *
+ * @return
+ *
+ * @endif
+ */
+ virtual bool isEmpty()
+ {
+ return !m_directNewData;
+ }
+
+ protected:
+ coil::Mutex m_valueMutex;
+ bool m_directNewData;
+ DataType m_directValue;
+ };
+}; // namespace RTC
+
+#endif // RTC_DIRECTOUTPORTBASE_H
Added: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectPortBase.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectPortBase.h (rev 0)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DirectPortBase.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+/*!
+ * @file DirectPortBase.h
+ * @brief DirectPortBase class
+ * @date $Date: 2018-1-23 03:08:05 $
+ * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ *
+ * Copyright (C) 2018
+ * Nobuhiko Miyamoto
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ *
+ */
+
+#ifndef RTC_DIRECTPORTBASE_H
+#define RTC_DIRECTPORTBASE_H
+
+
+
+
+
+
+
+namespace RTC
+{
+ /*!
+ * @if jp
+ * @class DirectPortBase
+ * @brief directÚ±pPortîêNX
+ *
+ *
+ * @since 1.2.0
+ *
+ * @else
+ * @class DirectPortBase
+ * @brief
+ *
+ *
+ *
+ * @since 1.2.0
+ *
+ * @endif
+ */
+ class DirectPortBase
+ {
+ public:
+ /*!
+ * @if jp
+ * @brief RXgN^
+ *
+ *
+ * @else
+ * @brief Constructor
+ *
+ *
+ * @endif
+ */
+ DirectPortBase(){};
+
+ /*!
+ * @if jp
+ * @brief fXgN^
+ *
+ *
+ * @else
+ * @brief Destructor
+ *
+ *
+ * @endif
+ */
+ virtual ~DirectPortBase(void){};
+
+
+
+ };
+}; // End of namesepace RTM
+
+#endif // RTC_DIRECTINPORTBASE_H
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:41:59 UTC (rev 3193)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPort.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -37,7 +37,10 @@
#include <rtm/PortCallback.h>
#include <rtm/InPortConnector.h>
#include <rtm/Timestamp.h>
+#include <rtm/DirectInPortBase.h>
+
+
namespace RTC
{
/*!
@@ -90,7 +93,7 @@
*/
template <class DataType>
class InPort
- : public InPortBase
+ : public InPortBase, DirectInPortBase<DataType>
{
public:
DATAPORTSTATUS_ENUM
@@ -154,14 +157,16 @@
#else
: InPortBase(name, ::CORBA_Util::toRepositoryId<DataType>()),
#endif
- m_name(name), m_value(value),
+ DirectInPortBase<DataType>(value),
+ m_name(name),
m_OnRead(NULL), m_OnReadConvert(NULL),
- m_status(1), m_directNewData(false)
+ m_status(1)
{
this->addConnectorDataListener(ON_RECEIVED,
new Timestamp<DataType>("on_received"));
this->addConnectorDataListener(ON_BUFFER_READ,
new Timestamp<DataType>("on_read"));
+ m_directport = this;
}
/*!
@@ -671,15 +676,7 @@
*/
std::string m_name;
- /*!
- * @if jp
- * @brief ¥Ð¥¤¥ó¥É¤µ¤ì¤ë T ·¿¤ÎÊÑ¿ô¤Ø¤Î»²¾È
- * @else
- * @brief The reference to type-T value bound this OutPort
- * @endif
- */
- DataType& m_value;
- mutable coil::Mutex m_valueMutex;
+
/*!
* @if jp
@@ -708,14 +705,7 @@
*/
DataPortStatusList m_status;
- /*!
- * @if jp
- * @brief ¥À¥¤¥ì¥¯¥È¥Ç¡¼¥¿Å¾Á÷¥Õ¥é¥°
- * @else
- * @brief A flag for direct data transfer
- * @endif
- */
- bool m_directNewData;
+
};
}; // End of namesepace RTM
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:41:59 UTC (rev 3193)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/InPortConnector.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -22,6 +22,7 @@
#include <rtm/ConnectorListener.h>
#include <rtm/ConnectorBase.h>
+#include <rtm/DirectOutPortBase.h>
namespace RTC
@@ -261,8 +262,8 @@
{
return false;
}
- OutPort<DataType>* outport;
- outport = static_cast<OutPort<DataType>*>(m_directOutPort);
+ DirectOutPortBase<DataType>* outport;
+ outport = static_cast<DirectOutPortBase<DataType>*>(m_directOutPort->getDirectPort());
if (outport->isEmpty())
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:41:59 UTC (rev 3193)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPort.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -35,6 +35,7 @@
#include <rtm/PortCallback.h>
#include <rtm/OutPortConnector.h>
#include <rtm/Timestamp.h>
+#include <rtm/DirectOutPortBase.h>
/*!
* @if jp
@@ -105,7 +106,7 @@
*/
template <class DataType>
class OutPort
- : public OutPortBase
+ : public OutPortBase, DirectOutPortBase<DataType>
{
typedef coil::Guard<coil::Mutex> Guard;
public:
@@ -138,7 +139,8 @@
#else
: OutPortBase(name, ::CORBA_Util::toRepositoryId<DataType>()),
#endif
- m_value(value), m_onWrite(0), m_onWriteConvert(0), m_directNewData(false)
+ DirectOutPortBase<DataType>(value),
+ m_value(value), m_onWrite(0), m_onWriteConvert(0)
{
this->addConnectorDataListener(ON_BUFFER_WRITE,
@@ -145,6 +147,7 @@
new Timestamp<DataType>("on_write"));
this->addConnectorDataListener(ON_SEND,
new Timestamp<DataType>("on_send"));
+ m_directport = this;
}
@@ -503,16 +506,20 @@
*
* @endif
*/
- void read(DataType& data)
+ virtual void read(DataType& data)
{
Guard guard(m_valueMutex);
m_directNewData = false;
data = m_directValue;
}
- bool isEmpty()
+ virtual bool isEmpty()
{
return !m_directNewData;
}
+ virtual bool isNew()
+ {
+ return m_directNewData;
+ }
private:
std::string m_typename;
@@ -549,9 +556,7 @@
CORBA::Long m_propValueIndex;
- coil::Mutex m_valueMutex;
- bool m_directNewData;
- DataType m_directValue;
+
};
}; // 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:41:59 UTC (rev 3193)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/OutPortConnector.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -23,6 +23,7 @@
#include <rtm/SystemLogger.h>
#include <rtm/ConnectorBase.h>
#include <rtm/ConnectorListener.h>
+#include <rtm/DirectInPortBase.h>
@@ -214,8 +215,8 @@
{
if (m_directInPort != NULL)
{
- InPort<DataType>* inport;
- inport = static_cast<InPort<DataType>*>(m_directInPort);
+ DirectInPortBase<DataType>* inport = static_cast<DirectInPortBase<DataType>*>(m_directInPort->getDirectPort());
+
if (inport->isNew())
{
// ON_BUFFER_OVERWRITE(In,Out), ON_RECEIVER_FULL(In,Out) callback
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.cpp 2018-01-23 08:41:59 UTC (rev 3193)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.cpp 2018-01-23 10:20:54 UTC (rev 3194)
@@ -46,7 +46,8 @@
m_onUnsubscribeInterfaces(0),
m_onDisconnected(0),
m_onConnectionLost(0),
- m_portconnListeners(NULL)
+ m_portconnListeners(NULL),
+ m_directport(NULL)
{
m_objref = this->_this();
// Now Port name is <instance_name>.<port_name>. r1648
@@ -982,4 +983,26 @@
return true;
}
+
+
+
+
+ /*!
+ * @if jp
+ * @brief directÄÌ¿®Íѥݡ¼¥È¥ª¥Ö¥¸¥§¥¯¥È¼èÆÀ
+ *
+ * @return ¥Ý¡¼¥È¤Î¥Ý¥¤¥ó¥¿
+ *
+ * @else
+ * @brief
+ *
+ * @return
+ *
+ * @endif
+ */
+ DirectPortBase* PortBase::getDirectPort()
+ {
+ return m_directport;
+ }
+
}; // namespace RTC
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.h 2018-01-23 08:41:59 UTC (rev 3193)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/PortBase.h 2018-01-23 10:20:54 UTC (rev 3194)
@@ -32,6 +32,7 @@
#include <rtm/SystemLogger.h>
#include <rtm/PortConnectListener.h>
#include <iostream>
+#include <rtm/DirectPortBase.h>
#ifdef WIN32
#pragma warning( disable : 4290 )
@@ -1272,6 +1273,20 @@
*/
void setPortConnectListenerHolder(PortConnectListeners* portconnListeners);
+ /*!
+ * @if jp
+ * @brief directÄÌ¿®Íѥݡ¼¥È¥ª¥Ö¥¸¥§¥¯¥È¼èÆÀ
+ *
+ * @return ¥Ý¡¼¥È¤Î¥Ý¥¤¥ó¥¿
+ *
+ * @else
+ * @brief
+ *
+ * @return
+ *
+ * @endif
+ */
+ virtual DirectPortBase* getDirectPort();
//============================================================
// protected operations
//============================================================
@@ -2217,6 +2232,8 @@
*/
PortConnectListeners* m_portconnListeners;
+ DirectPortBase *m_directport;
+
//============================================================
// Functor
//============================================================
More information about the openrtm-commit
mailing list