#include <PortBase.h>
Public Member Functions | |
PortBase (const char *name="") | |
Constructor. | |
virtual | ~PortBase (void) |
Destructor. | |
virtual PortProfile * | get_port_profile () throw (CORBA::SystemException) |
[CORBA interface] Get the PortProfile of the Port | |
const PortProfile & | getPortProfile () const |
Get the PortProfile of the Port. | |
virtual ConnectorProfileList * | get_connector_profiles () throw (CORBA::SystemException) |
[CORBA interface] Get the ConnectorProfileList of the Port | |
virtual ConnectorProfile * | get_connector_profile (const char *connector_id) throw (CORBA::SystemException) |
[CORBA interface] Get the ConnectorProfile | |
virtual ReturnCode_t | connect (ConnectorProfile &connector_profile) throw (CORBA::SystemException) |
[CORBA interface] Connect the Port | |
virtual ReturnCode_t | notify_connect (ConnectorProfile &connector_profile) throw (CORBA::SystemException) |
[CORBA interface] Notify the Ports connection | |
virtual ReturnCode_t | disconnect (const char *connector_id) throw (CORBA::SystemException) |
[CORBA interface] Disconnect the Port | |
virtual ReturnCode_t | notify_disconnect (const char *connector_id) throw (CORBA::SystemException) |
[CORBA interface] Notify the Ports disconnection | |
virtual ReturnCode_t | disconnect_all () throw (CORBA::SystemException) |
[CORBA interface] Disconnect the All Ports | |
virtual void | activateInterfaces ()=0 |
Activate all Port interfaces. | |
virtual void | deactivateInterfaces ()=0 |
Deactivate all Port interfaces. | |
void | setName (const char *name) |
Set the name of this Port. | |
const PortProfile & | getProfile () const |
Get the PortProfile of the Port. | |
void | setPortRef (PortService_ptr port_ref) |
Set the object reference of this Port. | |
PortService_ptr | getPortRef () |
Get the object reference of this Port. | |
void | setOwner (RTObject_ptr owner) |
Set the owner RTObject of the Port. | |
Protected Types | |
typedef coil::Guard < coil::Mutex > | Guard |
Protected Member Functions | |
virtual ReturnCode_t | publishInterfaces (ConnectorProfile &connector_profile)=0 |
Publish interface information. | |
virtual ReturnCode_t | connectNext (ConnectorProfile &connector_profile) |
Call notify_connect() of the next Port. | |
virtual ReturnCode_t | disconnectNext (ConnectorProfile &connector_profile) |
Call notify_disconnect() of the next Port. | |
virtual ReturnCode_t | subscribeInterfaces (const ConnectorProfile &connector_profile)=0 |
Publish interface information. | |
virtual void | unsubscribeInterfaces (const ConnectorProfile &connector_profile)=0 |
Disconnect interface connection. | |
bool | isEmptyId (const ConnectorProfile &connector_profile) const |
Check whether connector_id of ConnectorProfile is empty. | |
const std::string | getUUID () const |
Generate the UUID. | |
void | setUUID (ConnectorProfile &connector_profile) const |
Generate and set the UUID to the ConnectorProfile. | |
bool | isExistingConnId (const char *id) |
Check whether the given id exists in stored ConnectorProfiles. | |
ConnectorProfile | findConnProfile (const char *id) |
Find ConnectorProfile with id. | |
CORBA::Long | findConnProfileIndex (const char *id) |
Find ConnectorProfile with id. | |
void | updateConnectorProfile (const ConnectorProfile &connector_profile) |
Append or update the ConnectorProfile list. | |
bool | eraseConnectorProfile (const char *id) |
Delete the ConnectorProfile. | |
bool | appendInterface (const char *name, const char *type_name, PortInterfacePolarity pol) |
Append an interface to the PortInterfaceProfile. | |
bool | deleteInterface (const char *name, PortInterfacePolarity pol) |
Delete the interface registration from the PortInterfaceProfile. | |
template<class ValueType> | |
void | addProperty (const char *key, ValueType value) |
Add NameValue data to PortProfile's properties. | |
void | appendProperty (const char *key, const char *value) |
Protected Attributes | |
Logger | rtclog |
PortProfile | m_profile |
PortProfile of the Port. | |
RTC::PortService_var | m_objref |
Object Reference of the Port. | |
coil::Mutex | m_profile_mutex |
Classes | |
struct | connect_func |
Functor to connect Ports. More... | |
struct | disconnect_all_func |
Functor to disconnect all Ports. More... | |
struct | disconnect_func |
Functor to disconnect Ports. More... | |
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... | |
struct | if_name |
Functor to find a PortInterfaceProfile named instance_name. More... |
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.
typedef coil::Guard<coil::Mutex> RTC::PortBase::Guard [protected] |
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.
name | The name of Port (The default value:"") |
virtual RTC::PortBase::~PortBase | ( | void | ) | [virtual] |
Destructor.
Destructor
virtual 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. PortProfile struct has the following members:
const PortProfile& RTC::PortBase::getPortProfile | ( | ) | const |
Get the PortProfile of the Port.
Get the PortProfile of this Port.
virtual 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. 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:
virtual 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. If ConnectorProfile with specified connector_id is not included, empty ConnectorProfile is returned.
connector_id | ID of the ConnectorProfile |
virtual 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. Application programs, which is going to establish the connection among Ports owned by RT-Components, have to set valid values to the ConnectorProfile and give it to the argument of connect() operation.
name, ports and properties which are members of ConnectorProfile, should be set valid values before giving to the argument of connect() operation.
The following sequences are executed in connect() of OutPort side.
1. Create and set connector information associated with OutPort.
2. Get connector information associated with InPort.
3. Invoke PortBase::connect(). Execute the basic processing of Port's connection.
4. If the reference of InPort cannot be got (by step2), get connector information associated with InPort again.
5. Initialize on OutPort side from information given by ConnectorProfile::properties.
6. If error occurs in one of the above processings, return error. If processing has completed successfully, return RTC::RTC_OK.
connector_profile | The ConnectorProfile. |
virtual ReturnCode_t RTC::PortBase::notify_connect | ( | ConnectorProfile & | connector_profile | ) | throw (CORBA::SystemException) [virtual] |
[CORBA interface] Notify the Ports connection
This operation is invoked between Ports internally when the connection is established. A ConnectorProfile has a sequence of port references. This Port stores the ConnectorProfile and invokes the notify_connect operation of the next Port in the sequence. As ports are added to the connector, Port references are added to the ConnectorProfile and provided to the caller. In this way, notification of connection is propagated with the ConnectorProfile.
connector_profile | The ConnectorProfile. |
virtual 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 when the connection established. This port invokes the notify_disconnect of one of the ports included a port list in ConnectorProfile stored when the connection was established. The notification of disconnection is executed by the notify_disconnect.
connector_id | The ID of the ConnectorProfile. |
virtual 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. This operation notifies a disconnection between corresponding port and the other ports. The disconnected Port is identified by the given ID. This port invokes the notify_disconnect operation of the next Port in the sequence of the ConnectorProfile that was stored when the connection was established. As ports are disconnected, corresponding port information are removed from the ConnectorProfile. In this way, the notification of disconnection is propagated by the notify_disconnect operation.
connector_id | The ID of the ConnectorProfile. |
virtual 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.
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::InPortBase, and RTC::OutPortBase.
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::InPortBase, and RTC::OutPortBase.
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.
name | The name of this Port. |
const PortProfile& RTC::PortBase::getProfile | ( | ) | const |
Get the PortProfile of the Port.
This operation returns const reference of the PortProfile.
void RTC::PortBase::setPortRef | ( | PortService_ptr | port_ref | ) |
Set the object reference of this Port.
This operation sets the object reference itself to the Port's PortProfile.
port_ref | The object reference of this Port. |
PortService_ptr RTC::PortBase::getPortRef | ( | ) |
Get the object reference of this Port.
This operation returns the object reference that is stored in the Port's PortProfile.
void RTC::PortBase::setOwner | ( | RTObject_ptr | owner | ) |
Set the owner RTObject of the Port.
This operation sets the owner RTObject of this Port.
owner | The owner RTObject's reference of this Port |
virtual ReturnCode_t RTC::PortBase::publishInterfaces | ( | ConnectorProfile & | connector_profile | ) | [protected, pure 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.
connector_profile | The connection profile information |
Implemented in RTC::CorbaPort, RTC::InPortBase, and RTC::OutPortBase.
virtual ReturnCode_t RTC::PortBase::connectNext | ( | ConnectorProfile & | connector_profile | ) | [protected, virtual] |
Call notify_connect() of the next Port.
This operation calls the notify_connect() of the next Port's that stored in ConnectorProfile's port_ref sequence.
connector_profile | The connection profile information |
virtual ReturnCode_t RTC::PortBase::disconnectNext | ( | ConnectorProfile & | connector_profile | ) | [protected, virtual] |
Call notify_disconnect() of the next Port.
This operation calls the notify_disconnect() of the next Port's that stored in ConnectorProfile's port_ref sequence.
connector_profile | The connection profile information |
virtual ReturnCode_t RTC::PortBase::subscribeInterfaces | ( | const ConnectorProfile & | connector_profile | ) | [protected, pure 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.
connector_profile | The connection profile information |
Implemented in RTC::CorbaPort, RTC::InPortBase, and RTC::OutPortBase.
virtual void RTC::PortBase::unsubscribeInterfaces | ( | const ConnectorProfile & | connector_profile | ) | [protected, pure 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.
connector_profile | The connection profile information |
Implemented in RTC::CorbaPort, RTC::InPortBase, and RTC::OutPortBase.
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.
connector_profile | Target ConnectorProfile for the check |
const std::string RTC::PortBase::getUUID | ( | ) | const [protected] |
Generate the UUID.
This operation generates UUID.
void RTC::PortBase::setUUID | ( | ConnectorProfile & | connector_profile | ) | const [protected] |
Generate and set the UUID to the ConnectorProfile.
This operation generates and set UUID to the ConnectorProfile.
connector_profile | ConnectorProfile to be set connector_id |
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.
id | connector_id to be find in Port's ConnectorProfiles |
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.
id | the connector_id to be searched in Port's ConnectorProfiles |
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.
id | the connector_id to be searched |
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.
connector_profile | the ConnectorProfile to be appended or updated |
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.
id | The id of the ConnectorProfile to be deleted. |
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.
name | The instance name of the interface. | |
type_name | The type name of the interface. | |
pol | The interface's polarity (RTC::PROVIDED or RTC:REQUIRED) |
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.
name | The instance name of the interface. | |
pol | The interface's polarity (RTC::PROVIDED or RTC:REQUIRED) |
void RTC::PortBase::addProperty | ( | const char * | key, | |
ValueType | value | |||
) | [inline, protected] |
Add NameValue data to PortProfile's properties.
Add NameValue data to PortProfile's properties. Type of additional data is specified by ValueType.
key | The name of properties | |
value | The value of properties |
void RTC::PortBase::appendProperty | ( | const char * | key, | |
const char * | value | |||
) | [inline, protected] |
Logger RTC::PortBase::rtclog [mutable, protected] |
PortProfile RTC::PortBase::m_profile [protected] |
PortProfile of the Port.
RTC::PortService_var RTC::PortBase::m_objref [protected] |
Object Reference of the Port.
coil::Mutex RTC::PortBase::m_profile_mutex [mutable, protected] |