Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
RTC::PortBase Class Referenceabstract

Port base class. More...

#include <PortBase.h>

Inheritance diagram for RTC::PortBase:
Inheritance graph
[legend]

Classes

struct  find_conn_id
 Functor to find a ConnectorProfile named id. More...
 
struct  find_interface
 Functor to find interface from name and polarity. More...
 
struct  find_port_ref
 Functor to find the object reference that is identical port_ref. More...
 

Public Member Functions

virtual void activateInterfaces ()=0
 Activate all Port interfaces. More...
 
virtual ReturnCode_t connect (ConnectorProfile &connector_profile) throw (CORBA::SystemException)
 [CORBA interface] Connect the Port More...
 
virtual void deactivateInterfaces ()=0
 Deactivate all Port interfaces. More...
 
virtual ReturnCode_t disconnect (const char *connector_id) throw (CORBA::SystemException)
 [CORBA interface] Disconnect the Port More...
 
virtual ReturnCode_t disconnect_all () throw (CORBA::SystemException)
 [CORBA interface] Disconnect the All Ports More...
 
virtual ConnectorProfile * get_connector_profile (const char *connector_id) throw (CORBA::SystemException)
 [CORBA interface] Get the ConnectorProfile More...
 
virtual ConnectorProfileList * get_connector_profiles () throw (CORBA::SystemException)
 [CORBA interface] Get the ConnectorProfileList of the Port More...
 
virtual PortProfile * get_port_profile () throw (CORBA::SystemException)
 [CORBA interface] Get the PortProfile of the Port More...
 
const char * getName () const
 Get the name of this Port. More...
 
const PortProfile & getPortProfile () const
 Get the PortProfile of the Port. More...
 
PortService_ptr getPortRef ()
 Get the object reference of this Port. More...
 
const PortProfile & getProfile () const
 Get the PortProfile of the Port. More...
 
virtual ReturnCode_t notify_connect (ConnectorProfile &connector_profile) throw (CORBA::SystemException)
 [CORBA interface] Notify the Ports connection More...
 
virtual ReturnCode_t notify_disconnect (const char *connector_id) throw (CORBA::SystemException)
 [CORBA interface] Notify the Ports disconnection More...
 
 PortBase (const char *name="")
 Constructor. More...
 
void setName (const char *name)
 Set the name of this Port. More...
 
void setOnConnected (ConnectionCallback *on_connected)
 Setting callback called on connection established. More...
 
void setOnConnectionLost (ConnectionCallback *on_connection_lost)
 Setting callback called on connection lost. More...
 
void setOnDisconnected (ConnectionCallback *on_disconnected)
 Setting callback called on disconnected. More...
 
void setOnPublishInterfaces (ConnectionCallback *on_publish)
 Setting callback called on publish interfaces. More...
 
void setOnSubscribeInterfaces (ConnectionCallback *on_subscribe)
 Setting callback called on publish interfaces. More...
 
void setOnUnsubscribeInterfaces (ConnectionCallback *on_subscribe)
 Setting callback called on unsubscribe interfaces. More...
 
void setOwner (RTObject_ptr owner)
 Set the owner RTObject of the Port. More...
 
void setPortConnectListenerHolder (PortConnectListeners *portconnListeners)
 Setting PortConnectListener holder. More...
 
void setPortRef (PortService_ptr port_ref)
 Set the object reference of this Port. More...
 
virtual ~PortBase (void)
 Destructor. More...
 

Protected Types

typedef coil::Guard< coil::MutexGuard
 

Protected Member Functions

virtual ReturnCode_t _publishInterfaces (void)
 Publish interface information. More...
 
template<class ValueType >
void addProperty (const char *key, ValueType value)
 Add NameValue data to PortProfile's properties. More...
 
bool appendInterface (const char *name, const char *type_name, PortInterfacePolarity pol)
 Append an interface to the PortInterfaceProfile. More...
 
void appendProperty (const char *key, const char *value)
 Append NameValue data to PortProfile's properties. More...
 
bool checkPorts (::RTC::PortServiceList &ports)
 Existence of ports. More...
 
virtual ReturnCode_t connectNext (ConnectorProfile &connector_profile)
 Call notify_connect() of the next Port. More...
 
bool deleteInterface (const char *name, PortInterfacePolarity pol)
 Delete the interface registration from the PortInterfaceProfile. More...
 
virtual ReturnCode_t disconnectNext (ConnectorProfile &connector_profile)
 Call notify_disconnect() of the next Port. More...
 
bool eraseConnectorProfile (const char *id)
 Delete the ConnectorProfile. More...
 
ConnectorProfile findConnProfile (const char *id)
 Find ConnectorProfile with id. More...
 
CORBA::Long findConnProfileIndex (const char *id)
 Find ConnectorProfile with id. More...
 
const std::string getUUID () const
 Generate the UUID. More...
 
bool isEmptyId (const ConnectorProfile &connector_profile) const
 Check whether connector_id of ConnectorProfile is empty. More...
 
bool isExistingConnId (const char *id)
 Check whether the given id exists in stored ConnectorProfiles. More...
 
