jp.go.aist.rtm.RTC.port
クラス PortBase

java.lang.Object
  上位を拡張 org.omg.PortableServer.Servant
      上位を拡張 RTC.PortPOA
          上位を拡張 jp.go.aist.rtm.RTC.port.PortBase
すべての実装されたインタフェース:
SDOServiceOperations, org.omg.CORBA.portable.InvokeHandler, PortOperations
直系の既知のサブクラス:
CorbaPort, DataInPort, DataOutPort

public abstract class PortBase
extends PortPOA

Portサーバントのベース実装となるクラスです。

Portは、UMLにおけるポートの概念をほぼ継承しており、ほぼ同等のものとみなすことができます。 RTコンポーネントのコンセプトにおいては、Portはコンポーネントに付属するものであり、 コンポーネントが他のコンポーネントと相互作用を行う接点であり、 通常は幾つかのインターフェースと関連付けられます。

コンポーネントはPortを通して外部に対してインターフェースを提供または要求 することができ、Portはその接続を管理する役割を担っています。

Portの具象クラスは、通常はRTコンポーネントインスタンス生成時に同時に生成され、 提供・要求インターフェースを登録した後、RTコンポーネントに登録され、 外部からアクセス可能なPortとして機能することを想定しています。

Portは、CORBAインターフェースとして以下のオペレーションを提供します。

このクラスでは、これらのオペレーションの実装を提供しています。

上記のオペレーションのうち、get_port_profile(), get_connector_profiles(), get_connector_profile(), connect(), disconnect(), disconnect_all()は、 サブクラスにおいて特に振る舞いを変更する必要がないため、オーバーライドすることは推奨されません。

notify_connect(), notify_disconnect()については、サブクラスが提供・要求するインターフェースの 種類に応じて、振る舞いを変更する必要が生ずるかもしれませんが、これらを直接オーバーライドすることは 推奨されず、後述のnotify_connect(), notify_disconnect()の項にも記述されている通りに、 これらのメソッドに関連したprotectedメソッドをオーバーライドすることにより振る舞いを変更することが 推奨されます。


入れ子のクラスの概要
protected  class PortBase.connect_func
          ポート接続のためのヘルパクラスです。
protected  class PortBase.disconnect_all_func
          ポート接続解除のためのヘルパクラスです。
protected  class PortBase.disconnect_func
          ポート接続解除のためのヘルパクラスです。
protected  class PortBase.find_conn_id
          指定された接続IDを持つ接続プロファイルを検索するためのヘルパクラスです。
protected  class PortBase.find_interface
          指定されたインスタンス名と属性を持つインタフェースを検索するためのヘルパクラスです。
protected  class PortBase.find_port_ref
          指定されたPortオブジェクトと同じCORBAオブジェクト参照を持つPortオブジェクトを 検索するためのヘルパクラスです。
 
フィールドの概要
protected  Port m_objref
          当該ポートのCORBAオブジェクト参照です。
protected  PortProfile m_profile
          当該ポートに関連付けられているPortProfileオブジェクトです。
 
コンストラクタの概要
PortBase()
          デフォルトコンストラクタです。
PortBase(java.lang.String name)
          本コンストラクタでは、オブジェクトの初期化処理を行うと同時に、 自身をCORBAオブジェクトとして活性化します。
 
メソッドの概要
 Port _this()
          当該PortのCORBAオブジェクト参照を取得します。
protected
<T> void
addProperty(java.lang.String key, T value, java.lang.Class<T> klass)
          当該ポートが持つPortProfile内のpropertiesメンバに、 指定されたキーと値を持つNameValueオブジェクトを追加します。
protected  boolean appendInterface(java.lang.String instance_name, java.lang.String type_name, PortInterfacePolarity polarity)
          当該ポートが持つPortProfile内に含まれるPortInterfaceProfileメンバに、 引数で指定された情報を追加します。
 ReturnCode_t connect(ConnectorProfileHolder connector_profile)
          ポート間の接続を行います。
protected  ReturnCode_t connectNext(ConnectorProfileHolder connector_profile)
          当該ポートの次のポートに対して接続通知を行います。
