LCG Project | LCG Applications Area | |
$Date: 2004/06/28 17:34:30 $ |
This guide explains how to use the Configuration Service from a component (refer to how to create a component).
The end-user interacts with the ConfigurationService in the C++ code using a PropertyManager to declare its own properties that the ConfigurationService will configure. The end-user needs to either create its own PropertyManager or locate the one from its Context.
Typical method implementation looks like this:
#include "SealKernel/PropertyManager.h" Handle<PropertyManager> propmanager = context()->component<PropertyManager>(); if (!propmanager ){ /* Error */ }
The end-user may declare properties using the Property class or directly using the variable holding the value (typically a data member). A property is a name-value pair and can be of any type (the boost::any class is used). Additionally, a Property has a textual description, an initial default value and a optional call-back function (the boost::function1 is used) that is called when the value of the Property changes. The two options of declaring Properties are shown in the next code fragment.
// Using a Property instance Property<int> my_int ("MyInt", 99 ,"MyInt property description"); propmanger->declareProperty(my_int); // Using a variable as holder double my_double; propmanager->declareProperty("MyDouble", my_double, 0.99,"MyDouble property description"); // Using a variable and declaring a call-back void callback(const PropertyBase& p) { .... } std::pair<int,double> my_pair; propmanager->declareProperty("MyPair", my_pair, std::make_pair(10,0.10),"Description", callback);
When declaring properties, the PropertyManager tries to locate the ConfigurationService to set the user's property to the value given by the ConfigurationService. If the ConfigurationService is not found in the Context hierarchy no action is done.
The current implementation of the ConfigurationService supports only Gaudi jobOptions as configuration file input format. The general format is <scope>.<name> = <value>; ,w here value can be a list of values between braces {} when configuring vector properties. Refer to the Gaudi documentation for more details.
An example of JobOptions file is shown in the following lines. The <scope> name is given by the scope of the PropertyManager ( setScopeName() method ) that is typically set by the Service owning a PropertyManager. The Application sets the top level scope as "Application".
SEAL/Services/MessageService.OutputLevel = 1; Application.InitialComponents = { "SEAL/Example/SimpleFileReporter" }; Application.LogFileName = "sfr.log";
For the time being the ConfigurationService offers two configuration parameters: