This example illustrates how to use the CIAO static configurator to build applications using RTCORBA policies statically. From the BasicSP directory do the following.

> cd descriptors
> $CIAO_ROOT/tools/static_configurator/Static_Assembly_Parser -a BasicSP-rt.cad

The following files are generated -

Static_Assembly_Config.h
Static_CCM_App.cpp
Static_CCM_App.mpc

Static_Assembly_Config.h contains the intermediate representation of all the parsed component and assembly information obtained from the XML files. Static_CCM_App.cpp  contains the main driver application. Here a runtime static configuration engine is used to create containers, homes, components, etc and then establish necessary connections between the components. The configuration engine is also used to configure the containers and RTORB with the appropriate RTCORBA policies specified declaratively in the .rtcad file. In the BasicSP example, an external controller  (see $CIAO_ROOT/examples/OEP/BasicSP/README) is used to start or stop a pulser. The generated main driver application (Static_CCM_App.cpp) is modified to add code to trigger the pulser object on. The generated .mpc file is modified to add all other necessary files so that the application can be built statically. Note that the static configurator only generates only certain file names in the .mpc file. These filenames are obtained from the XML descriptor files. All other necessary files have to be added manually as indicated.

Now the static build files can be generated by running the mpc utility.

> cd ..
> $ACE_ROOT/bin/mpc -static Static_CCM_App.mpc

Static_Assembly_Config.h
#include "Static_Assembly.h"

#include "CCM_ContainerC.h"
#include "Container_Base.h"

//Containers
CIAO::Static_Config::ContainerAttributes containers_table_[]=
{
    {"POLICY_1", 0},
    {"", 0}
};


extern "C" ::Components::HomeExecutorBase_ptr createECHome_Impl (void);
extern "C" ::PortableServer::Servant createECHome_Servant
        (::Components::HomeExecutorBase_ptr p,
        ::CIAO::Session_Container *c
        ACE_ENV_ARG_DECL_WITH_DEFAULTS);
extern "C" ::Components::HomeExecutorBase_ptr createBMDeviceHome_Impl (void);
extern "C" ::PortableServer::Servant createBMDeviceHome_Servant
        (::Components::HomeExecutorBase_ptr p,
        ::CIAO::Session_Container *c
        ACE_ENV_ARG_DECL_WITH_DEFAULTS);
extern "C" ::Components::HomeExecutorBase_ptr createBMClosedEDHome_Impl (void);
extern "C" ::PortableServer::Servant createBMClosedEDHome_Servant
        (::Components::HomeExecutorBase_ptr p,
        ::CIAO::Session_Container *c
        ACE_ENV_ARG_DECL_WITH_DEFAULTS);
extern "C" ::Components::HomeExecutorBase_ptr createBMDisplayHome_Impl (void);
extern "C" ::PortableServer::Servant createBMDisplayHome_Servant
        (::Components::HomeExecutorBase_ptr p,
        ::CIAO::Session_Container *c
        ACE_ENV_ARG_DECL_WITH_DEFAULTS);
//Homes
CIAO::Static_Config::HomeAttributes homes_table_[]=
{
    {"a_ECHome", "DCE:3148F760-F2ED-4204-A775-6B972C10E8CB", "createECHome_Impl", createECHome_Impl, "DCE:75309233-0E0A-4cfb-B186-3E99F69B1D40", "createECHome_Servant", createECHome_Servant, 0, 0 },
    {"a_BMDeviceHome", "DCE:82C2B032-37F0-4315-A59F-7020D3264E4D", "createBMDeviceHome_Impl", createBMDeviceHome_Impl, "DCE:93D254CF-9538-44e8-BB98-AABCD134ADD3", "createBMDeviceHome_Servant", createBMDeviceHome_Servant, 0, 0 },
    {"a_BMClosedEDHome", "DCE:8E6C468D-A39F-46b4-962B-265F1AA8D538", "createBMClosedEDHome_Impl", createBMClosedEDHome_Impl, "DCE:CDC06FCA-50FC-43ca-8ECC-BEFBD33FEE78", "createBMClosedEDHome_Servant", createBMClosedEDHome_Servant, 0, 0 },
    {"a_BMDisplayHome", "DCE:8E92655E-CA07-46C8-B127-0F0872A8CC29", "createBMDisplayHome_Impl", createBMDisplayHome_Impl, "DCE:D7984625-8561-431d-9927-4E498B317C02", "createBMDisplayHome_Servant", createBMDisplayHome_Servant, 1, 0 }
};


