[openrtm-commit:01574] r2641 - trunk/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2015年 6月 29日 (月) 09:22:56 JST


Author: n-ando
Date: 2015-06-29 09:22:55 +0900 (Mon, 29 Jun 2015)
New Revision: 2641

Modified:
   trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.cpp
   trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.h
Log:
[incompat,new_member] Now ConnectorListener and ConnectorDataListener have new size() function and typed notify function. refs #3242

Modified: trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.cpp	2015-06-26 07:53:58 UTC (rev 2640)
+++ trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.cpp	2015-06-29 00:22:55 UTC (rev 2641)
@@ -92,6 +92,11 @@
     
   }
 
+  size_t ConnectorDataListenerHolder::size()
+  {
+    Guard guard(m_mutex);
+    return m_listeners.size();
+  }
     
   void ConnectorDataListenerHolder::notify(const ConnectorInfo& info,
                                            const cdrMemoryStream& cdrdata)
@@ -157,6 +162,11 @@
     
   }
   
+  size_t ConnectorListenerHolder::size()
+  {
+    Guard guard(m_mutex);
+    return m_listeners.size();
+  }
   
   void ConnectorListenerHolder::notify(const ConnectorInfo& info)
   {

Modified: trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.h	2015-06-26 07:53:58 UTC (rev 2640)
+++ trunk/OpenRTM-aist/src/lib/rtm/ConnectorListener.h	2015-06-29 00:22:55 UTC (rev 2641)
@@ -668,6 +668,25 @@
     /*!
      * @if jp
      *
+     * @brief リスナーの数を得る
+     *
+     * 現在登録されているリスナー数を得る。
+     *
+     * @return listener数
+     * @else
+     *
+     * @brief Getting number of listeners.
+     *
+     * This method returns current number of listenrs.
+     *
+     * @return number of listeners
+     * @endif
+     */
+    size_t size();
+
+    /*!
+     * @if jp
+     *
      * @brief リスナーへ通知する
      *
      * 登録されているリスナのコールバックメソッドを呼び出す。
@@ -686,7 +705,44 @@
      */
     void notify(const ConnectorInfo& info,
                 const cdrMemoryStream& cdrdata);
-    
+
+    /*!
+     * @if jp
+     *
+     * @brief リスナーへ通知する(データ型指定版)
+     *
+     * 登録されているリスナのコールバックメソッドを呼び出す。
+     * COnnectorDataListenerT 型のコールバックのみコールされる。
+     *
+     * @param info ConnectorInfo
+     * @param typeddata データ(データ型指定あり)
+     * @else
+     *
+     * @brief Notify listeners. (Typed data version)
+     *
+     * This calls the Callback method of the registered listener.
+     * This operation calls only ConnectorDataListenerT type callback.
+     *
+     * @param info ConnectorInfo
+     * @param typeddata Data
+     * @endif
+     */
+    template <class DataType>
+    void notify(const ConnectorInfo& info, const DataType& typeddata)
+    {
+      Guard guard(m_mutex);
+      for (int i(0), len(m_listeners.size()); i < len; ++i)
+        {
+          ConnectorDataListenerT<DataType>* listener(0);
+          listener =
+          dynamic_cast<ConnectorDataListenerT<DataType>*>(m_listeners[i].first);
+          if (listener != 0)
+            {
+              listener->operator()(info, typeddata);
+            }
+        }
+    }
+
   private:
     std::vector<Entry> m_listeners;
     coil::Mutex m_mutex;
@@ -776,6 +832,25 @@
     /*!
      * @if jp
      *
+     * @brief リスナーの数を得る
+     *
+     * 現在登録されているリスナー数を得る。
+     *
+     * @return listener数
+     * @else
+     *
+     * @brief Getting number of listeners.
+     *
+     * This method returns current number of listenrs.
+     *
+     * @return number of listeners
+     * @endif
+     */
+    size_t size();
+
+    /*!
+     * @if jp
+     *
      * @brief リスナーへ通知する
      *
      * 登録されているリスナのコールバックメソッドを呼び出す。



More information about the openrtm-commit mailing list