Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
RTC::CorbaPort Class Reference

RT Conponent CORBA service/consumer Port. More...

#include <CorbaPort.h>

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

List of all members.

Classes

class  CorbaConsumerHolder
 The structure to be stored Consumer information. More...
class  CorbaProviderHolder
 The structure to be stored Provider information. More...
struct  unsubscribe
 Functor to release Consumer's object. More...

Public Member Functions

 CorbaPort (const char *name)
 Constructor.
void init (coil::Properties &prop)
 Initializing properties.
bool registerConsumer (const char *instance_name, const char *type_name, CorbaConsumerBase &consumer)
 Register the consumer.
bool registerProvider (const char *instance_name, const char *type_name, PortableServer::RefCountServantBase &provider)
 Register the provider.
virtual ~CorbaPort (void)
 Virtual destructor.

Protected Member Functions

virtual void activateInterfaces ()
 Activate all Port interfaces.
virtual void deactivateInterfaces ()
 Deactivate all Port interfaces.
virtual ReturnCode_t publishInterfaces (ConnectorProfile &connector_profile)
 Publish information about interfaces.
virtual ReturnCode_t subscribeInterfaces (const ConnectorProfile &connector_profile)
 Subscribe to interface.
virtual void unsubscribeInterfaces (const ConnectorProfile &connector_profile)
 Unsubscribe interfaces.

Protected Attributes

coil::Properties m_properties
 Properties.

Private Types

typedef std::vector
< CorbaConsumerHolder
CorbaConsumerList
typedef std::vector
< CorbaProviderHolder
CorbaProviderList
 vector to stored Providers' information

Private Member Functions

virtual bool findProvider (const NVList &nv, CorbaConsumerHolder &cons, std::string &iorstr)
 Find out a provider corresponding to the consumer from NVList.
virtual bool findProviderOld (const NVList &nv, CorbaConsumerHolder &cons, std::string &iorstr)
 Find out a provider corresponding to the consumer from NVList.
bool releaseObject (const std::string &ior, CorbaConsumerHolder &cons)
 Releasing Consumer Object.
bool setObject (const std::string &ior, CorbaConsumerHolder &cons)
 Setting IOR to Consumer.

Private Attributes

CorbaConsumerList m_consumers
CorbaProviderList m_providers

Detailed Description

RT Conponent CORBA service/consumer Port.

CorbaPort is an implementation of the Port of RT-Component's that provides user-defined CORBA Object Service and Consumer.

RT-Component can provide user-defined CORBA serivces, which is called RT-Serivce (Provider), through the Ports. RT-Component can also provide place-holder, which is called RT-Serivce Consumer, to use other RT-Component's service.

The CorbaPort can manage any number of Providers and Consumers, can associate Consumers with correspondent Providers when establishing connection among Ports.

Usually, CorbaPort is used like the following.

 RTC::CorbaPort m_port0; // declaration of Port
 MyService_impl m_mysvc0; // Serivce Provider that is provided by the Port
 RTC::CorbaConsumer<YourService> m_cons0; // Consumer of the Port
 // register Service Provider to the Port
 m_port0.registerProvider("MyService0", "Generic", m_mysvc0);
 // register Service Consumer to the Port
 m_port0.registerConsumer("YourService0", "Generic", m_cons0 );
 // after connect established
 m_cons0->your_service_function(); // call a YourService's function
 // in another component that is connected with the Port
 m_cons1->my_service_function(); // call a MyService's function
 

Registering Service Provider by registerProvider(), it can be used from other RT-Components. Registering Service Consumer by registerConsumer(), other RT-Component's services can be used through the consumer object.

PortInterfaceProfile is a one of the profile information to store Provider interface and Consumer interface information. Tools or other RTCs should call one of the Port::connect() with an appropriate ConnectorProfile.

In addition, the instance name "*" declares a special type of instance.

When the name of the PROVIDED type interface that is the provider interface is "*", Provider interface's instance does not exist at the beginning of connection sequence. The instances will be created dynamically according to the consumer interface requirement at the connection sequence. Although the instance name does not exist at the beginning of connection sequence, the created providers shall publish its references to the ConnectorProfile with interface descriptor adequately in the interface publisher phase of the connection sequence.

If REQUIRED interface name that is Consumer interface name is "*", it shows that one Consumer interface is able to connect with multiple Provider interfaces. (This feature is not implemented.)

The following describes the rules that specify interface connection between ports.

The descriptor format of interfaces associated with Ports is declared as follows. Now some of interface properties are assumed as the followings.

The interface descriptors shall be declared as follows.

