RTC::CorbaPort Class Reference

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

#include <CorbaPort.h>

Inheritance diagram for RTC::CorbaPort:

RTC::PortBase

List of all members.

Public Member Functions

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

Protected Member Functions

virtual ReturnCode_t publishInterfaces (ConnectorProfile &connector_profile)
 Publish interface information.
virtual ReturnCode_t subscribeInterfaces (const ConnectorProfile &connector_profile)
 Subscribe to interface.
virtual void unsubscribeInterfaces (const ConnectorProfile &connector_profile)
 Unsubscribe interfaces.

Classes

struct  Consumer
 The structure to be stored Consumer information.
struct  subscribe
 Functor to compare ConnectorProfile and Consuemr, to set object reference.
struct  unsubscribe
 Functor to release Consumer's object.


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.

Since:
0.4.0

Constructor & Destructor Documentation

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

Constructor.

Parameters:
name The name of Port

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

Virtual destructor.


Member Function Documentation

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.

Parameters:
instance_name Instance name of servant
type_name Type name of the servant
provider CORBA servant
Returns:
Return false if the same name of instance_name is already registered.

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 by specified instance_name, type_name and Consumer itself to the argument as service's instance name and its type name associated with Consumer. If the service with the same instance_name and type_name is provided by the other port when connecting between ports, its service object reference will be set automatically.

Parameters:
instance_name Instance name of the service Consumer requires
type_name Type name of the service Consumer requires
consumer CORBA service consumer
Returns:
False would be returned if the same instance_name was registered

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

Publish interface information.

Assign information associated with Provider owned by this Port to ConnectorProfile::properties. In assignment information, the following is stored as NVList name and its value.

Here,

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

so,

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

The above value is set to ConnectorProfile::properties and sent to other ports. If Consumer that uses this interface in other Port exists, the object references will be got and use from the key of ConnectorProfile.

Parameters:
connector_profile Connector profile
Returns:
The return code of ReturnCode_t type

Implements RTC::PortBase.

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

Subscribe to interface.

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_profile Connector profile
Returns:
The return code of ReturnCode_t type

Implements RTC::PortBase.

virtual 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_profile Connector profile

Implements RTC::PortBase.


Generated on Wed May 21 05:17:34 2008 for OpenRTM by  doxygen 1.5.3