OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
Base class for maintaining parameters affecting the runtime configuration of OSSIM executables. More...
#include <JsonConfig.h>
Public Member Functions | |
JsonConfig () | |
Default Ctor loads all default .json files in the share/ossim system dir. More... | |
JsonConfig (const ossimFilename &configFile) | |
virtual | ~JsonConfig () |
Destructor. More... | |
bool | open (const ossimFilename &configFile) |
Opens and parses JSON file. The "parameters" keyword is expected in the root node. More... | |
virtual void | loadJSON (const Json::Value ¶ms_json_node) |
Reads the params controlling the process from the JSON node named "parameters". More... | |
virtual void | saveJSON (Json::Value ¶ms_json_node) const |
Reads the params controlling the process from the JSON node named "parameters". More... | |
JsonParam & | getParameter (const char *paramName) |
Returns a parameter (might be a null parameter if paramName not found in the configuration. More... | |
void | setParameter (const JsonParam &p) |
Adds parameter to the configuration. More... | |
bool | diagnosticLevel (unsigned int level) const |
Convenience method returns TRUE if the currently set diagnostic level is <= level. More... | |
bool | paramExists (const char *paramName) const |
![]() | |
JsonInterface () | |
virtual | ~JsonInterface () |
Protected Member Functions | |
JsonConfig (const JsonConfig &) | |
bool | getBoolValue (bool &rtn_val, const std::string &json_value) const |
Protected Attributes | |
std::map< std::string, JsonParam > | m_paramsMap |
Static Protected Attributes | |
static JsonParam | s_nullParam |
Friends | |
std::ostream & | operator<< (std::ostream &out, const JsonConfig &obj) |
Outputs JSON to output stream provided. More... | |
Base class for maintaining parameters affecting the runtime configuration of OSSIM executables.
The state is imported and exported via JSON. There are default configuration files that should be part of the install, that are accessed by this class. Custom settings can also be loaded.
There are two functionally equivalent forms for specifying parameters: long and short. Parameters are initially declared via the long form with descriptions and default values. These values must be supplied in default JSON files as part of the OSSIM install.
Once the parameters are declared via the long form, the short form can be used to supply runtime overrides.
The long form format is
{ "parameters": [ { "name": "<param_name>", "descr": "<param description", "type": "string"|"float"|"uint"|"int"|"bool", "value":
}, ... ] }
The short form is:
{ "parameters": [ "<param_name>":
, ... ] }
The short form parameter is only accepted if it has previously been loaded via the long form so that the data type is known.
Parameters are usually accessed knowing the data type ahead of time. For example, a string parameter is accessed as:
string paramVal = jsonConfig.getParameter("param_name").asSTring();
If the parameter is not found, the special null-parameter is returned from getParameter(), and casting to a tye will return 0, false, or empty string.
Definition at line 64 of file JsonConfig.h.
ossim::JsonConfig::JsonConfig | ( | ) |
Default Ctor loads all default .json files in the share/ossim system dir.
Definition at line 309 of file JsonConfig.cpp.
References ossimDirectory::findAllFilesThatMatch(), ossimPreferences::instance(), ossimFilename::isDir(), m_paramsMap, ossimDirectory::open(), open(), ossimNotify(), ossimNotifyLevel_WARN, and ossimException::what().
ossim::JsonConfig::JsonConfig | ( | const ossimFilename & | configFile | ) |
Definition at line 348 of file JsonConfig.cpp.
References open().
|
virtual |
Destructor.
Definition at line 354 of file JsonConfig.cpp.
References m_paramsMap.
|
inlineprotected |
Definition at line 99 of file JsonConfig.h.
bool ossim::JsonConfig::diagnosticLevel | ( | unsigned int | level | ) | const |
Convenience method returns TRUE if the currently set diagnostic level is <= level.
Definition at line 461 of file JsonConfig.cpp.
References m_paramsMap.
Referenced by ATP::AtpGenerator::constructChain(), ATP::ossimCorrelationSource::correlate(), ATP::AtpTileSource::filterPoints(), ATP::AtpTileSource::filterWithoutParallax(), ATP::AtpTileSource::filterWithParallax(), ATP::AtpGenerator::generateTiePointList(), ATP::ossimCorrelationSource::getTile(), ATP::ossimDescriptorSource::getTile(), ATP::AtpGenerator::initialize(), ATP::AtpGenerator::layoutSearchTileRects(), ATP::ossimAtpTool::loadJSON(), main(), and ATP::ossimCorrelationSource::OpenCVCorrelation().
|
protected |
JsonParam & ossim::JsonConfig::getParameter | ( | const char * | paramName | ) |
Returns a parameter (might be a null parameter if paramName not found in the configuration.
Definition at line 377 of file JsonConfig.cpp.
References m_paramsMap, and s_nullParam.
Referenced by ATP::AtpAnnotatedImage::annotateCorrelations(), ATP::AtpAnnotatedImage::annotateResiduals(), ATP::AtpAnnotatedImage::AtpAnnotatedImage(), ATP::AtpGenerator::constructChain(), ATP::ossimCorrelationSource::correlate(), ATP::ossimAtpTool::doPairwiseMatching(), ATP::AtpTileSource::filterPoints(), ATP::ossimCorrelationSource::findFeatures(), ATP::ossimDescriptorSource::getTile(), ATP::ossimCorrelationSource::getTile(), ATP::ossimCorrelationSource::initialize(), ATP::AtpGenerator::initialize(), ATP::AtpTileSource::initializeStaticMembers(), ATP::AtpGenerator::layoutSearchTileRects(), ATP::ossimAtpTool::loadJSON(), loadJSON(), and ATP::ossimCorrelationSource::OpenCVCorrelation().
|
virtual |
Reads the params controlling the process from the JSON node named "parameters".
Implements ossim::JsonInterface.
Definition at line 403 of file JsonConfig.cpp.
References ossimString::contains(), ossim::JsonParam::descr(), ossimString::empty(), getParameter(), ossim::JsonParam::loadJSON(), ossim::JsonParam::name(), ossimNotify(), ossimNotifyLevel_WARN, ossim::JsonParam::saveJSON(), setParameter(), and ossimString::string().
Referenced by ATP::ossimAtpTool::loadJSON(), main(), and open().
bool ossim::JsonConfig::open | ( | const ossimFilename & | configFile | ) |
Opens and parses JSON file. The "parameters" keyword is expected in the root node.
Definition at line 359 of file JsonConfig.cpp.
References loadJSON(), and ossimString::string().
Referenced by JsonConfig().
bool ossim::JsonConfig::paramExists | ( | const char * | paramName | ) | const |
Definition at line 395 of file JsonConfig.cpp.
References m_paramsMap.
Referenced by ATP::AtpTileSource::filterPoints(), ATP::ossimDescriptorSource::getTile(), ATP::ossimCorrelationSource::getTile(), ATP::AtpTileSource::initializeStaticMembers(), and ATP::ossimCorrelationSource::OpenCVCorrelation().
|
virtual |
Reads the params controlling the process from the JSON node named "parameters".
Implements ossim::JsonInterface.
Definition at line 447 of file JsonConfig.cpp.
References m_paramsMap.
Referenced by ATP::ossimAtpTool::getParameters(), ossimDemTool::getParameters(), and ossim::operator<<().
void ossim::JsonConfig::setParameter | ( | const JsonParam & | p | ) |
Adds parameter to the configuration.
Any previous parameter of the same name is replaced.
Definition at line 385 of file JsonConfig.cpp.
References m_paramsMap, ossim::JsonParam::name(), and ossimString::string().
Referenced by loadJSON().
|
friend |
Outputs JSON to output stream provided.
Definition at line 472 of file JsonConfig.cpp.
|
protected |
Definition at line 103 of file JsonConfig.h.
Referenced by diagnosticLevel(), getParameter(), JsonConfig(), paramExists(), saveJSON(), setParameter(), and ~JsonConfig().
|
staticprotected |
Definition at line 104 of file JsonConfig.h.
Referenced by getParameter().