### 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

### · In the beginning of this tutorial, we're using a perl scripts which creates the MPC files for you. This script is called generate_component_mpc.pl and is located in $CIAO_ROOT/bin.

### · When running this script, please use the full path to the CIAO bin directory instead of $CIAO_ROOT/bin on Linux or %CIAO_ROOT%\bin on Windows.

### · To understand the meaning of different parameters passed to generate_component_mpc.pl type the following command:
generate_component_mpc.pl -h

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 –e –l ../lib –o ../lib 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. Since we're using events in this tutorial, we need to add –e to the command line. The MPC file should look like this.
Mind that "-o" (library output) and "-l" (path to libraries) 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 –e –p Stock_Base –c StockDistributorDriver –o ../lib –l ../lib 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.

Broker:

· In the `Quoter/Broker` `sub-directory,` place an idl file `StockBroker.id` `l` 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 –e –p Stock_Base –c StockBrokerDriver –o ../lib –l ../lib 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.

Previous Next