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