· The CORBA Component Model, Part 2: Defining Components with the IDL 3.x Types
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 size 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. In addition, the command above will generate export files that will portably handle platform specific issues of import/export declarations of dynamically linked libraries (DLLs). After executing the command above you should see the following output on your screen.
The following commands have been executed:
generate_export_file.pl STOCK_BASE_STUB > Stock_Base_stub_export.h
generate_export_file.pl STOCK_BASE_SKEL > Stock_Base_skel_export.h
· The MPC file should look like this.
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 parameter. The -p option states that the StockDistributor 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 StockDistirubotor.mpc file that contains several projects that will build the Stub, Servant, and Executor code respectively. In addition, the command above will generate export files that will portably handle platform specific issues of import/export declarations of dynamically linked libraries (DLLs). After executing the command above you should see the following output on your screen.
The following commands have been executed:
generate_export_file.pl STOCKDISTRIBUTOR_STUB > StockDistributor_stub_export.h
generate_export_file.pl STOCKDISTRIBUTOR_SVNT > StockDistributor_svnt_export.h
generate_export_file.pl STOCKDISTRIBUTOR_EXEC > StockDistributor_exec_export.h
· 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 -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. In addition, the command above will generate export files that will portably handle platform specific issues of import/export declarations of dynamically linked libraries (DLLs). After executing the command above you should see the following output on your screen.
The following commands have been executed:
generate_export_file.pl STOCKBROKER_STUB > StockBroker_stub_export.h
generate_export_file.pl STOCKBROKER_SVNT > StockBroker_svnt_export.h
generate_export_file.pl STOCKBROKER_EXEC > StockBroker_exec_export.h
· 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.
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