Fennel: ConfigMap Class Reference (original) (raw)
ConfigMap defines a simple container for configuration parameter/value pairs. More...
#include <[ConfigMap.h](ConfigMap%5F8h-source.html)>
Inheritance diagram for ConfigMap:

| Public Member Functions | |
|---|---|
| ConfigMap () | |
| Creates an empty map. | |
| virtual | ~ConfigMap () |
| Destroys the map. | |
| void | readParams (std::istream ¶mStream) |
| Reads parameter name/value pairs from an input stream, until end-of-stream is encountered. | |
| void | dumpParams (std::ostream &dumpStream) const |
| Dumps all parameter settings to a stream. | |
| void | mergeFrom (const ConfigMap &) |
| Merges in all the parameters from another map. | |
| std::string | getStringParam (std::string paramName, std::string defaultVal="") const |
| Gets the value of a string-typed parameter. | |
| int | getIntParam (std::string paramName, int defaultVal=0) const |
| Gets the value of an integer-typed parameter. | |
| long | getLongParam (std::string paramName, long defaultVal=0) const |
| Gets the value of a long-typed parameter. | |
| bool | getBoolParam (std::string paramName, bool defaultVal=false) const |
| Gets the value of an boolean-typed parameter. | |
| bool | isParamSet (std::string paramName) const |
| Determines whether a parameter has an associated value. | |
| void | setStringParam (std::string paramName, std::string paramVal) |
| Sets an individual parameter value. | |
| void | clear () |
| Clears all parameters. | |
| virtual void | initTraceSource (SharedTraceTarget pTraceTarget, std::string name) |
| For use when initialization has to be deferred until after construction. | |
| void | trace (TraceLevel level, std::string message) const |
| Records a trace message. | |
| bool | isTracing () const |
| **Returns:**true iff tracing is enabled for this source | |
| bool | isTracingLevel (TraceLevel level) const |
| Determines whether a particular level is being traced. | |
| TraceTarget & | getTraceTarget () const |
| **Returns:**the TraceTarget for this source | |
| SharedTraceTarget | getSharedTraceTarget () const |
| **Returns:**the SharedTraceTarget for this source | |
| std::string | getTraceSourceName () const |
| Gets the name of this source. | |
| void | setTraceSourceName (std::string const &n) |
| Sets the name of this source. | |
| TraceLevel | getMinimumTraceLevel () const |
| void | disableTracing () |
| Private Types | |
| typedef std::map< std::string, std::string > | StringMap |
| typedef StringMap::iterator | StringMapIter |
| typedef StringMap::const_iterator | StringMapConstIter |
| Private Attributes | |
| StringMap | paramVals |
Detailed Description
ConfigMap defines a simple container for configuration parameter/value pairs.
Definition at line 37 of file ConfigMap.h.
Member Typedef Documentation
Constructor & Destructor Documentation
| ConfigMap::ConfigMap | ( | | ) | [explicit] | | -------------------- | - | | - | ------------ |
| ConfigMap::~ConfigMap | ( | | ) | [virtual] | | ---------------------- | - | | - | ----------- |
Member Function Documentation
| void ConfigMap::readParams | ( | std::istream & | paramStream | ) |
|---|
Reads parameter name/value pairs from an input stream, until end-of-stream is encountered.
Each pair should be on a line by itself, with whitespace between the name and value.
Parameters:
| paramStream | the stream from which to read parameters |
|---|
Definition at line 40 of file ConfigMap.cpp.
References TraceSource::name, and paramVals.
Referenced by TestBase::readParams().
00041 { 00042 for (;;) { 00043 std::string name,value; 00044 paramStream >> name; 00045 if (name == "") { 00046 break; 00047 } 00048 paramStream >> value; 00049 paramVals[name] = value; 00050 } 00051 }
| void ConfigMap::dumpParams | ( | std::ostream & | dumpStream | ) | const |
|---|
Dumps all parameter settings to a stream.
Parameters:
Definition at line 53 of file ConfigMap.cpp.
References paramVals.
Referenced by TestBase::readParams().
00054 { 00055 for (StringMapConstIter pPair = paramVals.begin(); 00056 pPair != paramVals.end(); ++pPair) 00057 { 00058 dumpStream << pPair->first; 00059 dumpStream << " "; 00060 dumpStream << pPair->second; 00061 dumpStream << std::endl; 00062 } 00063 }
| void ConfigMap::mergeFrom | ( | const ConfigMap & | | ) | | ------------------------- | - | ---------------------------------------- | | - |
| std::string ConfigMap::getStringParam | ( | std::string | paramName, |
|---|---|---|---|
| std::string | defaultVal = "" | ||
| ) | const |
Gets the value of a string-typed parameter.
Parameters:
| paramName | name of the parameter |
|---|---|
| defaultVal | the default value to return if the parameter is not set |
Returns:
the parameter value
Definition at line 76 of file ConfigMap.cpp.
References paramVals, and TRACE_CONFIG.
Referenced by CacheTestBase::CacheTestBase(), TestOptionsTest::extra(), Database::init(), JniUtilParams::readConfig(), DeviceAccessSchedulerParams::readConfig(), TestOptionsTest::test1(), TestOptionsTest::test2(), TestBase::TestBase(), SegStreamTest::testRead(), and SegStreamTest::testWrite().
00079 { 00080 StringMapConstIter pPair = paramVals.find(paramName); 00081 if (pPair == paramVals.end()) { 00082 FENNEL_TRACE( 00083 TRACE_CONFIG, 00084 "parameter " << paramName 00085 << " using default value of '" 00086 << defaultVal << "'"); 00087 return defaultVal; 00088 } else { 00089 FENNEL_TRACE( 00090 TRACE_CONFIG, 00091 "parameter " << paramName 00092 << " using specified value of '" 00093 << pPair->second << "'"); 00094 return pPair->second; 00095 } 00096 }
| int ConfigMap::getIntParam | ( | std::string | paramName, |
|---|---|---|---|
| int | defaultVal = 0 | ||
| ) | const |
Gets the value of an integer-typed parameter.
Parameters:
| paramName | name of the parameter |
|---|---|
| defaultVal | the default value to return if the parameter is not set |
Returns:
the parameter value
Definition at line 98 of file ConfigMap.cpp.
References paramVals, and TRACE_CONFIG.
Referenced by BTreeTxnTest::BTreeTxnTest(), CacheTestBase::CacheTestBase(), TestOptionsTest::extra(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), DeviceAccessSchedulerParams::readConfig(), CacheParams::readConfig(), Database::readDeviceParams(), TestOptionsTest::test1(), TestOptionsTest::test2(), TestBase::TestBase(), BTreeTxnTest::testCheckpoint(), ThreadedTestBase::ThreadedTestBase(), and CmdInterpreter::visit().
00101 { 00102 StringMapConstIter pPair = paramVals.find(paramName); 00103 if (pPair == paramVals.end()) { 00104 FENNEL_TRACE( 00105 TRACE_CONFIG, 00106 "parameter " << paramName 00107 << " using default value of '" 00108 << defaultVal << "'"); 00109 return defaultVal; 00110 } else { 00111 FENNEL_TRACE( 00112 TRACE_CONFIG, 00113 "parameter " << paramName 00114 << " using specified value of '" 00115 << pPair->second << "'"); 00116 return boost::lexical_cast(pPair->second); 00117 } 00118 }
| long ConfigMap::getLongParam | ( | std::string | paramName, |
|---|---|---|---|
| long | defaultVal = 0 | ||
| ) | const |
Gets the value of a long-typed parameter.
Parameters:
| paramName | name of the parameter |
|---|---|
| defaultVal | the default value to return if the parameter is not set |
Returns:
the parameter value
Definition at line 149 of file ConfigMap.cpp.
References paramVals, and TRACE_CONFIG.
00152 {
00153 StringMapConstIter pPair = paramVals.find(paramName);
00154 if (pPair == paramVals.end()) {
00155 FENNEL_TRACE(
00156 TRACE_CONFIG,
00157 "parameter " << paramName
00158 << " using default value of '"
00159 << defaultVal << "'");
00160 return defaultVal;
00161 } else {
00162 FENNEL_TRACE(
00163 TRACE_CONFIG,
00164 "parameter " << paramName
00165 << " using specified value of '"
00166 << pPair->second << "'");
00167
00168
00169
00170 return atol(pPair->second.c_str());
00171 }
00172 }
| bool ConfigMap::getBoolParam | ( | std::string | paramName, |
|---|---|---|---|
| bool | defaultVal = false | ||
| ) | const |
Gets the value of an boolean-typed parameter.
Parameters:
| paramName | name of the parameter |
|---|---|
| defaultVal | the default value to return if the parameter is not set |
Returns:
the parameter value
Definition at line 120 of file ConfigMap.cpp.
References paramVals, and TRACE_CONFIG.
Referenced by Database::init().
00123 {
00124 StringMapConstIter pPair = paramVals.find(paramName);
00125 if (pPair == paramVals.end()) {
00126 FENNEL_TRACE(
00127 TRACE_CONFIG,
00128 "parameter " << paramName
00129 << " using default value of '"
00130 << defaultVal << "'");
00131 return defaultVal;
00132 } else {
00133 FENNEL_TRACE(
00134 TRACE_CONFIG,
00135 "parameter " << paramName
00136 << " using specified value of '"
00137 << pPair->second << "'");
00138
00139 if (strcasecmp(pPair->second.c_str(), "true") == 0) {
00140 return true;
00141 } else if (strcasecmp(pPair->second.c_str(), "false") == 0) {
00142 return false;
00143 } else {
00144 return boost::lexical_cast(pPair->second);
00145 }
00146 }
00147 }
| bool ConfigMap::isParamSet | ( | std::string | paramName | ) | const |
|---|
| void ConfigMap::setStringParam | ( | std::string | paramName, |
|---|---|---|---|
| std::string | paramVal | ||
| ) |
| void ConfigMap::clear | ( | | ) | | --------------------- | - | | - |
| void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, |
|---|---|---|---|
| std::string | name | ||
| ) | [virtual, inherited] |
| void TraceSource::trace | ( | TraceLevel | level, |
|---|---|---|---|
| std::string | message | ||
| ) | const [inherited] |
| bool TraceSource::isTracing | ( | | ) | const [inline, inherited] | | --------------------------- | - | | - | --------------------------- |
| bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
|---|
| TraceTarget& TraceSource::getTraceTarget | ( | | ) | const [inline, inherited] | | ----------------------------------------------------------------- | - | | - | --------------------------- |
| std::string TraceSource::getTraceSourceName | ( | | ) | const [inline, inherited] | | ------------------------------------------- | - | | - | --------------------------- |
| void TraceSource::setTraceSourceName | ( | std::string const & | n | ) | [inline, inherited] |
|---|
Sets the name of this source.
Useful to construct dynamic names for fine-grained filtering.
Definition at line 136 of file TraceSource.h.
00137 { 00138 name = n; 00139 }
| TraceLevel TraceSource::getMinimumTraceLevel | ( | | ) | const [inline, inherited] | | ------------------------------------------------------------------------------------------------------ | - | | - | --------------------------- |
| void TraceSource::disableTracing | ( | | ) | [inherited] | | -------------------------------- | - | | - | ------------- |
Member Data Documentation
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/common/ConfigMap.h
- /home/pub/open/dev/fennel/common/ConfigMap.cpp
