Parameter Structure Arrays

Parameter Structure Arrays

These parameter are to fill the gap between Simple Parameter Arrays (SPAs) and Extended Parameter Arrays (EPAs): SPAs are rezisable by configuration (files) but members are of a fixed types, EPAs can be only set (but not resized) by configuration (files) and can contain members of any type.

Parameter Structure Arrays are structs with fixed member types gs_params. They can be hold within a SPA and accordingly can be created by rezising the SPA via configuration.

Approach A

still to come...

Approach B

This approach does not introduce any changes to any API. It just allows for simplified definitions of complex groups of gs_params.

  1. namespace gs{
  2. namespace cnf{
  3.   //define a parameter group
  4.   DECLARE_PARAM_GROUP(my_param_group){
  5.     my_param_group()
  6.       : foo("FOO", 1)
  7.       , bar("BAR", 2)
  8.     {
  9.     }
  10.  
  11.     gs_param<int> foo;
  12.     gs_param<int> bar;
  13.   };
  14.  
  15.   //define a parameter group that contains
  16.   //another parameter group
  17.   DECLARE_PARAM_GROUP(my_complex_group){
  18.     my_complex_group()
  19.       : sub_group("test")
  20.       , baz("BAZ",4)
  21.       , woo("WOO",6)
  22.     {
  23.     }
  24.    
  25.     gs_param<group::my_param_group> sub_group;
  26.     gs_param<int> baz;
  27.     gs_param<int> woo;
  28.   };
  29. }
  30. }
  31.  
  32. int sc_main(int argc, char **argv)
  33. {
  34.   // GreenControl Core instance
  35.   gs::ctr::GC_Core       core("ControlCore");
  36.  
  37.   // GreenConfig Plugin
  38.   gs::cnf::ConfigDatabase* cnfdatabase = new gs::cnf::ConfigDatabase("ConfigDatabase");
  39.   gs::cnf::ConfigPlugin configPlugin("ConfigPlugin", cnfdatabase);
  40.  
  41.   //this will just add FOO and BAR into the system
  42.   // because the parameter groups are transparent as long
  43.   //  as they are not defined as gs_params (see below)
  44.   gs::cnf::group::my_param_group my_group;
  45.  
  46.   //this will add test.FOO and test.BAR into the system
  47.   gs::cnf::gs_param<gs::cnf::group::my_param_group> test("test");
  48.  
  49.   //this will add test2.test.FOO, test2.test.BAR, test2.BAZ, test2.WOO into the system
  50.   gs::cnf::gs_param<gs::cnf::group::my_complex_group> test2("test2");
  51.  
  52.   //this will add test_array.X.FOO and test_array.X.BAR into the system
  53.   // with X ranging from zero to the desired array size
  54.   gs::cnf::gs_param<gs::cnf::group::my_param_group*> test_array("test_array");
  55.  
  56.   //this will add test_array2.X.test.FOO and test_array2.X.test.BAR
  57.   // and test_array2.X.BAZ and test_array2.X.WOO into the system
  58.   //  with X ranging from zero to the desired array size
  59.   gs::cnf::gs_param<gs::cnf::group::my_complex_group*> test_array2("test_array2");
  60.  
  61.   ...
  62. }