void onConnected (const char *portname, RTC::ConnectorProfile &profile, ReturnCode_t ret)
 
void onConnectNextport (const char *portname, RTC::ConnectorProfile &profile, ReturnCode_t ret)
 
void onDisconnected (const char *portname, RTC::ConnectorProfile &profile, ReturnCode_t ret)
 
void onDisconnectNextport (const char *portname, RTC::ConnectorProfile &profile, ReturnCode_t ret)
 
void onNotifyConnect (const char *portname, RTC::ConnectorProfile &profile)
 
void onNotifyDisconnect (const char *portname, RTC::ConnectorProfile &profile)
 
void onPublishInterfaces (const char *portname, RTC::ConnectorProfile &profile, ReturnCode_t ret)
 
void onSubscribeInterfaces (const char *portname, RTC::ConnectorProfile &profile, ReturnCode_t ret)
 
void onUnsubscribeInterfaces (const char *portname, RTC::ConnectorProfile &profile)
 
virtual ReturnCode_t publishInterfaces (ConnectorProfile &connector_profile)=0
 Publish interface information. More...
 
virtual void setConnectionLimit (int limit_value)
 Set the maximum number of connections. More...
 
void setUUID (ConnectorProfile &connector_profile) const
 Generate and set the UUID to the ConnectorProfile. More...
 
virtual ReturnCode_t subscribeInterfaces (const ConnectorProfile &connector_profile)=0
 Publish interface information. More...
 
virtual void unsubscribeInterfaces (const ConnectorProfile &connector_profile)=0
 Disconnect interface connection. More...
 
void updateConnectorProfile (const ConnectorProfile &connector_profile)
 Append or update the ConnectorProfile list. More...
 
void updateConnectors ()
 Disconnect ports that doesn't exist. More...
 

Protected Attributes

int m_connectionLimit
 The maximum number of connections. More...
 
coil::Mutex m_connectorsMutex
 
RTC::PortService_var m_objref
 Object Reference of the Port. More...
 
ConnectionCallbackm_onConnected
 Callback functor objects. More...
 
ConnectionCallbackm_onConnectionLost
 Callback functor objects. More...
 
ConnectionCallbackm_onDisconnected
 Callback functor objects. More...
 
ConnectionCallbackm_onPublishInterfaces
 Callback functor objects. More...
 
ConnectionCallbackm_onSubscribeInterfaces
 Callback functor objects. More...
 
ConnectionCallbackm_onUnsubscribeInterfaces
 Callback functor objects. More...
 
std::string m_ownerInstanceName
 Instance name. More...
 
PortConnectListenersm_portconnListeners
 PortConnectListener holder. More...
 
PortProfile m_profile
 PortProfile of the Port. More...
 
coil::Mutex m_profile_mutex
 Mutex of PortProfile. More...
 
Logger rtclog
 Logger stream. More...
 

Detailed Description

Port base class.

This class is a base class of RTC::Port. RTC::Port inherits a concept of RT-Component, and can be regarded as almost the same as it. In the concept of RT-Component, Port is attached to the component, can mediate interaction between other components and usually is associated with some interfaces. Component can provide or require interface for outside via Port, and the Port plays a role to manage the connection.

Concrete class of Port assumes to be usually created at the same time that RT-Component's instance is created, be registerd to RT-Component after provided and required interfaces are registerd, and function as accessible Port from outside.

RTC::Port provides the following operations as CORBA interface:

This class provides implementations of these operations.

In these operations, as for get_port_profile(), get_connector_profiles(), get_connector_profile(), connect(), disconnect() and disconnect_all(), since their behaviors especially need not to be change in subclass, overriding is not recommended.

As for notify_connect() and notify_disconnect(), you may have to modify behavior according to the kind of interfaces that subclass provides and requires, however it is not recommended these are overriden directly. In the section of notify_connect() and notify_disconnect() as described below, it is recommended that you modify behavior by overriding the protected function related to these functions.

Since
0.4.0

Definition at line 134 of file PortBase.h.

Member Typedef Documentation

Definition at line 2089 of file PortBase.h.

Constructor & Destructor Documentation

RTC::PortBase::PortBase ( const char *  name = "")

Constructor.

The constructor of the ProtBase class is given the name of this Port and initialized. At the same time, the PortBase activates itself as CORBA object and stores its object reference to the PortProfile's port_ref member. Characters except "." can be used for the name of the port.

Parameters
nameThe name of Port (The default value:"")

Definition at line 38 of file PortBase.cpp.

RTC::PortBase::~PortBase ( void  )
virtual

Destructor.

In the destructor, PortService CORBA object is deactivated. This function never throws exception.

Definition at line 71 of file PortBase.cpp.

Member Function Documentation

ReturnCode_t RTC::PortBase::_publishInterfaces ( void  )
protectedvirtual

Publish interface information.

Publish interface information.

Returns
The return code of ReturnCode_t type

Definition at line 315 of file PortBase.cpp.

virtual void RTC::PortBase::activateInterfaces ( )
pure virtual

Activate all Port interfaces.

This operation activate all interfaces that is registered in the ports.

Implemented in RTC::CorbaPort, RTC::OutPortBase, RTC::InPortBase, RTObject::PortMock, PortBase::PortBaseMock, PortAdmin::PortMock, and CORBA_SeqUtil::PortMock.

template<class ValueType >
void RTC::PortBase::addProperty ( const char *  key,
ValueType  value 
)
inlineprotected

Add NameValue data to PortProfile's properties.

Add NameValue data to PortProfile's properties. Type of additional data is specified by ValueType.

Parameters
keyThe name of properties
valueThe value of properties

Definition at line 1876 of file PortBase.h.

bool RTC::PortBase::appendInterface ( const char *  name,
const char *  type_name,
PortInterfacePolarity  pol 
)
protected

Append an interface to the PortInterfaceProfile.

This operation appends interface information to the PortInterfaceProfile that is owned by the Port. The given interfaces information only updates PortInterfaceProfile of PortProfile that is obtained through get_port_profile(). In order to provide and require interfaces, proper functions (for example publishInterface(), subscribeInterface() and so on) should be overridden in subclasses, and these functions provide concrete interface connection and disconnection functionality.

The interface (instance) name have to be unique in the Port. If the given interface name is identical with stored interface name, this function returns false.

Parameters
nameThe instance name of the interface.
type_nameThe type name of the interface.
polThe interface's polarity (RTC::PROVIDED or RTC:REQUIRED)
Returns
false would be returned if the same name is already registered.

Definition at line 841 of file PortBase.cpp.

void RTC::PortBase::appendProperty ( const char *  key,
const char *  value 
)
inlineprotected

Append NameValue data to PortProfile's properties.

Append NameValue data to PortProfile's properties. The properties which are set by this function would be referred through get_port_profile() from outsides.

Parameters
keyThe name of properties
valueThe value of properties

Definition at line 1907 of file PortBase.h.

bool RTC::PortBase::checkPorts ( ::RTC::PortServiceList &  ports)
protected

Existence of ports.

Parameters
portsChecked ports
Returns
true:existent,false:non existent

Definition at line 937 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::connect ( ConnectorProfile &  connector_profile)
throw (CORBA::SystemException
)
virtual

[CORBA interface] Connect the Port

This operation establishes connection according to the given ConnectionProfile inforamtion. This function is premised on calling from mainly application program or tools.

Precondition
To establish the connection among Ports of RT-Components, application programs must call this operation giving ConnectorProfile with valid values as an argument.
Out of ConnectorProfile member variables, "name", "ports" and "properties" members shall be set valid data. "connector_id" shall be set as empty string value or valid string UUID value.
ConnectorProfile::name that is connection identifier shall be any valid CORBA::string.
ConnectorProfile::connector_id shall be set unique identifier (usually UUID is used) for all connections. Since UUID string value is usually set in the connect() function, caller should just set empty string. If the connect() is called with the same UUID as existing connection, this function returns PRECONDITION_NOT_MET error. However, in order to update the existing connection profile, the "connect()" operation with existing connector ID might be used as valid method by future extension
ConnectorProfile::ports, which is sequence of RTC::PortService references, shall store usually two or more ports' references. As exceptions, the "connect()" operation might be called with only one reference in ConnectorProfile, in case of just getting interfaces information from the port, or connecting a special port (i.e. the peer port except RTC::PortService on CORBA).
ConnectorProfile::properties might be used to give certain properties to the service interfaces associated with the port. The properties is a sequence variable with a pair of key string and Any type value. Although the A variable can store any type of values, it is not recommended except string.
The following is the summary of the ConnectorProfile member to be set when this operation is called.
  • ConnectorProfile::name: The any name of connection
  • ConnectorProfile::connector_id: Empty string
  • ConnectorProfile::ports: One or more port references
  • ConnectorProfile::properties: Properties for the interfaces
Postcondition
connect() operation will call the first port in the sequence of the ConnectorProfile.
"noify_connect()"s perform cascaded call to the ports stored in the ConnectorProfile::ports by order. Even if errors are raised by intermediate notify_connect() operation, as long as ports' object references are valid, it is guaranteed that this cascaded call is completed in all the ports. If invalid or dead ports exist in the port's sequence, the ports are skipped and notify_connect() is called for the next valid port.
connect() function returns RTC_OK if all the notify_connect() return RTC_OK. At this time the connection is completed. If notify_connect()s return except RTC_OK, connect() calls disconnect() operation with the connector_id to destruct the connection, and then it returns error code from notify_connect().
The ConnectorProfile argument of the connect() operation returns ConnectorProfile::connector_id and various information about service interfaces that is published by publishInterfaces() in the halfway ports. The connect() and halfway notify_connect() functions never change ConnectorProfile::{name, ports}.
Parameters
connector_profileThe ConnectorProfile.
Returns
ReturnCode_t The return code of ReturnCode_t type.

Reimplemented in RTC::OutPortBase, and RTC::InPortBase.

Definition at line 181 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::connectNext ( ConnectorProfile &  connector_profile)
protectedvirtual

Call notify_connect() of the next Port.