protected  boolean deleteInterface(java.lang.String instance_name, PortInterfacePolarity polarity)
          指定されたインスタンス名と属性を持つインタフェースを、当該ポートが持つPortProfile内の PortInterfaceProfileから削除します。
 ReturnCode_t disconnect_all()
          当該ポートに関連したすべての接続を解除します。
 ReturnCode_t disconnect(java.lang.String connector_id)
          ポートの接続を解除します。
protected  ReturnCode_t disconnectNext(ConnectorProfile connector_profile)
          当該ポートの次のポートに対して接続解除通知を行います。
protected  boolean eraseConnectorProfile(java.lang.String connector_id)
          指定された接続IDに対応する接続プロファイルを、当該ポートのPortProfileから削除します。
protected  ConnectorProfile findConnProfile(java.lang.String id)
          指定された接続IDを持つ接続プロファイルが、当該ポートのPortProfileに設定されている ConnectorProfileオブジェクトシーケンス内に存在するかどうかを調べ、存在する場合は そのConnectorProfileオブジェクトが取得されます。
protected  int findConnProfileIndex(java.lang.String id)
          指定された接続IDを持つ接続プロファイルが、当該ポートのPortProfileに設定されている ConnectorProfileオブジェクトシーケンス内に存在するかどうかを調べ、存在する場合は そのConnectorProfileオブジェクトのシーケンス内でのインデクスが取得されます。
 ConnectorProfile get_connector_profile(java.lang.String connector_id)
          指定されたコネクタIDに対応する接続プロファイルを取得します。
 ConnectorProfile[] get_connector_profiles()
          ConnectorProfileリストを取得します。
 PortProfile get_port_profile()
          PortProfileを取得します。
 PortProfile getPortProfile()
          PortProfileを取得します。
 Port getPortRef()
          当該ポートのPortProfileが保持している、当該ポート自身のCORBAオブジェクト参照を取得します。
 PortProfile getProfile()
          当該ポートが保持しているPortProfileオブジェクトを取得します。
protected  java.lang.String getUUID()
          UUIDを生成します。
protected  boolean isEmptyId(ConnectorProfile connector_profile)
          指定されたConnectorProfileオブジェクト内のconnector_idメンバが空かどうか判定します。
protected  boolean isExistingConnId(java.lang.String id)
          指定された接続IDを持つ接続プロファイルが、当該ポートのPortProfileに設定されている ConnectorProfileオブジェクトシーケンス内に存在するかどうかを判定します。
 ReturnCode_t notify_connect(ConnectorProfileHolder connector_profile)
          ポートの接続通知を行います。
 ReturnCode_t notify_disconnect(java.lang.String connector_id)
          ポートの接続解除通知を行います。
protected abstract  ReturnCode_t publishInterfaces(ConnectorProfileHolder connector_profile)
          Interface情報を公開します。
 void setName(java.lang.String name)
          ポート名を設定します。
 void setOwner(RTObject owner)
          当該ポートのオーナーRTObjectを設定します。
 void setPortRef(Port port_ref)
          指定されたポートCORBAオブジェクト参照を設定します。
protected  void setUUID(ConnectorProfileHolder connector_profile)
          UUIDを生成し、指定されたConnectorProfileオブジェクトのconnector_idメンバに設定します。
protected abstract  ReturnCode_t subscribeInterfaces(ConnectorProfileHolder connector_profile)
          Interface 情報を公開します。
protected abstract  void unsubscribeInterfaces(ConnectorProfile connector_profile)
          Interfaceの接続を解除します。
protected  void updateConnectorProfile(ConnectorProfile connector_profile)
          指定された接続プロファイルを、当該ポートのPortProfileに追加します。
 
クラス RTC.PortPOA から継承されたメソッド
_all_interfaces, _invoke, _this
 
クラス org.omg.PortableServer.Servant から継承されたメソッド
_default_POA, _get_delegate, _get_interface_def, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

m_profile

protected PortProfile m_profile

当該ポートに関連付けられているPortProfileオブジェクトです。


m_objref

protected Port m_objref

当該ポートのCORBAオブジェクト参照です。

コンストラクタの詳細

PortBase

public PortBase(java.lang.String name)

