[openrtm-commit:00326] r532 - in branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . port
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 8月 9日 (火) 14:22:40 JST
Author: fsi-katami
Date: 2011-08-09 14:22:39 +0900 (Tue, 09 Aug 2011)
New Revision: 532
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/PortBase.java
branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListeners.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 08:51:01 UTC (rev 531)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java 2011-08-09 05:22:39 UTC (rev 532)
@@ -2675,6 +2675,7 @@
rtcout.println(Logbuf.TRACE, "addPort(PortBase)");
port.setOwner(this.getObjRef());
+ port.setPortConnectListenerHolder(m_portconnListeners);
onAddPort(port.getPortProfile());
return m_portAdmin.addPort(port);
@@ -4961,10 +4962,7 @@
*/
public void addPortConnectListener(int listener_type,
PortConnectListener listener) {
- if(listener_type < PortConnectListenerType.PORT_CONNECT_LISTENER_NUM){
- m_portconnListeners.
- portconnect_[listener_type].addObserver(listener);
- }
+ addPortConnectListener(listener_type, listener, true);
}
/**
@@ -5094,6 +5092,7 @@
}
catch(java.lang.Exception e){
+ System.out.println("Exception caught."+e.toString());
rtcout.println(Logbuf.WARN,
"Exception caught."+e.toString());
}
@@ -5196,10 +5195,7 @@
*/
public void addPortConnectRetListener(int listener_type,
PortConnectRetListener listener) {
- if(listener_type < PortConnectRetListenerType.PORT_CONNECT_RET_LISTENER_NUM){
- m_portconnListeners.
- portconnret_[listener_type].addObserver(listener);
- }
+ addPortConnectRetListener(listener_type, listener, true);
}
/**
* {@.ja PortConnectRetListener リスナを追加する}
@@ -6134,7 +6130,7 @@
* {@.en Holders of PortConnectListeners}
*
*/
- protected PortConnectListeners m_portconnListeners;
+ protected PortConnectListeners m_portconnListeners = new PortConnectListeners();
/**
* {@.ja RTコンポーネント検索用ヘルパークラス}
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortBase.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortBase.java 2011-08-05 08:51:01 UTC (rev 531)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortBase.java 2011-08-09 05:22:39 UTC (rev 532)
@@ -1365,6 +1365,24 @@
m_onConnectionLost = on_connection_lost;
}
+ /**
+ * {@.ja PortConnectListeners のホルダをセットする}
+ * {@.en Setting PortConnectListener holder}
+ * <p>
+ * {@.ja ポートの接続に関するリスナ群を保持するホルダクラスへのポインタを
+ * セットする。この関数は通常親のRTObjectから呼ばれ、RTObjectが持つ
+ * ホルダクラスへのポインタがセットされる。}
+ * {@.en This operation sets a functor that is called when connection
+ * of this port does lost. }
+ *
+ * @param portconnListeners
+ * {@.ja PortConnectListeners オブジェクトのポインタ}
+ * {@.en a pointer to ConnectionCallback's subclasses}
+ *
+ */
+ public void setPortConnectListenerHolder(PortConnectListeners portconnListeners){
+ m_portconnListeners = portconnListeners;
+ }
/**
* <p>Interface情報を公開します。
@@ -2054,17 +2072,15 @@
protected void onNotifyConnect(final String portname,
ConnectorProfile profile) {
- if (m_portconnListeners != null) {
- m_portconnListeners.
- portconnect_[PortConnectListenerType.ON_NOTIFY_CONNECT].notify(portname, profile);
+ if (m_portconnListeners != null) {
+ m_portconnListeners.portconnect_[PortConnectListenerType.ON_NOTIFY_CONNECT].notify(portname, profile);
}
}
protected void onNotifyDisconnect(final String portname,
RTC.ConnectorProfile profile) {
- if (m_portconnListeners != null) {
- m_portconnListeners.
- portconnect_[PortConnectListenerType.ON_NOTIFY_DISCONNECT].notify(portname, profile);
+ if (m_portconnListeners != null) {
+ m_portconnListeners.portconnect_[PortConnectListenerType.ON_NOTIFY_DISCONNECT].notify(portname, profile);
}
}
protected void onUnsubscribeInterfaces(final String portname,
@@ -2180,7 +2196,8 @@
* {@.en Holders of PortConnectListeners}
*
*/
- protected PortConnectListeners m_portconnListeners = new PortConnectListeners();
+ //protected PortConnectListeners m_portconnListeners = new PortConnectListeners();
+ protected PortConnectListeners m_portconnListeners = null;
/**
* <p> The maximum number of connections </p>
*/
Modified: branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListeners.java
===================================================================
--- branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListeners.java 2011-08-05 08:51:01 UTC (rev 531)
+++ branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/PortConnectListeners.java 2011-08-09 05:22:39 UTC (rev 532)
@@ -23,5 +23,14 @@
*/
public PortConnectRetListenerHolder[] portconnret_
= new PortConnectRetListenerHolder[PortConnectRetListenerType.PORT_CONNECT_RET_LISTENER_NUM];
+
+ public PortConnectListeners() {
+ for(int ic=0;ic<PortConnectListenerType.PORT_CONNECT_LISTENER_NUM;++ic){
+ portconnect_[ic] = new PortConnectListenerHolder();
+ }
+ for(int ic=0;ic<PortConnectRetListenerType.PORT_CONNECT_RET_LISTENER_NUM;++ic){
+ portconnret_[ic] = new PortConnectRetListenerHolder();
+ }
+ }
};
openrtm-commit メーリングリストの案内