Call notify_connect() for the next Port.

This operation calls the notify_connect() of the next Port's that stored in ConnectorProfile's port_ref sequence.

Parameters
connector_profileThe connection profile information
Returns
The return code of ReturnCode_t type.

Definition at line 626 of file PortBase.cpp.

virtual void RTC::PortBase::deactivateInterfaces ( )
pure virtual

Deactivate all Port interfaces.

This operation deactivate all interfaces that is registered in the ports.

Implemented in RTC::CorbaPort, RTC::OutPortBase, RTC::InPortBase, RTObject::PortMock, PortBase::PortBaseMock, PortAdmin::PortMock, and CORBA_SeqUtil::PortMock.

bool RTC::PortBase::deleteInterface ( const char *  name,
PortInterfacePolarity  pol 
)
protected

Delete the interface registration from the PortInterfaceProfile.

This operation deletes interface information from the PortInterfaceProfile that is owned by the Port.

Parameters
nameThe instance name of the interface.
polThe interface's polarity (RTC::PROVIDED or RTC:REQUIRED)
Returns
Delete processing result of interface. false would be returned if the given name is not registered.

Definition at line 867 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::disconnect ( const char *  connector_id)
throw (CORBA::SystemException
)
virtual

[CORBA interface] Disconnect the Port

This operation destroys connection between this port and the peer port according to given connector_id. Usually connector_id should be a UUID string that is unique in the system. And the connection, which is established by connect()/notify_connect() functions, is identified by the ConnectorProfile::connector_id.

Precondition
connector_id shall be a character string which is same with ID of at least one of the ConnectorProfiles stored in this port. If ConnectorProfile that has same ID with the given connector_id does not exist in the list of ConnectorProfile, this operation returns BAD_PARAMTER error.
ConnectorProfile::ports that is same ID with given connector_id shall store the valid ports' references.
Postcondition
disconnect() function invokes the notify_disconnect() for the port that is stored in the first of the ConnectorProfile::ports. If notify_disconnect() call fails for the first port, It tries on calling "notify_disconnect()" in order for ports stored in ConnectorProfile::ports until the operation call is succeeded. If notify_disconnect() succeeded for at least one port, it returns return code from notify_disconnect(). If none of notify_connect() call succeeded, it returns RTC_ERROR error.
Parameters
connector_idThe ID of the ConnectorProfile.
Returns
ReturnCode_t The return code of ReturnCode_t type.

Definition at line 339 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::disconnect_all ( )
throw (CORBA::SystemException
)
virtual

[CORBA interface] Disconnect the All Ports

This operation destroys all connections associated with this Port.

Returns
ReturnCode_t The return code of ReturnCode_t type.

Definition at line 454 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::disconnectNext ( ConnectorProfile &  connector_profile)
protectedvirtual

Call notify_disconnect() of the next Port.

Call notify_disconnect() for the next Port.

This operation calls the notify_disconnect() of the next Port's that stored in ConnectorProfile's port_ref sequence.

Parameters
connector_profileThe connection profile information
Returns
The return code of ReturnCode_t type.

Definition at line 650 of file PortBase.cpp.

bool RTC::PortBase::eraseConnectorProfile ( const char *  id)
protected

Delete the ConnectorProfile.

This operation deletes a ConnectorProfile specified by id from ConnectorProfileList owned by PortProfile of this Port.

Parameters
idThe id of the ConnectorProfile to be deleted.
Returns
true would be returned if it deleted correctly. false woluld be returned if specified ConnectorProfile cannot be found.

Definition at line 823 of file PortBase.cpp.

ConnectorProfile RTC::PortBase::findConnProfile ( const char *  id)
protected

Find ConnectorProfile with id.

This operation returns ConnectorProfile with the given id from Port's ConnectorProfiles' list. If the ConnectorProfile with connector id that is identical with the given id does not exist, empty ConnectorProfile is returned.

Parameters
idthe connector_id to be searched in Port's ConnectorProfiles
Returns
CoonectorProfile with connector_id

Definition at line 770 of file PortBase.cpp.

CORBA::Long RTC::PortBase::findConnProfileIndex ( const char *  id)
protected

Find ConnectorProfile with id.

This operation returns ConnectorProfile with the given id from Port's ConnectorProfiles' list. If the ConnectorProfile with connector id that is identical with the given id does not exist, -1 is returned.

Parameters
idthe connector_id to be searched
Returns
The index of ConnectorProfile of the Port

Definition at line 785 of file PortBase.cpp.

ConnectorProfile * RTC::PortBase::get_connector_profile ( const char *  connector_id)
throw (CORBA::SystemException
)
virtual

[CORBA interface] Get the ConnectorProfile

This operation returns the ConnectorProfiles specified connector_id. Since this function is CORBA operation, callers have responsibility to destruction of the returned ConnectorProfile object according to the CORBA memory management rules.

If ConnectorProfile with specified connector_id is not included, empty ConnectorProfile is returned.

Postcondition
This function never changes the state of the object.
Parameters
connector_idID of the ConnectorProfile
Returns
the ConnectorProfile identified by the connector_id

