OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
ossimDemToolConfig Class Reference

Singleton class maintaining parameters affecting the automatic tie point generation. More...

#include <ossimDemToolConfig.h>

Inheritance diagram for ossimDemToolConfig:
ossim::JsonConfig ossim::JsonInterface

Public Member Functions

virtual ~ossimDemToolConfig ()
 Destructor. More...
 
bool readConfig (const std::string &configName="")
 
bool diagnosticLevel (unsigned int level) const
 Convenience method returns TRUE if the currently set diagnostic level is <= level. More...
 
- Public Member Functions inherited from ossim::JsonConfig
 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 &params_json_node)
 Reads the params controlling the process from the JSON node named "parameters". More...
 
virtual void saveJSON (Json::Value &params_json_node) const
 Reads the params controlling the process from the JSON node named "parameters". More...
 
JsonParamgetParameter (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
 
- Public Member Functions inherited from ossim::JsonInterface
 JsonInterface ()
 
virtual ~JsonInterface ()
 

Static Public Member Functions

static ossimDemToolConfiginstance ()
 Singleton implementation. More...
 

Private Member Functions

 ossimDemToolConfig ()
 
 ossimDemToolConfig (const ossimDemToolConfig &)
 

Additional Inherited Members

- Protected Member Functions inherited from ossim::JsonConfig
 JsonConfig (const JsonConfig &)
 
bool getBoolValue (bool &rtn_val, const std::string &json_value) const
 
- Protected Attributes inherited from ossim::JsonConfig
std::map< std::string, JsonParamm_paramsMap
 
- Static Protected Attributes inherited from ossim::JsonConfig
static JsonParam s_nullParam
 

Detailed Description

Singleton class maintaining parameters affecting the automatic tie point generation.

The state is imported and exported via JSON. There are default configuration files that must be part of the install, that are accessed by this class. Custom settings can also be st

Definition at line 22 of file ossimDemToolConfig.h.

Constructor & Destructor Documentation

◆ ~ossimDemToolConfig()

ossimDemToolConfig::~ossimDemToolConfig ( )
virtual

Destructor.

Definition at line 33 of file ossimDemToolConfig.cpp.

34 {
35  m_paramsMap.clear();
36 }
std::map< std::string, JsonParam > m_paramsMap
Definition: JsonConfig.h:103

◆ ossimDemToolConfig() [1/2]

ossimDemToolConfig::ossimDemToolConfig ( )
private

Definition at line 25 of file ossimDemToolConfig.cpp.

26 {
27 
28  // Register the ISA-common parameters in the params map:
29  //TODO:
30  // readConfig();
31 }

◆ ossimDemToolConfig() [2/2]

ossimDemToolConfig::ossimDemToolConfig ( const ossimDemToolConfig )
inlineprivate

Definition at line 38 of file ossimDemToolConfig.h.

38 {}

Member Function Documentation

◆ diagnosticLevel()

bool ossimDemToolConfig::diagnosticLevel ( unsigned int  level) const

Convenience method returns TRUE if the currently set diagnostic level is <= level.

◆ instance()

ossimDemToolConfig & ossimDemToolConfig::instance ( )
static

Singleton implementation.

Definition at line 19 of file ossimDemToolConfig.cpp.

Referenced by ossimDemTool::getParameters(), and ossimDemTool::loadJSON().

20 {
21  static ossimDemToolConfig singleton;
22  return singleton;
23 }
Singleton class maintaining parameters affecting the automatic tie point generation.

◆ readConfig()

bool ossimDemToolConfig::readConfig ( const std::string &  configName = "")

Definition at line 38 of file ossimDemToolConfig.cpp.

References ossimPreferences::instance(), ossimFilename::isDir(), ossimNotify(), ossimNotifyLevel_WARN, ossimFilename::setPath(), and ossimException::what().

39 {
40  // This method could eventually curl a spring config server for the param JSON. For now it
41  // is reading the installed share/ossim-isa system directory for config JSON files.
42 
43  // The previous parameters list is cleared first for a fresh start:
44  m_paramsMap.clear();
45 
46  ossimFilename configFilename;
47  Json::Value jsonRoot;
48  try
49  {
50  // First establish the directory location of the default config files:
52  preferencesKWL().findKey( std::string( "ossim_share_directory" ) );
53  shareDir += "/dem";
54  if (!shareDir.isDir())
55  throw ossimException("Nonexistent share drive provided for config files.");
56 
57  // Read the default common parameters first:
58  configFilename = "demToolConfig.json";
59  configFilename.setPath(shareDir);
60  if (!open(configFilename))
61  throw ossimException("Bad file open or parse.");
62 
63  // Read the algorithm-specific default parameters if generic algo name specified as config:
64 // ossimString configName (cn);
65 // configFilename.clear();
66 // if (configName == "crosscorr")
67 // configFilename = "crossCorrConfig.json";
68 // else if (configName == "descriptor")
69 // configFilename = "descriptorConfig.json";
70 // else if (configName == "nasa")
71 // configFilename = "nasaConfig.json";
72 // else if (!configName.empty())
73 // {
74 // // Custom configuration. TODO: the path here is still the install's share directory.
75 // // Eventually want to provide a database access to the config JSON.
76 // configFilename = configName + ".json";
77 // }
78 
79  // Load the specified configuration. This will override the common defaults:
80 // if (!configFilename.empty())
81 // {
82 // configFilename.setPath(shareDir);
83 // if (!open(configFilename))
84 // throw ossimException("Bad file open or parse.");
85 // }
86  }
87  catch (ossimException& e)
88  {
89  ossimNotify(ossimNotifyLevel_WARN)<<"ossimDemToolConfig::readConfig(): Could not open/parse "
90  "config file at <"<< configFilename << ">. Error: "<<e.what()<<endl;
91  return false;
92  }
93  return true;
94 }
ossimFilename & setPath(const ossimString &p)
bool isDir() const
std::map< std::string, JsonParam > m_paramsMap
Definition: JsonConfig.h:103
virtual const char * what() const
Returns the error message.
bool open(const ossimFilename &configFile)
Opens and parses JSON file. The "parameters" keyword is expected in the root node.
Definition: JsonConfig.cpp:359
static ossimPreferences * instance()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

The documentation for this class was generated from the following files: