[openrtm-commit:00318] r529 - in branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . port
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 8月 5日 (金) 16:35:03 JST
Author: fsi-katami
Date: 2011-08-05 16:35:03 +0900 (Fri, 05 Aug 2011)
New Revision: 529
Modified:
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListener.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerArgument.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerHolder.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListener.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerArgument.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerHolder.java
Log:
Implemented of PortConnect listener. refs #2048
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -36,6 +36,7 @@
import OpenRTM.DataFlowComponentHelper;
import OpenRTM.DataFlowComponentPOA;
import RTC.ComponentProfile;
+import RTC.ConnectorProfile;
import RTC.ExecutionContext;
import RTC.ExecutionContextHelper;
import RTC.ExecutionContextListHolder;
@@ -5026,37 +5027,95 @@
portconnect_[listener_type].addObserver(listener);
}
}
-/*
- template <class Listener>
- PortConnectListener*
- addPortConnectListener(PortConnectListenerType listener_type,
- Listener& obj,
- void (Listener::*memfunc)(const char*,
- ConnectorProfile&))
- {
- class Noname
- : public PortConnectListener
- {
- public:
- Noname(Listener& obj,
- void (Listener::*memfunc)(const char*, ConnectorProfile&))
- : m_obj(obj), m_memfunc(memfunc)
- {
- }
- void operator()(const char* portname, ConnectorProfile& cprofile)
- {
- (m_obj.*m_memfunc)(portname, cprofile);
- }
- private:
- Listener& m_obj;
- typedef void (Listener::*Memfunc)(const char*, ConnectorProfile&);
- Memfunc m_memfunc;
- };
- Noname* listener(new Noname(obj, memfunc));
- addPortConnectListener(listener_type, listener, true);
- return listener;
+ /**
+ * {@.ja PortConnectListener リスナを追加する}
+ * {@.en Adding PortConnect type listener}
+ * <p>
+ * {@.ja Portの接続時や接続解除時に呼び出される各種リスナを設定する。
+ *
+ * 設定できるリスナのタイプとコールバックイベントは以下の通り
+ *
+ * - ON_NOTIFY_CONNECT: notify_connect() 関数内呼び出し直後
+ * - ON_NOTIFY_DISCONNECT: notify_disconnect() 呼び出し直後
+ * - ON_UNSUBSCRIBE_INTERFACES: notify_disconnect() 内のIF購読解除時
+ *
+ * リスナは PortConnectListener を継承し、以下のシグニチャを持つ
+ * operator() を実装している必要がある。
+ *
+ * PortConnectListener::operator()(const char*, ConnectorProfile)
+ *
+ * デフォルトでは、この関数に与えたリスナオブジェクトの所有権は
+ * RTObjectに移り、RTObject解体時もしくは、
+ * removePortConnectListener() により削除時に自動的に解体される。
+ * リスナオブジェクトの所有権を呼び出し側で維持したい場合は、第3引
+ * 数に false を指定し、自動的な解体を抑制することができる。}
+ * {@.en This operation adds certain listeners related to Port's connect
+ * actions.
+ * The following listener types are available.
+ *
+ * - ON_NOTIFY_CONNECT: right after entering into notify_connect()
+ * - ON_NOTIFY_DISCONNECT: right after entering into notify_disconnect()
+ * - ON_UNSUBSCRIBE_INTERFACES: unsubscribing IF in notify_disconnect()
+ *
+ * Listeners should have the following function operator().
+ *
+ * PortConnectListener::operator()(const char*, ConnectorProfile)
+ *
+ * The ownership of the given listener object is transferred to
+ * this RTObject object in default. The given listener object will
+ * be destroied automatically in the RTObject's dtor or if the
+ * listener is deleted by removePortConnectListener() function.
+ * If you want to keep ownership of the listener object, give
+ * "false" value to 3rd argument to inhibit automatic destruction.}
+ *
+ * @param listener_type
+ * {@.ja リスナタイプ}
+ * {@.en A listener type}
+ * @param obj
+ * {@.ja リスナオブジェクト}
+ * {@.en listener object}
+ * @param memfunc
+ * {@.ja リスナのmethod名}
+ * {@.en Method name of listener}
+ *
+ */
+ public <DataType>
+ PortConnectListener
+ addPortConnectListener(int listener_type,
+ DataType obj,
+ String memfunc) {
+ class Noname extends PortConnectListener {
+ public Noname(DataType obj, String memfunc) {
+ m_obj = obj;
+ try {
+ Class clazz = m_obj.getClass();
+
+ m_method = clazz.getMethod(memfunc,String.class,ConnectorProfile.class);
+
+ }
+ catch(java.lang.Exception e){
+ rtcout.println(Logbuf.WARN,
+ "Exception caught."+e.toString());
+ }
+ }
+ public void operator(final String portname, ConnectorProfile profile) {
+ try {
+ m_method.invoke(
+ m_obj,
+ portname,profile);
+ }
+ catch(java.lang.Exception e){
+ rtcout.println(Logbuf.WARN,
+ "Exception caught."+e.toString());
+ }
+ }
+ private DataType m_obj;
+ private Method m_method;
+ };
+ Noname listener = new Noname(obj, memfunc);
+ addPortConnectListener(listener_type, listener, true);
+ return listener;
}
-*/
/**
* {@.ja PortConnectListener リスナを削除する}
@@ -5206,46 +5265,103 @@
portconnret_[listener_type].addObserver(listener);
}
}
-/*
- template <class Listener>
- PortConnectRetListener*
- addPortConnectRetListener(PortConnectRetListenerType listener_type,
- Listener& obj,
- void (Listener::*memfunc)(const char*,
- ConnectorProfile&,
- ReturnCode_t))
- {
- class Noname
- : public PortConnectRetListener
- {
- public:
- Noname(Listener& obj,
- void (Listener::*memfunc)(const char*,
- ConnectorProfile&,
- ReturnCode_t))
- : m_obj(obj), m_memfunc(memfunc)
- {
- }
- void operator()(const char* portname,
- ConnectorProfile& cprofile,
- ReturnCode_t ret)
- {
- (m_obj.*m_memfunc)(portname, cprofile, ret);
- }
- private:
- Listener& m_obj;
- typedef void (Listener::*Memfunc)(const char* portname,
- ConnectorProfile& cprofile,
- ReturnCode_t ret);
- Memfunc m_memfunc;
- };
- Noname* listener(new Noname(obj, memfunc));
- addPortConnectRetListener(listener_type, listener, true);
- return listener;
- }
-*/
/**
+ * {@.ja PortConnectRetListener リスナを追加する}
+ * {@.en Adding PortConnectRet type listener}
+ * <p>
+ * {@.ja Portの接続時や接続解除時に呼び出される各種リスナを設定する。
+ *
+ * 設定できるリスナのタイプとコールバックイベントは以下の通り
+ *
+ * - ON_CONNECT_NEXTPORT: notify_connect() 中のカスケード呼び出し直後
+ * - ON_SUBSCRIBE_INTERFACES: notify_connect() 中のインターフェース購読直後
+ * - ON_CONNECTED: nofity_connect() 接続処理完了時に呼び出される
+ * - ON_DISCONNECT_NEXT: notify_disconnect() 中にカスケード呼び出し直後
+ * - ON_DISCONNECTED: notify_disconnect() リターン時
+ *
+ * リスナは PortConnectRetListener を継承し、以下のシグニチャを持つ
+ * operator() を実装している必要がある。
+ *
+ * PortConnectRetListener::operator()(const char*, ConnectorProfile)
+ *
+ * デフォルトでは、この関数に与えたリスナオブジェクトの所有権は
+ * RTObjectに移り、RTObject解体時もしくは、
+ * removePortConnectRetListener() により削除時に自動的に解体される。
+ * リスナオブジェクトの所有権を呼び出し側で維持したい場合は、第3引
+ * 数に false を指定し、自動的な解体を抑制することができる。}
+ * {@.en This operation adds certain listeners related to Port's connect
+ * actions.
+ * The following listener types are available.
+ *
+ * - ON_CONNECT_NEXTPORT: after cascade-call in notify_connect()
+ * - ON_SUBSCRIBE_INTERFACES: after IF subscribing in notify_connect()
+ * - ON_CONNECTED: completed nofity_connect() connection process
+ * - ON_DISCONNECT_NEXT: after cascade-call in notify_disconnect()
+ * - ON_DISCONNECTED: completed notify_disconnect() disconnection process
+ *
+ * Listeners should have the following function operator().
+ *
+ * PortConnectRetListener::operator()(const char*, ConnectorProfile)
+ *
+ * The ownership of the given listener object is transferred to
+ * this RTObject object in default. The given listener object will
+ * be destroied automatically in the RTObject's dtor or if the
+ * listener is deleted by removePortConnectRetListener() function.
+ * If you want to keep ownership of the listener object, give
+ * "false" value to 3rd argument to inhibit automatic destruction.}
+ *
+ * @param listener_type
+ * {@.ja リスナタイプ}
+ * {@.en A listener type}
+ * @param obj
+ * {@.ja リスナオブジェクト}
+ * {@.en listener object}
+ * @param memfunc
+ * {@.ja リスナのmethod名}
+ * {@.en Method name of listener}
+ *
+ */
+ public <DataType>
+ PortConnectRetListener
+ addPortConnectRetListener(int listener_type,
+ DataType obj,
+ String memfunc) {
+ class Noname extends PortConnectRetListener {
+ public Noname(DataType obj, String memfunc) {
+ m_obj = obj;
+ try {
+ Class clazz = m_obj.getClass();
+
+ m_method = clazz.getMethod(memfunc,String.class,ConnectorProfile.class,ReturnCode_t.class);
+
+ }
+ catch(java.lang.Exception e){
+ rtcout.println(Logbuf.WARN,
+ "Exception caught."+e.toString());
+ }
+ }
+ public void operator(final String portname,
+ ConnectorProfile profile,
+ ReturnCode_t ret) {
+ try {
+ m_method.invoke(
+ m_obj,
+ portname,profile,ret);
+ }
+ catch(java.lang.Exception e){
+ rtcout.println(Logbuf.WARN,
+ "Exception caught."+e.toString());
+ }
+ }
+ private DataType m_obj;
+ private Method m_method;
+ };
+ Noname listener = new Noname(obj, memfunc);
+ addPortConnectRetListener(listener_type, listener, true);
+ return listener;
+ }
+ /**
* {@.ja PortConnectRetListener リスナを削除する}
* {@.en Removing PortConnectRet type listener}
* <p>
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListener.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListener.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListener.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -1,5 +1,6 @@
package jp.go.aist.rtm.RTC.port;
+import java.util.Observable;
import java.util.Observer;
import RTC.ConnectorProfile;
@@ -23,7 +24,10 @@
*
*/
public abstract class PortConnectListener implements Observer{
-
+ public void update(Observable o, Object obj) {
+ PortConnectListenerArgument arg = (PortConnectListenerArgument)obj;
+ operator(arg.m_portname,arg.m_connector_profile);
+ }
/**
* {@.ja デストラクタ}
* {@.en Destructor}
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerArgument.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerArgument.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerArgument.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -1,6 +1,6 @@
package jp.go.aist.rtm.RTC.port;
-import RTC.ReturnCode_t;
+import RTC.ConnectorProfile;
/**
* {@.ja PortConnectListenerArgument クラス}
* {@.en PortConnectListenerArgument class}
@@ -13,13 +13,13 @@
* {@.en Constructor}
*
*/
- public PortConnectListenerArgument(final String config_set_name,
- final String config_param_name){
- m_config_set_name = config_set_name;
- m_config_param_name = config_param_name;
+ public PortConnectListenerArgument(final String portname,
+ final ConnectorProfile prof) {
+ m_portname = portname;
+ m_connector_profile = prof;
}
- public String m_config_set_name;
- public String m_config_param_name;
+ public String m_portname;
+ public ConnectorProfile m_connector_profile;
}
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerHolder.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerHolder.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListenerHolder.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -1,6 +1,8 @@
package jp.go.aist.rtm.RTC.port;
import java.util.Observable;
+
+import RTC.ConnectorProfile;
/**
* {@.ja PortConnectListener ホルダクラス}
* {@.en PortConnectListener holder class}
@@ -11,10 +13,10 @@
*
*/
public class PortConnectListenerHolder extends Observable{
- public void notify(final String config_set_name,final String config_param_name) {
+ public void notify(final String portname,final ConnectorProfile prof) {
super.setChanged();
PortConnectListenerArgument arg
- = new PortConnectListenerArgument(config_set_name,config_param_name);
+ = new PortConnectListenerArgument(portname,prof);
super.notifyObservers(arg);
super.clearChanged();
}
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListener.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListener.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListener.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -1,5 +1,6 @@
package jp.go.aist.rtm.RTC.port;
+import java.util.Observable;
import java.util.Observer;
import RTC.ConnectorProfile;
@@ -29,7 +30,10 @@
*
*/
public abstract class PortConnectRetListener implements Observer{
-
+ public void update(Observable o, Object obj) {
+ PortConnectRetListenerArgument arg = (PortConnectRetListenerArgument)obj;
+ operator(arg.m_portname,arg.m_connector_profile,arg.m_return_t);
+ }
/**
* {@.ja デストラクタ}
* {@.en Destructor}
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerArgument.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerArgument.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerArgument.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -1,5 +1,6 @@
package jp.go.aist.rtm.RTC.port;
+import RTC.ConnectorProfile;
import RTC.ReturnCode_t;
/**
* {@.ja PortConnectRetListenerArgument クラス}
@@ -13,13 +14,16 @@
* {@.en Constructor}
*
*/
- public PortConnectRetListenerArgument(final String config_set_name,
- final String config_param_name){
- m_config_set_name = config_set_name;
- m_config_param_name = config_param_name;
+ public PortConnectRetListenerArgument(final String portname,
+ final RTC.ConnectorProfile prof,
+ final ReturnCode_t ret){
+ m_portname = portname;
+ m_connector_profile = prof;
+ m_return_t = ret;
}
- public String m_config_set_name;
- public String m_config_param_name;
+ public String m_portname;
+ public RTC.ConnectorProfile m_connector_profile;
+ public ReturnCode_t m_return_t;
}
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerHolder.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerHolder.java 2011-08-05 06:25:52 UTC (rev 528)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectRetListenerHolder.java 2011-08-05 07:35:03 UTC (rev 529)
@@ -1,6 +1,9 @@
package jp.go.aist.rtm.RTC.port;
import java.util.Observable;
+
+import RTC.ConnectorProfile;
+import RTC.ReturnCode_t;
/**
* {@.ja PortConnectRetListener ホルダクラス}
* {@.en PortConnectRetListener holder class}
@@ -11,10 +14,10 @@
*
*/
public class PortConnectRetListenerHolder extends Observable{
- public void notify(final String config_set_name,final String config_param_name) {
+ public void notify(final String portname,final ConnectorProfile prof, final ReturnCode_t ret) {
super.setChanged();
PortConnectRetListenerArgument arg
- = new PortConnectRetListenerArgument(config_set_name,config_param_name);
+ = new PortConnectRetListenerArgument(portname,prof,ret);
super.notifyObservers(arg);
super.clearChanged();
}
openrtm-commit メーリングリストの案内