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.
- namespace gs{
- namespace cnf{
- //define a parameter group
- DECLARE_PARAM_GROUP(my_param_group){
- my_param_group()
- : foo("FOO", 1)
- , bar("BAR", 2)
- {
- }
- gs_param<int> foo;
- gs_param<int> bar;
- };
- //define a parameter group that contains
- //another parameter group
- DECLARE_PARAM_GROUP(my_complex_group){
- my_complex_group()
- : sub_group("test")
- , baz("BAZ",4)
- , woo("WOO",6)
- {
- }
- gs_param<group::my_param_group> sub_group;
- gs_param<int> baz;
- gs_param<int> woo;
- };
- }
- }
- int sc_main(int argc, char **argv)
- {
- // GreenControl Core instance
- gs::ctr::GC_Core core("ControlCore");
- // GreenConfig Plugin
- gs::cnf::ConfigDatabase* cnfdatabase = new gs::cnf::ConfigDatabase("ConfigDatabase");
- gs::cnf::ConfigPlugin configPlugin("ConfigPlugin", cnfdatabase);
- //this will just add FOO and BAR into the system
- // because the parameter groups are transparent as long
- // as they are not defined as gs_params (see below)
- gs::cnf::group::my_param_group my_group;
- //this will add test.FOO and test.BAR into the system
- gs::cnf::gs_param<gs::cnf::group::my_param_group> test("test");
- //this will add test2.test.FOO, test2.test.BAR, test2.BAZ, test2.WOO into the system
- gs::cnf::gs_param<gs::cnf::group::my_complex_group> test2("test2");
- //this will add test_array.X.FOO and test_array.X.BAR into the system
- // with X ranging from zero to the desired array size
- gs::cnf::gs_param<gs::cnf::group::my_param_group*> test_array("test_array");
- //this will add test_array2.X.test.FOO and test_array2.X.test.BAR
- // and test_array2.X.BAZ and test_array2.X.WOO into the system
- // with X ranging from zero to the desired array size
- gs::cnf::gs_param<gs::cnf::group::my_complex_group*> test_array2("test_array2");
- ...
- }
- Printer-friendly version
- Login or register to post comments
Posted August 27th, 2008 by RobertGuenzel