本コンストラクタでは、オブジェクトの初期化処理を行うと同時に、 自身をCORBAオブジェクトとして活性化します。さらに、自分自身のPortProfileの port_refメンバに、自身のCORBAオブジェクト参照を格納します。

パラメータ:
name - ポート名

PortBase

public PortBase()

デフォルトコンストラクタです。ポート名には空文字列が割り当てられます。

メソッドの詳細

_this

public Port _this()

当該PortのCORBAオブジェクト参照を取得します。

オーバーライド:
クラス PortPOA 内の _this
戻り値:
当該PortのCORBAオブジェクト参照

get_port_profile

public PortProfile get_port_profile()

PortProfileを取得します。なお、PortProfileは次のメンバを持っています。

戻り値:
本ポートに関するPortProfileオブジェクト

getPortProfile

public final PortProfile getPortProfile()

PortProfileを取得します。

戻り値:
本ポートに関するPortProfile

get_connector_profiles

public ConnectorProfile[] get_connector_profiles()

ConnectorProfileリストを取得します。 ConnectorProfileはポート間の接続プロファイル情報を保持するクラスであり、 接続時にポート間で情報交換を行い、関連するすべてのポートで同一の値が保持されます。

ConnectorProfileは以下のメンバを保持しています。

戻り値:
このポートに関連するConnectorProfileオブジェクトの配列

get_connector_profile

public ConnectorProfile get_connector_profile(java.lang.String connector_id)

指定されたコネクタIDに対応する接続プロファイルを取得します。

パラメータ:
connector_id - コネクタID
戻り値:
指定されたコネクタIDに対応する接続プロファイル

connect

public ReturnCode_t connect(ConnectorProfileHolder connector_profile)

ポート間の接続を行います。指定された接続プロファイルにしたがってポート間の接続を確立します。

アプリケーションプログラム側は、幾つかのコンポーネントが持つ複数のポート間を接続したい場合、 適切な値を設定した接続プロファイルを引数として渡すことにより、関連するポート間の接続を確立できます。

本メソッドの呼び出しにあたっては、ConnectorProfileオブジェクトのメンバのうち、 次のものについて値を設定しておかねばなりません。

パラメータ:
connector_profile - 接続プロファイル
戻り値:
ReturnCode_t型による戻り値

notify_connect

public ReturnCode_t notify_connect(ConnectorProfileHolder connector_profile)

ポートの接続通知を行います。本メソッドは、ポート間で接続が行われる際に、 ポート間で内部的に呼び出されます。

パラメータ:
connector_profile - 接続プロファイル
戻り値:
ReturnCode_t型の戻り値

disconnect

public ReturnCode_t disconnect(java.lang.String connector_id)

ポートの接続を解除します。このメソッドは、接続確立時に接続に対して与えられるコネクタIDに 対応するピア・ポートとの接続を解除します。

パラメータ:
connector_id - コネクタID
戻り値:
ReturnCode_t型の戻り値

notify_disconnect

public ReturnCode_t notify_disconnect(java.lang.String connector_id)

ポートの接続解除通知を行います。本メソッドは、ポート間の接続解除が行われる際に、 ポート間で内部的に呼び出されます。

パラメータ:
connector_id - コネクタID
戻り値:
ReturnCode_t型の戻り値

disconnect_all

public ReturnCode_t disconnect_all()

当該ポートに関連したすべての接続を解除します。

戻り値:
ReturnCode_t型の戻り値

setName

public void setName(java.lang.String name)

ポート名を設定します。指定されたポート名は、PortProfileのnameメンバに設定されます。

パラメータ:
name - ポート名

getProfile

public final PortProfile getProfile()

当該ポートが保持しているPortProfileオブジェクトを取得します。

戻り値:
当該ポートが保持しているPortProfileオブジェクト

setPortRef

public void setPortRef(Port port_ref)

指定されたポートCORBAオブジェクト参照を設定します。

本メソッドは、当該ポート自身のCORBAオブジェクト参照を設定するために用います。 当該ポートのCORBAオブジェクト参照以外は設定しないでください。

パラメータ:
port_ref - 当該ポートのCORBAオブジェクト参照

getPortRef

public Port getPortRef()

当該ポートのPortProfileが保持している、当該ポート自身のCORBAオブジェクト参照を取得します。

戻り値:
当該ポートのCORBAオブジェクト参照