//Components
CIAO::Static_Config::ComponentAttributes components_table_[]=
{
    {"a_EC", 0, 0, 0 },
    {"a_BMDevice", -1, -1, 1 },
    {"a_BMClosedED", -1, -1, 2 },
    {"a_BMDisplay", -1, -1, 3 }
};


//Component Registrations
CIAO::Assembly_Placement::componentinstantiation::Register_Info component_registrations_table_[]=
{
    {CIAO::Assembly_Placement::componentinstantiation::COMPONENT, CIAO::Assembly_Placement::componentinstantiation::IORFILE, "", "ec.ior" }
};


//Connections
CIAO::Static_Config::ConnectionAttributes connections_table_[]=
{
    {CIAO::Assembly_Connection::PUBLISHER_CONSUMER, "", "timeout", 0, 1, 0, 0 },
    {CIAO::Assembly_Connection::PUBLISHER_CONSUMER, "", "data_available", 3, 4, 0, 0 },
    {CIAO::Assembly_Connection::PUBLISHER_CONSUMER, "", "out_avail", 6, 7, 0, 0 },
    {CIAO::Assembly_Connection::INTERFACE, "", "datain", 9, 10, 0, 0 },
    {CIAO::Assembly_Connection::INTERFACE, "", "comp_data", 12, 13, 0, 0 }
};


//Resolver Infos
CIAO::Static_Config::ResolveInfoAttributes resolvers_table_[]=
{
    {CIAO::Assembly_Connection::COMP_IDREF, "a_EC", -1, 0 },
    {CIAO::Assembly_Connection::CONSUMER, "timeout", 2, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMDevice", -1, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMDevice", -1, 0 },
    {CIAO::Assembly_Connection::CONSUMER, "in_avail", 5, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMClosedED", -1, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMClosedED", -1, 0 },
    {CIAO::Assembly_Connection::CONSUMER, "data_ready", 8, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMDisplay", -1, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMClosedED", -1, 0 },
    {CIAO::Assembly_Connection::PROVIDER, "data_read", 11, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMDevice", -1, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMDisplay", -1, 0 },
    {CIAO::Assembly_Connection::PROVIDER, "dataout", 14, 0 },
    {CIAO::Assembly_Connection::COMP_IDREF, "a_BMClosedED", -1, 0 }
};


//Thread Pool
CIAO::Static_Config::ThreadPoolAttributes thread_pool_table_[]=
{
    {"common_pool", 0, 10, 20, 1, 0, 0, 0},
    {"high_prio_pool", 0, 2, 2, 3, 0, 0, 0}
};


//Lanes
CIAO::Static_Config::LaneAttributes lane_table_[]=
{
    {1, 100, 300},
    {2, 2, 2},
    {3, 1, 2},
    {1, 10, 30},
    {2, 3, 3},
    {3, 1, 2}
};


//ThreadPoolLanes
CIAO::Static_Config::ThreadPoolLanesAttributes thread_pool_lanes_table_[]=
{
    {"shared_pool", 0, 0, 2, 0, 0, 0, 0},
    {"laned_pool", 0, 3, 5, 0, 0, 0, 0}
};


//Bands
CIAO::Static_Config::BandAttributes band_table_[]=
{
    {1, 1},
    {2, 2},
    {3, 3000}
};


//PriorityBands
CIAO::Static_Config::PriorityBandsAttributes priority_band_table_[]=
{
    {"common_conn", 0, 2}
};


//Policy Configs
CIAO::Static_Config::PolicyConfigAttributes policy_config_table_[]=
{
    {RTCORBA::PRIORITY_MODEL_POLICY_TYPE, "", RTCORBA::SERVER_DECLARED, 2},
    {RTCORBA::THREADPOOL_POLICY_TYPE, "shared_pool", /*dummy variable*/ RTCORBA::CLIENT_PROPAGATED, 0},
    {RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE, "common_conn", /*dummy variable*/ RTCORBA::CLIENT_PROPAGATED, 0},
    {RTCORBA::THREADPOOL_POLICY_TYPE, "common_pool", /*dummy variable*/ RTCORBA::CLIENT_PROPAGATED, 0},
    {RTCORBA::PRIORITY_MODEL_POLICY_TYPE, "", RTCORBA::CLIENT_PROPAGATED, 2}
};


//Policy Set
CIAO::Static_Config::PolicySetAttributes  policy_set_table_[]=
{
    {"POLICY_1", 0, 2},
    {"POLICY_2", 3, 4}
};

Modified Static_CCM_App.cpp

(Highlighted text is manually added to the generated .cpp file)

#include "RTServer_Impl.h"
#include "CIAO_ServersC.h"
#include "Server_init.h"
#include "Static_Configurator.h"
#include "ace/SString.h"
#include "ace/Get_Opt.h"
#include "Static_Assembly_Config.h"
#include "tao/RTPortableServer/RTPortableServer.h"
#include "EC/ECC.h"