Definition at line 153 of file PortBase.cpp.

ConnectorProfileList * RTC::PortBase::get_connector_profiles ( )
throw (CORBA::SystemException
)
virtual

[CORBA interface] Get the ConnectorProfileList of the Port

This operation returns a list of the ConnectorProfiles of the Port. Since this function is CORBA operation, callers have responsibility to destruction of the returned ConnectorProfileList object according to the CORBA memory management rules.

ConnectorProfile includes the connection information that describes relation between (among) Ports, and Ports exchange the ConnectionProfile on connection process and hold the same information in every Port. ConnectionProfile has the following members:

  • name [string type] The name of the connection.
  • connector_id [string type] Unique identifier.
  • ports [Port sequnce] The sequence of Port's object reference that are related the connection.
  • properties [NVList type] The other properties.
Postcondition
This function never changes the state of the object.
Returns
ConnectorProfileList of the Port

Definition at line 133 of file PortBase.cpp.

PortProfile * RTC::PortBase::get_port_profile ( )
throw (CORBA::SystemException
)
virtual

[CORBA interface] Get the PortProfile of the Port

This operation returns the PortProfile of the Port. Since this function is CORBA operation, callers have responsibility to destruction of the returned PortProfile object according to the CORBA memory management rules.

PortProfile struct has the following members:

  • name [string type] The name of the Port.
  • interfaces [PortInterfaceProfileList type] The sequence of PortInterfaceProfile owned by the Port
  • port_ref [Port Object type] The object reference of the Port.
  • connector_profile [ConnectorProfileList type] The sequence of ConnectorProfile owned by the Port.
  • owner [RTObject Object type] The object reference of RTObject that is owner of the Port.
  • properties [NVList type] The other properties.
Postcondition
This function never changes the state of the object.
Returns
PortProfile of the Port

Definition at line 100 of file PortBase.cpp.

const char * RTC::PortBase::getName ( void  ) const

Get the name of this Port.

This operation returns the name of this Port.

Returns
The name of this Port.
The name of this Port.

Definition at line 504 of file PortBase.cpp.

const PortProfile & RTC::PortBase::getPortProfile ( ) const

Get the PortProfile of the Port.

This function is a const function that returns a const reference of the PortProfile stored in this Port.

Postcondition
This function never changes the state of the object.
Returns
PortProfile

Definition at line 119 of file PortBase.cpp.

PortService_ptr RTC::PortBase::getPortRef ( )

Get the object reference of this Port.

Get the object reference of the Port.

This operation returns the object reference that is stored in the Port's PortProfile.

Returns
The object reference of this Port.

Definition at line 545 of file PortBase.cpp.

const PortProfile & RTC::PortBase::getProfile ( ) const

Get the PortProfile of the Port.

This operation returns const reference of the PortProfile.

Returns
PortProfile of the Port

Definition at line 517 of file PortBase.cpp.

const std::string RTC::PortBase::getUUID ( ) const
protected

Generate the UUID.

This operation generates UUID.

Returns
uuid

Definition at line 728 of file PortBase.cpp.

bool RTC::PortBase::isEmptyId ( const ConnectorProfile &  connector_profile) const
protected

Check whether connector_id of ConnectorProfile is empty.

Check whether connector_id of specified ConnectorProfile is empty.

Parameters
connector_profileTarget ConnectorProfile for the check
Returns
If the given ConnectorProfile's connector_id is empty string, it returns true.

Definition at line 715 of file PortBase.cpp.

bool RTC::PortBase::isExistingConnId ( const char *  id)
protected

Check whether the given id exists in stored ConnectorProfiles.

This operation returns boolean whether the given id exists in the Port's ConnectorProfiles.

Parameters
idconnector_id to be find in Port's ConnectorProfiles
Returns
id exestance resutl

Definition at line 757 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::notify_connect ( ConnectorProfile &  connector_profile)
throw (CORBA::SystemException
)
virtual

[CORBA interface] Notify the Ports connection

This operation is usually called from other ports' connect() or notify_connect() operations when connection between ports is established. This function is not premised on calling from other functions or application programs.

According to the template method pattern, the notify_connect() calls "publishInterfaces()" and "subsctiveInterfaces()" functions, which are premised on implementing in the subclasses. The processing sequence is as follows.

According to the order of port's references stored in the ConnectorProfile::ports, publishing interface information to all the ports and subscription interface information from all the ports is performed by "notify_connect()"s. This cascaded call never aborts in the halfway operations, and calling sequence shall be completed for all the ports.