<rtc_iname>.port.<port_name>.<if_polarity>.<if_tname>.<if_iname>

When PROVIDED that is Provider interface properties are the followings,

MyComp0.port.myservice.provided.echo_interface.echo_interface2

And, when REQUIRED that is Consumer interfaces properties are the followings,

interface descriptor is as follows.

YourComp0.port.myservice.required.hoge_interface.hoge_inteface1

Specific instance name descriptors that are dynamically generated at the connection time are defined here.

When the "Dynamically generated" instance descriptor: "<type_name>*" is specified as interface descriptor that is required by consumers, the provider will generate a instance. If n consumers who demand a provider by the "<type_name>" descriptor exist, the following relation which processes the call from these consumers by one provider will be established.

 consumer0 ]---<
 consumer1 ]---<  O----[ provider0
 consumer2 ]---<
 

On the other hand, when incremental generated type instance name descriptor "<type_name>+" is specified as the provider interface descriptor whom consumers demand, provider's instances are dynamically generated for the number of the descriptors "<type_name>+". When n consumers who demand a provider by the descriptor "<type_name>+" exist the following relations in which n providers process each call from the consumers will be established.

 consumer0 ]---<  O----[ provider0
 consumer1 ]---<  O----[ provider1
 consumer2 ]---<  O----[ provider2
 

Describing the appropriate interface mapping specification in the ConnectorProfile::properties, selective connections between providers/consumers interface can be established at the time of connection. However, when different RTC instances of the same instance name exist in a connection, since an interface descriptor uniqueness cannot be guaranteed, this connection mapping rules cannot be used.

Here, assume that an interface descriptor is given as <if_desc0>, <if_desc1>, .... And assume that the key and the value of NVList in ConnectorProfile::properties are given as "key: value".

Now the case where the service ports of two components are connected is considered. When the service port of each component is the following,

      MyComp0                                 YourComp0
     _______ mycomp_service   yourcomp_service ______
            |                                 |
          |~~~|---O echo0         echo9 >---|~~~|
          |   |---< add0          add9  O---|   |
           ~T~                               ~T~
            |                                 |
 

Assume that connection between echo0 (provider) of MyComp0 component and echo9 (consumer) of YourComp0 component, and add0 (consumer) of MyComp0 and add0 (provider) of YourComp0 is established. In this case, ConnectorProfile is set up as follows.

 ConnectorProfile:
   name: any connector name
   connector_id: empty string
   ports[]: mycomp_service's reference, yourcomp_service's reference
   properties:
     <add0>: <add9>
     <echo9>: <echo0>
 

Please note that <add0>, <add9>, <echo0> and <echo9> are the following.

 <add0> is MyComp0.port.mycomp_service.required.add.add0
 <add9> is YourComp0.port.yourcomp_service.provided.add.add9
 <echo0> is MyComp0.port.mycomp_service.provided.echo.echo0
 <echo9> is YourComp0.port.yourcomp_service.required.echo.echo9
 

In the connection process, the provider and the consumer of each port carries out the following process respectively in the virtual functions such as CorbaPort::publishInterfaces() and CorbaPort::subscribeInerfaces().

A provider sets its IOR string as a value and its interface descriptor as a key in the ConnectorProfile::properties in a publishInterfaces() function. Since this interface descriptor's uniqueness is guaranteed in the current connector, the key of NameValue in the ConnectorProfile::properties is unique.

[This functionalities are not implemented] The dynamically generated provider is processed according to the following procedure. The publishInterface() function scans dynamic instance descriptors such as "<type_name>*" and "<type_name>+" in the ConnectorProfile::properties. When the dynamic generation instance descriptor "<tupe_name>*" exists, one instance of provider is generated, and its descriptor and its IOR string are set to ConnectorProfile::properties as the key and the value respectively. Simultaneously, in the ConnectorProfile::properties, all the instance descriptor with the dynamic generation instance name "<type_name>*" will be replaced with newly generated instance descriptor.

When the incremental dynamic generation instance descriptor exists, providers are generated for the number of the descriptors, and its descriptor and its IOR string are set to ConnectorProfile::properties as the key and the value respectively. Simultaneously, in the ConnectorProfile::properties, all the instance descriptor with the dynamic generation instance name "<type_name>+" will be replaced with newly generated instance descriptor.

The providers do not perform particular operation in subscribeInterfaces() function.

The consumers do not perform particular operation in publisherInterfaces() function.

On the other hand, a consumer searches a key-value pair with the key of consumer interface descriptor, and if the pair exists, it obtains provider's descriptor from the value. The consumer searches again a key-value pair with the key of provider interface descriptor, and it obtains provider's reference and the reference is set as the consumer's service object. In addition, reserved string "nil" or "null" are used not to set specific provider.

If consumer's interface descriptors does not exists in the ConnectorProfile::properties, the consumer searches a provider with same type name and instance name, and its reference is set to the consumer. This rule is for only backward compatibility, and it is not recommended from version 1.0.

The correspondence of a provider versus a consumer does not need to be one to one, and the case of one provider to n-consumers and the case of m-providers to one consumer are allowed. The one provider to n-consumers case can be realized by the above mentioned methods. The one consumer to m-provider case can be specified to set the consumer descriptor and comma-separated provider descriptors into the key and the value respectively.

The following option is available to specify the strictness of interfaces connection.

port.connection.strictness: strict, best_effort

strict: The connection is established, if only all the specified consumers are set appropriate references and narrowed successfully.

best_effort: The connection is established without any errors, even if appropriate reference does not exist or reference narrowing fails.

Since:
0.4.0

Definition at line 620 of file CorbaPort.h.


Member Typedef Documentation

Definition at line 1359 of file CorbaPort.h.

vector to stored Providers' information

Definition at line 1307 of file CorbaPort.h.


Constructor & Destructor Documentation

RTC::CorbaPort::CorbaPort ( const char *  name)

Constructor.

In the ctor, a given name is set into PortBase, and the following property is added to the PortProfile::properties,

  • port.port_type: "CorbaPort"
Parameters:
nameThe name of Port

Definition at line 36 of file CorbaPort.cpp.

RTC::CorbaPort::~CorbaPort ( void  ) [virtual]

Virtual destructor.

Definition at line 49 of file CorbaPort.cpp.


Member Function Documentation

void RTC::CorbaPort::activateInterfaces ( ) [protected, virtual]

Activate all Port interfaces.

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

Implements RTC::PortBase.

Definition at line 154 of file CorbaPort.cpp.

void RTC::CorbaPort::deactivateInterfaces ( ) [protected, virtual]

Deactivate all Port interfaces.

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

Implements RTC::PortBase.

Definition at line 171 of file CorbaPort.cpp.

bool RTC::CorbaPort::findProvider ( const NVList &  nv,
CorbaConsumerHolder cons,
std::string &  iorstr 
) [private, virtual]

Find out a provider corresponding to the consumer from NVList.

This function finds out a Provider with the key that is matched with Cosumer's name in the CorbaConsumerHolder, extracts IOR and performs narrowing into the Consumer and set it to the Consumer. False is returned when there is no corresponding key and IOR and the narrowing failed.

Parameters:
nvNVlist of ConnectorProfile::properties that includes Provider
consa Consumer holder to be matched with a Provider
Returns:
bool false is returned if there is no provider for the consumer

Definition at line 345 of file CorbaPort.cpp.

bool RTC::CorbaPort::findProviderOld ( const NVList &  nv,
CorbaConsumerHolder cons,
std::string &  iorstr 
) [private, virtual]

Find out a provider corresponding to the consumer from NVList.

This function is for the old version's compatibility.

This function finds out a Provider with the key that is matched with Cosumer's name in the CorbaConsumerHolder and extracts IOR. False is returned when there is no corresponding key and IOR.

Parameters:
nvNVlist of ConnectorProfile::properties that includes Provider
consa Consumer holder to be matched with a Provider
iorstrvariable which is set IOR string
Returns:
bool false is returned if there is no provider for the consumer

Definition at line 386 of file CorbaPort.cpp.

Initializing properties.

This operation initializes outport's properties. If a property "connection_limit" is set and appropriate value is set to this property value, the number of maximum connection is set as this value. If the property does not exist or invalid value is set to this property, the maximum number of connection will be set unlimited.

Parameters:
propproperties of the CorbaPort

Definition at line 60 of file CorbaPort.cpp.

ReturnCode_t RTC::CorbaPort::publishInterfaces ( ConnectorProfile &  connector_profile) [protected, virtual]

Publish information about interfaces.

Publish interface information.

This operation publishes Provider interfaces information, which is owned by this port, to the other Ports via ConnectorProfile::properties. Now it is assumed RTC instance name and other information is as follows,

  • RTC instance name: rtc_iname
  • Port name: port_name
  • Interface polarity: if_polarity
  • Interface type name: if_tname
  • Interface instance name: if_iname

the following values are stored as the "name" and the "value" of the NameValue typee element in ConnectorProfile::properties.

  • name <rtc_iname>.port.<port_name>.provided.<if_tname>.<if_iname>
  • value IOR string value of interface reference

In addition, although the following NameValue values are also stored for the backward compatibility, this will be deleted in the future version.

  • name port.<if_tname>.<if_iname>
  • value IOR string value of interface reference

These values are stored in the ConnectorProfile::properties and are propagated to the other Ports. If the Consumer interface exists that requires this Provider interface, it will retrieve reference from the ConnectorProfile and utilize it.

Parameters:
connector_profileConnector profile
Returns:
The return code of ReturnCode_t type

Implements RTC::PortBase.

Definition at line 192 of file CorbaPort.cpp.

bool RTC::CorbaPort::registerConsumer ( const char *  instance_name,
const char *  type_name,
CorbaConsumerBase consumer 
)

Register the consumer.

This operation registers a consumer, which is a service placeholder this port requires. These are associated internally with specified instance_name, type_name and Consumer itself to the argument as service's instance name and its type name associated with Consumer. The service Provider interface' references will be set automatically to the Consumer Interface object when connections are established, according to the rules that are described at the subscribeInterface() function's documentation.

Parameters:
instance_nameInstance name of the service Consumer requires
type_nameType name of the service Consumer requires
consumerCORBA service consumer
Returns:
False would be returned if the same instance_name was registered

Definition at line 125 of file CorbaPort.cpp.

bool RTC::CorbaPort::registerProvider ( const char *  instance_name,
const char *  type_name,
PortableServer::RefCountServantBase &  provider 
)

Register the provider.

This operation registers a servant, which is provided in this Port, to the Port. The servant is associated with "instance_name" and "type_name" as the instance name of the servant and as the type name of the servant. A given servant will be stored in the CorbaPort, and this is registered as RTC::PROVIDED interface into the PortInterfaceProfile.

Parameters:
instance_nameInstance name of servant
type_nameType name of the servant
providerCORBA servant
Returns:
Return false if the same name of instance_name is already registered.

Definition at line 90 of file CorbaPort.cpp.

bool RTC::CorbaPort::releaseObject ( const std::string &  ior,
CorbaConsumerHolder cons 
) [private]

Releasing Consumer Object.

This function releases object reference of Consumer. If the given IOR string is different from Consumer's IOR string, it returns false.

Parameters:
iorIOR string
consConsumer holder

bool False if IOR and Consumer's IOR are different

Definition at line 442 of file CorbaPort.cpp.

bool RTC::CorbaPort::setObject ( const std::string &  ior,
CorbaConsumerHolder cons 
) [private]

Setting IOR to Consumer.

This function performs narrowing into the Consumer and set it to the Consumer. False is returned when the narrowing failed. But, if IOR string is "null" or "nil", this function returns true.

Parameters:
iorIOR string
consConsumer holder

bool false if narrowing failed.

Definition at line 414 of file CorbaPort.cpp.

ReturnCode_t RTC::CorbaPort::subscribeInterfaces ( const ConnectorProfile &  connector_profile) [protected, virtual]

Subscribe to interface.

Subscribe to interfaces.

Retrieve information associated with Provider matches Consumer owned by this port and set the object reference to Consumer.

Now, Consumer is registered as the following:

  PortInterfaceProfile
  {
    instance_name = "PA10_0";
    type_name     = "Manipulator";
    polarity      = REQUIRED;
  }
 

Find the object reference of Serivce Provider that is registered as the following of other ports:

  PortInterfaceProfile
  {
    instance_name = "PA10_0";
    type_name     = "Manipulator";
    polarity      = PROVIDED;
  }
 

and set to Consumer. In fact, find NameValue that is registered as the following to ConnectorProfile::properties:

 NameValue = { "port.Manipulator.PA10_0": <Object reference>=""> }
 

and set the object reference to Consumer.

Parameters:
connector_profileConnector profile
Returns:
The return code of ReturnCode_t type

Implements RTC::PortBase.

Definition at line 256 of file CorbaPort.cpp.

void RTC::CorbaPort::unsubscribeInterfaces ( const ConnectorProfile &  connector_profile) [protected, virtual]

Unsubscribe interfaces.

Release all Objects that was set in Consumer associated with the given ConnectorProfile.

Parameters:
connector_profileConnector profile

Implements RTC::PortBase.

Definition at line 312 of file CorbaPort.cpp.


Member Data Documentation

Definition at line 1360 of file CorbaPort.h.

Properties.

Definition at line 1070 of file CorbaPort.h.

Definition at line 1308 of file CorbaPort.h.


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


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:20