char *ior_file_name_ = "comp_serv.ior";
int rate = 2;
int
parse_args (int argc, char *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, "k:o:");
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
    {
    case 'o':  // get the file name to write to
     ior_file_name_ = get_opts.opt_arg ();
     break;

    case '?':  // display help for use of the server.
    default:
       ACE_ERROR_RETURN ((LM_ERROR,
                          "usage:  %s\n"
                          "-o <ior_output_file>\n"
                          "\n",
                          argv [0]),
                         -1);
     }

  return 0;
}

int
main (int argc, char *argv[])
{
 ACE_TRY_NEW_ENV
 {
     // Initialize orb
     CORBA::ORB_var orb = CORBA::ORB_init (argc,
                                           argv
                                           ACE_ENV_ARG_PARAMETER);

     ACE_TRY_CHECK;

     CIAO::Server_init (orb.in ());

     if (parse_args (argc, argv) != 0)
        return -1;

      // Get reference to Root POA.
      CORBA::Object_var object =
        orb->resolve_initial_references ("RootPOA"
                                         ACE_ENV_ARG_PARAMETER);
     ACE_TRY_CHECK;
     PortableServer::POA_var root_poa =
     PortableServer::POA::_narrow (object.in ()
                      ACE_ENV_ARG_PARAMETER);
     // Get reference to RTORB.
      object =
        orb->resolve_initial_references ("RTORB"
                                         ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      RTCORBA::RTORB_var rt_orb =
        RTCORBA::RTORB::_narrow (object.in ()
                                 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // Activate POA manager
      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;(Highlighted files are manually added to the generated mpc file)

      poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      CIAO::RTServer::RTComponentServer_Impl *comserv_servant;
      CIAO::Static_Configurator configurator;

      int containers_table_size =
        sizeof (containers_table_)/sizeof(CIAO::Static_Config::ContainerAttributes);
      int homes_table_size =
        sizeof (homes_table_)/sizeof(CIAO::Static_Config::HomeAttributes);
      int components_table_size =
        sizeof (components_table_)/sizeof(CIAO::Static_Config::ComponentAttributes);
      int component_registrations_table_size =
        sizeof (component_registrations_table_)/sizeof(CIAO::Assembly_Placement::componentinstantiation::Register_Info);
      int connections_table_size =
        sizeof (connections_table_)/sizeof(CIAO::Static_Config::ConnectionAttributes);
      int resolvers_table_size =
        sizeof (resolvers_table_)/sizeof(CIAO::Static_Config::ResolveInfoAttributes);
      int thread_pool_table_size=
        sizeof(thread_pool_table_)/sizeof(CIAO::Static_Config::ThreadPoolAttributes);
      int thread_pool_lanes_table_size=
        sizeof(thread_pool_lanes_table_)/sizeof(CIAO::Static_Config::ThreadPoolLanesAttributes);
      int priority_band_table_size=
        sizeof(priority_band_table_)/sizeof(CIAO::Static_Config::PriorityBandsAttributes);
      int policy_set_table_size=
        sizeof(policy_set_table_)/sizeof(CIAO::Static_Config::PolicySetAttributes);

      CIAO::HOMECREATOR_FUNCPTR_MAP home_creator_fptr_map;
      CIAO::HOMESERVANTCREATOR_FUNCPTR_MAP homesvnt_creator_fptr_map;
      CIAO::Static_Config_EntryPoints_Maps maps;
      maps.home_creator_funcptr_map_ = &home_creator_fptr_map;
      maps.home_servant_creator_funcptr_map_ = &homesvnt_creator_fptr_map;

      int i=0;
      for (i=0; i<homes_table_size; ++i)
        {
          home_creator_fptr_map.bind (homes_table_[i].executor_entrypt_,
                                      homes_table_[i].executor_fptr_);

          homesvnt_creator_fptr_map.bind (homes_table_[i].servant_entrypt_,
                                          homes_table_[i].servant_fptr_);
        }

      ACE_NEW_RETURN (comserv_servant,
                      CIAO::RTServer::RTComponentServer_Impl (orb.in (),
                                                              rt_orb.in (),
                                                              root_poa.in (),
                                                              1,
                                                              &maps),
                      -1);

      PortableServer::ServantBase_var safe_servant (comserv_servant);  

      Components::ConfigValues configs;

      configurator.config_rt_info(configs,
                                  thread_pool_table_,
                                  thread_pool_table_size,
                                  lane_table_,
                                  thread_pool_lanes_table_,
                                  thread_pool_lanes_table_size,
                                  band_table_,
                                  priority_band_table_,
                                  priority_band_table_size,
                                  policy_config_table_,
                                  policy_set_table_,
                                  policy_set_table_size);

     comserv_servant->init (configs
                            ACE_ENV_ARG_PARAMETER);
     ACE_TRY_CHECK;
     // Configuring ComponentServer.
     PortableServer::ObjectId_var cs_oid
        = root_poa->activate_object (comserv_servant
                                     ACE_ENV_ARG_PARAMETER);
     ACE_TRY_CHECK;

     object = root_poa->id_to_reference (cs_oid.in ()
                                          ACE_ENV_ARG_PARAMETER);
     ACE_TRY_CHECK;

     Components::Deployment::ComponentServer_var comserv_obj =
        Components::Deployment::ComponentServer::_narrow (object.in ()
                                                          ACE_ENV_ARG_PARAMETER);
     ACE_TRY_CHECK;

     if (CORBA::is_nil (comserv_obj.in ()))
         ACE_ERROR_RETURN ((LM_ERROR,
                          "Unable to activate RTComponentServer object\n"),
                         -1);

      Components::Deployment::ServerActivator_var activator;

      // We are just storing the original configuration here.
      // Currently, we don't really use this ConfigValues direclty.
      Components::ConfigValues_var more_config = new Components::ConfigValues;

      comserv_servant->set_objref (activator.in (),
                                   more_config.in (),
                                   comserv_obj.in ()
                                   ACE_ENV_ARG_PARAMETER);

      ACE_TRY_CHECK;

      configurator.configure (orb.in (),
                              comserv_obj.in (),
                              containers_table_,
                              containers_table_size,
                              homes_table_,
                              homes_table_size,
                              components_table_,
                              components_table_size,
                              component_registrations_table_,
                              component_registrations_table_size,
                              connections_table_,
                              connections_table_size,
                              resolvers_table_,
                              resolvers_table_size);

      CORBA::String_var str = orb->object_to_string (comserv_obj.in ()
                                                     ACE_ENV_ARG_PARAMETER);

      CIAO::Utility::write_IOR (ior_file_name_, str.in ());
      ACE_DEBUG ((LM_INFO, "RTComponentServer IOR: %s\n", str.in ()));

      ACE_DEBUG ((LM_DEBUG,
                  "Running RTComponentServer...\n"));

      CORBA::Object_var pulser_obj
        = orb->string_to_object ("file://ec.ior"
                                 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      BasicSP::EC_var pulser
        = BasicSP::EC::_narrow (pulser_obj.in ()
                                ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CORBA::is_nil (pulser.in ()))
        ACE_ERROR_RETURN ((LM_ERROR, "Unable to acquire 'EC' objref\n"), -1);

      pulser->hertz (rate
                     ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      ACE_DEBUG ((LM_DEBUG, "Start up the Event services\n"));

      pulser->start (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;


      // Run the main event loop for the ORB.
      orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK
    }
   ACE_CATCHANY
   {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "server::main    \n");
      return 1;
   }
  ACE_ENDTRY;

  return 0;
}

Modified Static_CCM_App.mpc

(Highlighted files are manually added to the generated mpc file)


project(Static_CCM_App) :  ciao_server, ciao_client, rtcorba, rtportableserver, iortable, acexml{

includes += $(ACE_ROOT)/TAO/CIAO/tools/Assembly_Deployer
includes += $(ACE_ROOT)/TAO/CIAO/tools/static_configurator
includes += $(ACE_ROOT)/TAO/CIAO/tools/RTComponentServer
libs += RTComponent_Server CIAO_XML_Helpers  Static_Configurator
after += RTComponent_Server CIAO_XML_Helpers  Static_Configurator
 
libs += BasicSP_stub  BasicSP_svnt
after += BasicSP_stub  BasicSP_svnt
libs += EC_exec
after += EC_exec
libs += EC_svnt EC_stub
after += EC_svnt EC_stub
libs += BMDevice_exec
after += BMDevice_exec
libs += BMDevice_svnt BMDevice_stub
after += BMDevice_svnt  BMDevice_stub
libs += BMClosedED_exec
after += BMClosedED_exec
libs += BMClosedED_svnt BMClosedED_stub
after += BMClosedED_svnt BMClosedED_stub
libs += BMDisplay_exec
after += BMDisplay_exec
libs += BMDisplay_svnt BMDisplay_stub
after += BMDisplay_svnt BMDisplay_stub
 
   Source_Files {
       Static_CCM_App.cpp
    }
 
    IDL_Files {
    }
}