Step 1: Define your interfaces and component types

 

Please make sure to read the following article to under the Stock Quoter system architecture before delving further into the tutorial:

·       The CORBA Component Model, Part 2: Defining Components with the IDL 3.x Types

 

Directory Structure:

The tutorial relies on the following directory structure. Create Quoter and all its subdirectories as shown below. We will describe the purpose of these directories later in the tutorial.

Quoter

                 |---- descriptors

                 |---- Stock_Base

                 |---- Distributor

                 |---- Broker

 

Preliminaries:

·       We use the Make Project Creator (MPC) throughout this tutorial. Understanding MPC will aid you in understanding this tutorial. For more information on MPC please look at the following:

1.     MPC Chapter.

2.     $ACE_ROOT/MPC/README

Interface Design:

·       In the Quoter/Stock_Base sub-directory, place an idl file Stock_Base.idl that you could copy from here . This file defines the interfaces and events that will be used by both StockDistributor and StockBroker components. We put together the common interface definitions so the base library can be shared by both components, reducing the footprint of "real" components.

·       Next, we need to create a Make Project Creator (MPC) file to generate the make files for us. From the Quoter/Stock_Base subdirectory, type the following command:

generate_component_mpc.pl –n Stock_Base

The command above will generate a Stock_Base.mpc file that contains two projects Stock_Base_stub and Stock_Base_skel for the Stub and Servant code respectively. The MPC file should look like this.
Mind that "libout" and "libpaths" are added. This is done to make the compilation of this example easier and at runtime, all deliveralbes are in one directory. Beware that you need to add this directory to your system path when running the executables (see page 4).

Component Design:

Distributor:   

·       In the Quoter/Distributor sub-directory, place an idl file StockDistributor.idl that looks like this. This file defines the StockDistributor component interfaces.

·       Next, we need to create a Make Project Creator (MPC) file to generate the make files for us. From the Quoter/Distributor  sub-directory, type the following command

generate_component_mpc.pl -p Stock_Base -c StockDistributorDriver StockDistributor

The command above takes a few optional parameters. The -p option indicates that the StockDistributor component has a dependency on Stock_Base, the -c option causes the script to generate MPC files for a simple driver program. In this tutorial, we use a simple driver program to demonstrate how a non-CCM applications can interact with component applications.

The command above will generate a StockDistributor.mpc file that contains several projects that will build the Stub, Servant, and Executor code respectively.

·     Next we write a simple driver program (StockDistributorDriver.cpp) that will control the StockDistributor component. The simple driver program controls when the StockDistributor component publishes stock quotes, the rates of publication, and when publication of stock quotes stops. The simple driver program should look like this.

·       The generated MPC file should look like this. Both "libout" and "libpaths" are added again.

Broker:

·       In the Quoter/Broker sub-directory, place an idl file StockBroker.idl that looks like this. This file defines the StockBroker component interface.

·       Next, we need to create a Make Project Creator (MPC) file to generate the make files for us. From the Quoter/Broker sub-directory, type the following command:

generate_component_mpc.pl -p Stock_Base -c StockBrokerDriver StockBroker

The command above takes a few optional parameter. The -p option states that the StockBroker component has a dependency on Stock_Base, the -c option causes the script to generates make files for a simple driver program. In this tutorial, we use a simple driver program to demonstrate how a non-CCM applications can interact with Components.

The command above will generate a StockBroker.mpc file that contains several projects that will build the Stub, Servant, and Executor code respectively.

·       Next we write a simple driver program (StockBrokerDriver.cpp) that would control the StockBroker component. The simple driver program controls what stocks the StockBroker component subscribes to. The simple driver program should look like this.

·       The generated MPC file should look like this. Both "libout" and "libpaths" are added again.


Note:

To understand the meaning of different parameters passed to generate_component_mpc.plclick here or type the following command:

generate_component_mpc.pl -h

Previous                                                                                              Next


Ming Xiong
Abdullah Sowayan
 
$Id: 01.html 86021 2009-07-14 12:14:35Z wotte $