setOwner

public void setOwner(RTObject owner)

当該ポートのオーナーRTObjectを設定します。 指定されたRTObjectオブジェクトが、PortProfileのownerメンバに設定されます。

パラメータ:
owner - 当該ポートを所有するRTObjectのCORBAオブジェクト参照

publishInterfaces

protected abstract ReturnCode_t publishInterfaces(ConnectorProfileHolder connector_profile)

Interface情報を公開します。 このメソッドは、notify_connect()処理シーケンスの始めに呼び出されるテンプレートメソッドです。

notify_connect()内では、以下の順にテンプレートメソッドが呼び出されて接続処理が行われます。

  1. publishInterfaces()
  2. connectNext()
  3. subscribeInterfaces()
  4. updateConnectorProfile()

具象Portクラスでは、このメソッドをオーバーライドし、引数として与えられた ConnectorProfileに従って処理を行い、パラメータが不適切であれば、ReturnCode_t型の エラーコードを返します。

通常、publishInterafaces()内においては、このポートに属するインターフェースに関する情報を ConnectorProfileに対して適切に設定し、他のポートに通知しなければなりません。 また、このメソッドが呼び出される段階では、他のポートのInterfaceに関する情報は すべては含まれていないので、他のポートのInterfaceを取得する処理はsubscribeInterfaces()内で 行われるべきです。

このメソッドは、新規のコネクタIDに対しては接続の生成が、既存のコネクタIDに対しては更新が 適切に行われる必要があります。

パラメータ:
connector_profile - 接続プロファイル
戻り値:
ReturnCode_t型の戻り値

connectNext

protected ReturnCode_t connectNext(ConnectorProfileHolder connector_profile)

当該ポートの次のポートに対して接続通知を行います。

ConnectorProfile内に設定されているPortのシーケンスを調べて、 当該Portの次のPortを特定し、そのPortに対してnotify_connect()を呼び出します。

パラメータ:
connector_profile - 接続プロファイル

disconnectNext

protected ReturnCode_t disconnectNext(ConnectorProfile connector_profile)

当該ポートの次のポートに対して接続解除通知を行います。

ConnectorProfile内に設定されているPortのシーケンスを調べて、 当該Portの次のPortを特定し、そのPortに対してnotify_disconnect()を呼び出します。

パラメータ:
connector_profile - 接続プロファイル

subscribeInterfaces

protected abstract ReturnCode_t subscribeInterfaces(ConnectorProfileHolder connector_profile)

Interface 情報を公開します。

このメソッドは、notify_connect()処理シーケンスの中間に呼び出されるテンプレートメソッドです。 notify_connect()では、

  1. publishInterfaces()
  2. connectNext()
  3. subscribeInterfaces()
  4. updateConnectorProfile()
の順にprotectedメソッドが呼び出されて接続処理が行われます。

このメソッドの処理は、新規のconnector_idに対しては接続の生成が適切に行われる必要があります。
また、既存のconnector_idに対しては更新が適切に行われる必要があります。

パラメータ:
connector_profile - 接続プロファイル情報
戻り値:
ReturnCode_t 戻り値

unsubscribeInterfaces

protected abstract void unsubscribeInterfaces(ConnectorProfile connector_profile)

Interfaceの接続を解除します。

このメソッドは、notify_disconnect()処理シーケンスの終わりに呼び出されるテンプレートメソッドです。 notify_disconnect()では、

  1. disconnectNext()
  2. unsubscribeInterfaces()
  3. eraseConnectorProfile()
の順にprotectedメソッドが呼び出されて接続解除処理が行われます。

具象クラスでは、このメソッドをオーバーライドし、引数として 与えられた ConnectorProfile に従い接続解除処理を行います。

パラメータ:
connector_profile - 接続プロファイル情報

isEmptyId

protected boolean isEmptyId(ConnectorProfile connector_profile)

指定されたConnectorProfileオブジェクト内のconnector_idメンバが空かどうか判定します。

戻り値:
空であればtrueを、さもなくばfalseを返します。

getUUID

protected java.lang.String getUUID()

UUIDを生成します。

戻り値:
生成されたUUID

setUUID

protected void setUUID(ConnectorProfileHolder connector_profile)

