Nymph  v1.5.2
Flow-Based Data Processing Framework
KTTestConfigurable.cc
Go to the documentation of this file.
1 /*
2  * KTTestConfigurable.cc
3  *
4  * Created on: Jul 25, 2012
5  * Author: nsoblath
6  */
7 
8 #include "KTLogger.hh"
9 #include "KTTestConfigurable.hh"
10 #include "KTCommandLineOption.hh"
11 
12 #include "param.hh"
13 
14 using std::string;
15 
16 namespace Nymph
17 {
18  static KTCommandLineOption< int > sTestConfigStringCLO("Test Configurable", "Command-line option for testing", "int-data", 'i');
19 
20  KTLOGGER(testparamlog, "KTTestConfigurable");
21 
22  KTTestConfigurable::KTTestConfigurable(const std::string& name) :
23  KTConfigurable(name),
24  fIntData(-9),
25  fDoubleData(-99.),
26  fStringData("not configured")
27  {
28  }
29 
31  {
32  }
33 
34  bool KTTestConfigurable::Configure(const scarab::param_node& node)
35  {
36  // Config-file options
37  // option: check for data before getting it from the node
38  if (node.has("int-data"))
39  {
40  fIntData = node.get_value< int >("int-data", fIntData);
41  KTINFO(testparamlog, "Configured integer (= existing value if not provided): " << fIntData);
42  }
43 
44  // option: don't check for data before getting it from the node; rely on the default if it's not there.
45  fDoubleData = node.get_value< double >("double-data", fDoubleData);
46  KTINFO(testparamlog, "Configured double (= existing value if not provided): " << fDoubleData);
47  fStringData = node.get_value("string-data", fStringData);
48  KTINFO(testparamlog, "Configured string (= existing value if not provided): " << fStringData);
49 
50  // Command-line options
51  fIntData = fCLHandler->GetCommandLineValue< int >("int-data", fIntData);
52  KTINFO(testparamlog, "Configured integer from CL (= existing value if not provided): " << fIntData);
53 
54  return true;
55  }
56 
58  {
59  KTINFO(testparamlog, "Final configuration of KTTestConfigurable:\n" <<
60  "\tInt data: " << fIntData << "\n" <<
61  "\tDouble data: " << fDoubleData << "\n" <<
62  "\tString data: " << fStringData);
63  return;
64  }
65 
66 
67 } /* namespace Nymph */
#define KTINFO(...)
Definition: KTLogger.hh:344
static KTCommandLineOption< int > sTestConfigStringCLO("Test Configurable", "Command-line option for testing", "int-data", 'i')
bool Configure(const scarab::param_node &node)
Should perform parameter store and command-line configurations.
XReturnType GetCommandLineValue(const std::string &aCLOption)
Return the value of a command line option; throws an exception if the value was not set...
KTLOGGER(applog, "KTApplication")
KTTestConfigurable(const std::string &name="test-configurable")
KTCommandLineHandler * fCLHandler
Contains the logger class and macros, based on Kasper&#39;s KLogger class.