This page contains some tutorial examples that will help you getting started using StdAir. Most examples show how to construct some simple business objects, i.e., instances of the so-named Business Object Model (BOM).
The source code for these examples can be found in the batches
and test/stdair
directories. They are compiled along with the rest of the StdAir
project. See the User Guide (Users Guide) for more details on how to build the StdAir
project.
A few steps:
First, a BOM root object (i.e., a root for all the classes in the project) is instantiated by the stdair::STDAIR_ServiceContext
context object, when the stdair::STDAIR_Service
is itself instantiated. The corresponding StdAir
type (class) is stdair::BomRoot
.
In the following sample, that object is named ioBomRoot
, and is given as input/output parameter of the stdair::CmdBomManager::buildSampleBom()
method:
An airline inventory object can then be instantiated. Let us give it the "BA" airline code (corresponding to British Airways) as the object key. That is, an object (let us name it lBAKey
) of type (class) stdair::InventoryKey
has first to be instantiated.
Thanks to that key, an airline inventory object, i.e. of type (class) stdair::Inventory
, can be instantiated. Let us name that airline inventory object lBAInv
.
Then, both objects have to be linked: the airline inventory object (stdair::Inventory
) has to be linked with the root of the BOM tree (stdair::BomRoot
). That operation is as simple as using the stdair::FacBomManager::addToListAndMap()
method:
Another airline inventory object, corresponding to the Air France (Air France) company, is instantiated the same way:
See the corresponding full program (C++ Class Building Sample StdAir BOM Trees) for more details.
From the BomRoot
(of type stdair::BomRoot
) object instance, the list of airline inventories (of type stdair::Inventory
) can then be retrieved...
... and browsed:
See the corresponding full program (C++ Utility Class Browsing and Dumping the StdAir BOM Tree) for more details.
When the stdair.cpp
program is run (with the -b
option), the output should look like:
See the corresponding full program (Command-Line Utility to Demonstrate Typical StdAir Usage) for more details.
Now that we master how to instantiate the pre-defined StdAir classes, let us see how to extend that BOM.
For instance, let us assume that some (IT) provider (e.g., you) would like to have a specific implementation of the Inventory
object. The corresponding class has just to extend the stdair::Inventory
class:
The STL containers have to be defined accordingly too:
See the full class definition (Specific Implementation of an Airline Inventory) and implementation (Specific Implementation of an Airline Inventory) for more details.
The BOM root object (stdair::BomRoot
) is instantiated the classical way:
Then, the specific implementation of the airline inventory object (myprovider::Inventory
) can be instantiated the same way as a standard Inventory (stdair::Inventory
) would be:
Then, the specific implementation of the airline inventory object (myprovider::Inventory
) is linked to the root of the BOM tree (stdair::BomRoot
) the same way as the standard Inventory (stdair::Inventory
) would be:
Another specific airline inventory object is instantiated the same way:
From the BomRoot
(of type stdair::BomRoot
) object instance, the list of specific airline inventories (of type stdair::Inventory
) can then be retrieved...
... and browsed:
When this program is run, the output should look like:
See the corresponding full program (Command-Line Test to Demonstrate How To Extend StdAir BOM) for more details.