UUIDを生成し、指定されたConnectorProfileオブジェクトのconnector_idメンバに設定します。

パラメータ:
connector_profile - 設定先となるConnectorProfileオブジェクト

isExistingConnId

protected boolean isExistingConnId(java.lang.String id)

指定された接続IDを持つ接続プロファイルが、当該ポートのPortProfileに設定されている ConnectorProfileオブジェクトシーケンス内に存在するかどうかを判定します。

戻り値:
存在すればtrueを、さもなくばfalseを返します。

findConnProfile

protected ConnectorProfile findConnProfile(java.lang.String id)

指定された接続IDを持つ接続プロファイルが、当該ポートのPortProfileに設定されている ConnectorProfileオブジェクトシーケンス内に存在するかどうかを調べ、存在する場合は そのConnectorProfileオブジェクトが取得されます。

パラメータ:
id - 接続ID
戻り値:
指定した接続IDを持つConnectorProfileオブジェクトが見つかった場合は、 そのオブジェクトを返します。
見つからない場合は、空のConnectorProfileオブジェクトを返します。

findConnProfileIndex

protected int findConnProfileIndex(java.lang.String id)

指定された接続IDを持つ接続プロファイルが、当該ポートのPortProfileに設定されている ConnectorProfileオブジェクトシーケンス内に存在するかどうかを調べ、存在する場合は そのConnectorProfileオブジェクトのシーケンス内でのインデクスが取得されます。

戻り値:
指定した接続IDを持つConnectorProfileオブジェクトが見つかった場合は、 そのオブジェクトのシーケンス内インデクスを返します。
見つからない場合は、-1を返します。

updateConnectorProfile

protected void updateConnectorProfile(ConnectorProfile connector_profile)

指定された接続プロファイルを、当該ポートのPortProfileに追加します。 同一の接続IDを持つ接続プロファイルがすでにある場合は、その内容を上書きします。

パラメータ:
connector_profile - 追加もしくは更新する接続プロファイル

eraseConnectorProfile

protected boolean eraseConnectorProfile(java.lang.String connector_id)

指定された接続IDに対応する接続プロファイルを、当該ポートのPortProfileから削除します。

パラメータ:
connector_id - 削除対象となる接続プロファイルの接続ID
戻り値:
削除された場合はtrueを返します。
また、指定された接続IDの接続プロファイルが見つからない場合はfalseを返します。

appendInterface

protected boolean appendInterface(java.lang.String instance_name,
                                  java.lang.String type_name,
                                  PortInterfacePolarity polarity)

当該ポートが持つPortProfile内に含まれるPortInterfaceProfileメンバに、 引数で指定された情報を追加します。この情報は、get_port_profile()メソッドによって 得られるPortProfileにうち、PortInterfaceProfileの値を変更するのみであり、 実際にインタフェースを提供したり要求したりする場合には、サブクラス側で publishInterface(), subscribeInterface()などのメソッドを適切にオーバライドし、 インタフェースの提供や要求処理を行う必要があります。

なお、インタフェース(のインスタンス)名は、ポート内で一意でなければなりません。

パラメータ:
instance_name - インタフェースのインスタンス名
type_name - インタフェースの型名称
polarity - インタフェースの属性(提供インタフェースまたは要求インタフェース)
戻り値:
正常に登録できた場合はtrueを返します。 また、同名のインタフェースがすでに登録済みの場合はfalseを返します。

deleteInterface

protected boolean deleteInterface(java.lang.String instance_name,
                                  PortInterfacePolarity polarity)

指定されたインスタンス名と属性を持つインタフェースを、当該ポートが持つPortProfile内の PortInterfaceProfileから削除します。

パラメータ:
instance_name - 削除対象インタフェースのインスタンス名
polarity - 削除対象インタフェースの属性
戻り値:
正常に削除できた場合はtrueを返します。 また、該当するインタフェースが見つからない場合はfalseを返します。

addProperty

protected <T> void addProperty(java.lang.String key,
                               T value,
                               java.lang.Class<T> klass)

当該ポートが持つPortProfile内のpropertiesメンバに、 指定されたキーと値を持つNameValueオブジェクトを追加します。

パラメータ:
key - キー
value - 値