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
ATP::AtpConfig Class Reference

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

#include <AtpConfig.h>

Inheritance diagram for ATP::AtpConfig:
ossim::JsonConfig ossim::JsonInterface

Public Member Functions

virtual ~AtpConfig ()
 Destructor. More...
 
bool readConfig (const std::string &configName="")
 
- 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 AtpConfiginstance ()
 Singleton implementation. More...
 

Private Member Functions

 AtpConfig ()
 
 AtpConfig (const AtpConfig &)
 

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 24 of file AtpConfig.h.

Constructor & Destructor Documentation

◆ ~AtpConfig()

ATP::AtpConfig::~AtpConfig ( )
virtual

Destructor.

Definition at line 33 of file AtpConfig.cpp.

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

◆ AtpConfig() [1/2]

ATP::AtpConfig::AtpConfig ( )
private

Definition at line 26 of file AtpConfig.cpp.

27 {
28 
29  // Register the ISA-common parameters in the params map:
30  readConfig();
31 }
bool readConfig(const std::string &configName="")
Definition: AtpConfig.cpp:38

◆ AtpConfig() [2/2]

ATP::AtpConfig::AtpConfig ( const AtpConfig )
inlineprivate

Definition at line 37 of file AtpConfig.h.

37 {}

Member Function Documentation

◆ instance()

AtpConfig & ATP::AtpConfig::instance ( )
static

◆ readConfig()

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

Definition at line 38 of file AtpConfig.cpp.

References ossimString::clear(), CWARN, ossimString::empty(), ossimPreferences::instance(), ossimFilename::isDir(), ossimFilename::setPath(), and ossimException::what().

Referenced by ATP::ossimAtpTool::loadJSON(), and main().

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 += "/atp";
54  if (!shareDir.isDir())
55  throw ossimException("Nonexistent share drive provided for config files.");
56 
57  // Read the default common parameters first:
58  configFilename = "atpConfig.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  CWARN<<"AtpConfig::readConfig(): Could not open/parse "
90  "config file at <"<< configFilename << ">. Error: "<<e.what()<<endl;
91  return false;
92  }
93  return true;
94 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
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()
bool empty() const
Definition: ossimString.h:411
#define CWARN

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