Skip to content

Developer's guide

nsoblath edited this page Oct 15, 2012 · 9 revisions

Concepts

Events

Data

Processors

Configuring a KTConfigurable

All classes that are able to be configured via the configuration system should inherit from KTConfigurable. KTConfigurables have a member function Configure(const KTPStoreNode*) that is used to perform the configuration of the KTConfigurable instance. The KTPStoreNode pointer that is passed to the instance should be the branch of the configuration tree that is relevant to that instance. It can then process that branch in any way it sees fit.

Patterns for configuring a KTConfigurable

Here are some examples of code that has been used to configure different KTConfigurable classes in Katydid. This is an incomplete list, and if new ways are developed, they should be added here.

  • Basic method for getting information from the tree, for the available data types (an exception is thrown if the data cannot be cast to the requested type, or if the data doesn't exist):
    std::string stringData = node->GetData< std::string >("string-data")
    Int_t intData = node->GetData< Int_t >("int-data")
    Double_t floatData = node->GetData< Double_t >("float-data")
    Bool_t boolData = node->GetData< Bool_t >("bool-data")

  • Data can be accessed with a default in case the data doesn't exist in the branch:
    std::string stringData = node->GetData< std::string >("string-data", "some default text")

Clone this wiki locally