Precondition
notify_connect() calls notify_connect() for the port's reference that is stored in next of this port's reference in the sequence of the ConnectorProfile::ports. Therefore the reference of this port shall be stored in the ConnectorProfile::ports. If this port's reference is not stored in the sequence, BAD_PARAMETER error will be returned, except the return code is overwritten by other operations.
UUID shall be set to ConnectorProfile::connector_id as a unique identifier when this operation is called. Usually, connector_id is given by a connect() function and, the behavior is undefined in the case of a null character.
Postcondition
ConnectorProfile::name, ConnectorProfile::connector_id, ConnectorProfile::ports are invariant, and they are never rewritten by notify_connect() operations.
In order to transfer interface information to other ports, interface property information is stored into the ConnectorProfile::properties.
At the end of notify_connect() operation for the first port stored in the ConnectorProfile::ports sequence, the related ports' notify_connect() invocations complete. Even if errors are raised at the halfway of publishInterfaces(), connectNext(), subscribeInterfaces() and storing process of ConnectorProfile, error codes are saved and the first error is returned.
Parameters
connector_profileThe ConnectorProfile.
Returns
ReturnCode_t The return code of ReturnCode_t type.

Definition at line 229 of file PortBase.cpp.

ReturnCode_t RTC::PortBase::notify_disconnect ( const char *  connector_id)
throw (CORBA::SystemException
)
virtual

[CORBA interface] Notify the Ports disconnection

This operation is invoked between Ports internally when the connection is destroied. Generally it is not premised on calling from application programs or RTC objects except Port object.

According to the template method pattern, the notify_disconnect() calls unsubsctiveInterfaces() function, which are premised on implementing in the subclasses. The processing sequence is as follows.

  • Searching ConnectorProfile
  • Calling notify_disconnect() for the next port
  • Unsubscribing interfaces
  • Deleting ConnectorProfile

notify_disconnect() notifies disconnection to all the ports by cascaded call to the stored ports in the ConnectorProfile::ports in order.

Precondition
The port shall store the ConnectorProfile having same id with connector_id.
Postcondition
If ConnectorProfile of same ID with connector_id does not exist, it returns BAD_PARAMETER error.
For the cascaded call, this operation calls noify_disconnect() for the port that is stored in the next of this port in the ConnectorProfile::ports. If the operation call raises exception for some failure, it tries to call notify_disconnect() and skips until the operation succeeded. If none of operation call succeeded, it returns RTC_ERROR.
At the end of notify_disconnect() operation for the first port stored in the ConnectorProfile::ports sequence, the related ports' notify_disconnect() invocations complete.
Parameters
connector_idThe ID of the ConnectorProfile.
Returns
ReturnCode_t The return code of ReturnCode_t type.

Reimplemented in PortBase::PortBaseMock.

Definition at line 396 of file PortBase.cpp.

void RTC::PortBase::onConnected ( const char *  portname,
RTC::ConnectorProfile &  profile,
ReturnCode_t  ret 
)
inlineprotected

Definition at line 2021 of file PortBase.h.

void RTC::PortBase::onConnectNextport ( const char *  portname,
RTC::ConnectorProfile &  profile,
ReturnCode_t  ret 
)
inlineprotected

Definition at line 1997 of file PortBase.h.

void RTC::PortBase::onDisconnected ( const char *  portname,
RTC::ConnectorProfile &  profile,
ReturnCode_t  ret 
)
inlineprotected

Definition at line 2043 of file PortBase.h.

void RTC::PortBase::onDisconnectNextport ( const char *  portname,
RTC::ConnectorProfile &  profile,
ReturnCode_t  ret 
)
inlineprotected

Definition at line 2032 of file PortBase.h.

void RTC::PortBase::onNotifyConnect ( const char *  portname,
RTC::ConnectorProfile &  profile 
)
inlineprotected

Definition at line 1956 of file PortBase.h.

void RTC::PortBase::onNotifyDisconnect ( const char *  portname,
RTC::ConnectorProfile &  profile 
)
inlineprotected

Definition at line 1966 of file PortBase.h.

void RTC::PortBase::onPublishInterfaces ( const char *  portname,
RTC::ConnectorProfile &  profile,
ReturnCode_t  ret 
)
inlineprotected

Definition at line 1985 of file PortBase.h.

void RTC::PortBase::onSubscribeInterfaces ( const char *  portname,
RTC::ConnectorProfile &  profile,
ReturnCode_t  ret 
)
inlineprotected

Definition at line 2009 of file PortBase.h.

void RTC::PortBase::onUnsubscribeInterfaces ( const char *  portname,
RTC::ConnectorProfile &  profile 
)
inlineprotected

Definition at line 1975 of file PortBase.h.

virtual ReturnCode_t RTC::PortBase::publishInterfaces ( ConnectorProfile &  connector_profile)
protectedpure virtual

Publish interface information.

This operation is pure virutal function that would be called at the beginning of the notify_connect() process sequence. In the notify_connect(), the following methods would be called in order.

In the concrete Port, this method should be overridden. This method processes the given ConnectorProfile argument and if the given parameter is invalid, it would return error code of ReturnCode_t. Usually, publishInterfaces() method should set interfaces information owned by this Port, and publish it to the other Ports.
When this method is called, other Ports' interfaces information may not be completed. Therefore, the process to obtain other Port's interfaces information should be done in the subscribeInterfaces() method.
This operation should create the new connection for the new connector_id, and should update the connection for the existing connection_id.

Parameters
connector_profileThe connection profile information
Returns
The return code of ReturnCode_t type.

Implemented in RTC::CorbaPort, RTC::OutPortBase, and RTC::InPortBase.

void RTC::PortBase::setConnectionLimit ( int  limit_value)
protectedvirtual

Set the maximum number of connections.

Parameters
limit_valueThe maximum number of connections

Definition at line 700 of file PortBase.cpp.

void RTC::PortBase::setName ( const char *  name)

Set the name of this Port.

This operation sets the name of this Port. The given Port's name is applied to Port's PortProfile.name.

Parameters
nameThe name of this Port.

Definition at line 488 of file PortBase.cpp.

void RTC::PortBase::setOnConnected ( ConnectionCallback on_connected)

Setting callback called on connection established.

This operation sets a functor that is called when connection between ports established.

Since the ownership of the callback functor object is owned by the caller, it has the responsibility of object destruction.

The callback functor is called only when notify_connect() function successfully returns. In case of error, the functor will not be called.

Since this functor is called with ConnectorProfile argument that is same as out-parameter of notify_connect() function, you can get all the information of published interfaces of related ports in the connection. Although by using this functor, you can modify ConnectorProfile argument for out-paramter of notify_connect(), the modification should be done carefully for fear of causing connection inconsistency.

Parameters
on_subscribea pointer to ConnectionCallback's subclasses

Definition at line 589 of file PortBase.cpp.

void RTC::PortBase::setOnConnectionLost ( ConnectionCallback on_connection_lost)

Setting callback called on connection lost.

This operation sets a functor that is called when connection of this port does lost.

Parameters
on_connection_losta pointer to ConnectionCallback's subclasses

Definition at line 604 of file PortBase.cpp.

void RTC::PortBase::setOnDisconnected ( ConnectionCallback on_disconnected)

Setting callback called on disconnected.

This operation sets a functor that is called when connection between ports is destructed.

Since the ownership of the callback functor object is owned by the caller, it has the responsibility of object destruction.

The callback functor is called just before notify_disconnect() that is disconnection execution function returns.

This functor is called with argument of corresponding ConnectorProfile. Since this ConnectorProfile will be destructed after calling this functor, modifications never affect others.

Parameters
on_disconnecteda pointer to ConnectionCallback's subclasses

Definition at line 599 of file PortBase.cpp.

void RTC::PortBase::setOnPublishInterfaces ( ConnectionCallback on_publish)

Setting callback called on publish interfaces.

This operation sets a functor that is called after publishing interfaces process when connecting between ports.

Since the ownership of the callback functor object is owned by the caller, it has the responsibility of object destruction.

The callback functor is called after calling publishInterfaces() that is virtual member function of the PortBase class with an argument of ConnectorProfile type that is same as the argument of publishInterfaces() function. Although by using this functor, you can modify the ConnectorProfile published by publishInterfaces() function, the modification should be done carefully for fear of causing connection inconsistency.

Parameters
on_publisha pointer to ConnectionCallback's subclasses

Definition at line 579 of file PortBase.cpp.

void RTC::PortBase::setOnSubscribeInterfaces ( ConnectionCallback on_subscribe)

Setting callback called on publish interfaces.

This operation sets a functor that is called before subscribing interfaces process when connecting between ports.

Since the ownership of the callback functor object is owned by the caller, it has the responsibility of object destruction.

The callback functor is called before calling subscribeInterfaces() that is virtual member function of the PortBase class with an argument of ConnectorProfile type that is same as the argument of subscribeInterfaces() function. Although by using this functor, you can modify ConnectorProfile argument for subscribeInterfaces() function, the modification should be done carefully for fear of causing connection inconsistency.

Parameters
on_subscribea pointer to ConnectionCallback's subclasses

Definition at line 584 of file PortBase.cpp.

void RTC::PortBase::setOnUnsubscribeInterfaces ( ConnectionCallback on_subscribe)

Setting callback called on unsubscribe interfaces.

This operation sets a functor that is called before unsubscribing interfaces process when disconnecting between ports.

Since the ownership of the callback functor object is owned by the caller, it has the responsibility of object destruction.

The callback functor is called before calling unsubscribeInterfaces() that is virtual member function of the PortBase class with an argument of ConnectorProfile type that is same as the argument of unsubscribeInterfaces() function. Although by using this functor, you can modify ConnectorProfile argument for unsubscribeInterfaces() function, the modification should be done carefully for fear of causing connection inconsistency.

Parameters
on_unsubscribea pointer to ConnectionCallback's subclasses

Definition at line 594 of file PortBase.cpp.

void RTC::PortBase::setOwner ( RTObject_ptr  owner)

Set the owner RTObject of the Port.

This operation sets the owner RTObject of this Port.

Parameters
ownerThe owner RTObject's reference of this Port

Definition at line 559 of file PortBase.cpp.

void RTC::PortBase::setPortConnectListenerHolder ( PortConnectListeners portconnListeners)

Setting PortConnectListener holder.

This operation sets a functor that is called when connection of this port does lost.

Parameters
on_connection_losta pointer to ConnectionCallback's subclasses

Definition at line 610 of file PortBase.cpp.

void RTC::PortBase::setPortRef ( PortService_ptr  port_ref)

Set the object reference of this Port.

Set the object reference of the Port.

This operation sets the object reference itself to the Port's PortProfile.

Parameters
port_refThe object reference of this Port.

Definition at line 531 of file PortBase.cpp.

void RTC::PortBase::setUUID ( ConnectorProfile &  connector_profile) const
protected

Generate and set the UUID to the ConnectorProfile.

Generate the UUID and set it to the ConnectorProfile.

This operation generates and set UUID to the ConnectorProfile.

Parameters
connector_profileConnectorProfile to be set connector_id

Definition at line 744 of file PortBase.cpp.

virtual ReturnCode_t RTC::PortBase::subscribeInterfaces ( const ConnectorProfile &  connector_profile)
protectedpure virtual

Publish interface information.

This operation is pure virutal function that would be called at the mid-flow of the notify_connect() process sequence. In the notify_connect(), the following methods would be called in order.

In the concrete Port, this method should be overridden. This method processes the given ConnectorProfile argument and if the given parameter is invalid, it would return error code of ReturnCode_t. The given argument ConnectorProfile includes all the interfaces information in it. Usually, subscribeInterafaces() method obtains information of interfaces from ConnectorProfile, and should set it to the interfaces that require them.
This operation should create the new connection for the new connector_id, and should update the connection for the existing connection_id.

Parameters
connector_profileThe connection profile information
Returns
The return code of ReturnCode_t type.

Implemented in RTC::CorbaPort, RTC::OutPortBase, and RTC::InPortBase.

virtual void RTC::PortBase::unsubscribeInterfaces ( const ConnectorProfile &  connector_profile)
protectedpure virtual

Disconnect interface connection.

This operation is pure virutal function that would be called at the end of the notify_disconnect() process sequence. In the notify_disconnect(), the following methods would be called in order to disconnect.

Parameters
connector_profileThe connection profile information

Implemented in RTC::CorbaPort, RTC::OutPortBase, and RTC::InPortBase.

void RTC::PortBase::updateConnectorProfile ( const ConnectorProfile &  connector_profile)
protected

Append or update the ConnectorProfile list.

This operation appends or updates ConnectorProfile of the Port by the given ConnectorProfile. If the connector_id of the given ConnectorProfile does not exist in the Port's ConnectorProfile list, the given ConnectorProfile would be append to the list. If the same id exists, the list would be updated.

Parameters
connector_profilethe ConnectorProfile to be appended or updated

Definition at line 799 of file PortBase.cpp.

void RTC::PortBase::updateConnectors ( )
protected

Disconnect ports that doesn't exist.

This function detects dead-port, and if dead ports are found in the connection list, disconnects them.

Definition at line 886 of file PortBase.cpp.

Member Data Documentation

int RTC::PortBase::m_connectionLimit
protected

The maximum number of connections.

Definition at line 2107 of file PortBase.h.

coil::Mutex RTC::PortBase::m_connectorsMutex
mutableprotected

Definition at line 2088 of file PortBase.h.

RTC::PortService_var RTC::PortBase::m_objref
protected

Object Reference of the Port.

Definition at line 2079 of file PortBase.h.

ConnectionCallback* RTC::PortBase::m_onConnected
protected

Callback functor objects.

This is a callback object that is called when the connection is completed.

Definition at line 2152 of file PortBase.h.

ConnectionCallback* RTC::PortBase::m_onConnectionLost
protected

Callback functor objects.

This is a callback object called when the connection of the port does lost.

Definition at line 2196 of file PortBase.h.

ConnectionCallback* RTC::PortBase::m_onDisconnected
protected

Callback functor objects.

This is a callback object that is called in connected release.

Definition at line 2180 of file PortBase.h.

ConnectionCallback* RTC::PortBase::m_onPublishInterfaces
protected

Callback functor objects.

This is callback objedct that is called when the interface is opened to the public.

Definition at line 2123 of file PortBase.h.

ConnectionCallback* RTC::PortBase::m_onSubscribeInterfaces
protected

Callback functor objects.

This is callback objedct that is called when the interface is got.

Definition at line 2137 of file PortBase.h.

ConnectionCallback* RTC::PortBase::m_onUnsubscribeInterfaces
protected

Callback functor objects.

This is a callback object that is called when the interface is released.

Definition at line 2166 of file PortBase.h.

std::string RTC::PortBase::m_ownerInstanceName
protected

Instance name.

Definition at line 2098 of file PortBase.h.

PortConnectListeners* RTC::PortBase::m_portconnListeners
protected

PortConnectListener holder.

Holders of PortConnectListeners

Definition at line 2211 of file PortBase.h.

PortProfile RTC::PortBase::m_profile
protected

PortProfile of the Port.

Definition at line 2070 of file PortBase.h.

coil::Mutex RTC::PortBase::m_profile_mutex
mutableprotected

Mutex of PortProfile.

Definition at line 2087 of file PortBase.h.

Logger RTC::PortBase::rtclog
mutableprotected

Logger stream.

Definition at line 2062 of file PortBase.h.


The documentation for this class was generated from the following files:


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:08:04