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

#include <ossimPreferences.h>

Public Member Functions

 ~ossimPreferences ()
 
bool loadPreferences ()
 
bool loadPreferences (const ossimFilename &pathname)
 
bool savePreferences () const
 
bool savePreferences (const ossimFilename &pathname)
 
const char * findPreference (const char *key) const
 
void addPreference (const char *key, const char *value)
 
const ossimKeywordlistpreferencesKWL () const
 
ossimKeywordlistpreferencesKWL ()
 
void addPreferences (const ossimKeywordlist &kwl, const char *prefix=0, bool stripPrefix=true)
 
ossimFilename getPreferencesFilename () const
 

Static Public Member Functions

static ossimPreferencesinstance ()
 

Protected Member Functions

 ossimPreferences ()
 
 ossimPreferences (const ossimPreferences &)
 
void operator= (const ossimPreferences &) const
 

Protected Attributes

ossimKeywordlist theKWL
 
ossimFilename thePrefFilename
 
bool theInstanceIsModified
 

Static Protected Attributes

static ossimPreferencestheInstance = NULL
 

Detailed Description


CLASS: ossimPreferences

Definition at line 28 of file ossimPreferences.h.

Constructor & Destructor Documentation

◆ ~ossimPreferences()

ossimPreferences::~ossimPreferences ( )

Definition at line 45 of file ossimPreferences.cpp.

References theInstance.

46 {
47  theInstance = NULL;
48 }
static ossimPreferences * theInstance

◆ ossimPreferences() [1/2]

ossimPreferences::ossimPreferences ( )
protected

Override the compiler default constructors:

If is found in the preferences file, expand it in place.

Definition at line 35 of file ossimPreferences.cpp.

References loadPreferences(), ossimKeywordlist::setExpandEnvVarsFlag(), and theKWL.

Referenced by instance().

36 {
43 }
ossimKeywordlist theKWL
void setExpandEnvVarsFlag(bool flag)

◆ ossimPreferences() [2/2]

ossimPreferences::ossimPreferences ( const ossimPreferences )
inlineprotected

Definition at line 100 of file ossimPreferences.h.

100 {}

Member Function Documentation

◆ addPreference()

void ossimPreferences::addPreference ( const char *  key,
const char *  value 
)

METHOD: addPreference() Inserts keyword/value pair into the in-memory preferences KWL. It does save to disk. App must do a savePreferences() for changes to be saved.

Definition at line 247 of file ossimPreferences.cpp.

References ossimKeywordlist::add(), theInstanceIsModified, and theKWL.

248 {
249  theKWL.add(key, value, true);
250  theInstanceIsModified = true;
251 }
ossimKeywordlist theKWL
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)

◆ addPreferences()

void ossimPreferences::addPreferences ( const ossimKeywordlist kwl,
const char *  prefix = 0,
bool  stripPrefix = true 
)

Definition at line 253 of file ossimPreferences.cpp.

References ossimKeywordlist::add(), theInstanceIsModified, and theKWL.

Referenced by ossimIgen::initializeAttributes().

256 {
257  theKWL.add(kwl, prefix, stripPrefix);
258  theInstanceIsModified = true;
259 }
ossimKeywordlist theKWL
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)

◆ findPreference()

const char* ossimPreferences::findPreference ( const char *  key) const
inline

◆ getPreferencesFilename()

ossimFilename ossimPreferences::getPreferencesFilename ( ) const
Returns
The preference filename.

Definition at line 261 of file ossimPreferences.cpp.

References thePrefFilename.

Referenced by ossimInfo::printConfiguration().

262 {
263  return thePrefFilename;
264 }
ossimFilename thePrefFilename

◆ instance()

ossimPreferences * ossimPreferences::instance ( )
static

METHOD: instance() The static singleton instance of this object is accessed via this method:


METHOD: ossimPreferences::instance()

This is the method by which run-time objects access this singleton instance

Simply return the instance if already created:

Create the static instance of this class:

Definition at line 56 of file ossimPreferences.cpp.

References ossimPreferences(), and theInstance.

Referenced by ossim::computeLevels(), ossimplugins::ossimGeometricSarSensorModel::createReplacementOCG(), ossim::defaultTileSize(), ossimGdalOgrVectorAnnotation::getDefaults(), ossimGdalTileSource::getDefaults(), ossimTool::getKwlTemplate(), ossim::getNumberOfThreads(), ossim::AwsStreamFactory::initClient(), ossimEpsgProjectionDatabase::initialize(), ossimIgen::initializeAttributes(), ossimNitfWriterBase::initializeDefaultsFromConfigFile(), ossimInit::initializePlugins(), ossimOverviewBuilderBase::initializePreferenceSettings(), ossimImageHandlerRegistry::initializeStateCache(), ossimAppTileCache::instance(), ossim::JsonConfig::JsonConfig(), ossimWktProjectionFactory::loadRecords(), ossimDtedElevationDatabase::loadState(), ossimDemTool::ossimDemTool(), ossimFilterResampler::ossimFilterResampler(), ossimH5Options::ossimH5Options(), ossimOrthoIgen::ossimOrthoIgen(), ossimStdOutProgress::ossimStdOutProgress(), ossimNitfFileHeaderV2_1::parseStream(), ossimNitfXmlDataContentDes::print(), ossimNitfDesInformation::print(), ossimInfo::printConfiguration(), ossimDemToolConfig::readConfig(), ATP::AtpConfig::readConfig(), ossim::S3StreamBuffer::S3StreamBuffer(), and ossimImageChainMtAdaptor::setNumberOfThreads().

57 {
61  if (theInstance)
62  return theInstance;
63 
68 
69  return theInstance;
70 }
static ossimPreferences * theInstance

◆ loadPreferences() [1/2]

bool ossimPreferences::loadPreferences ( )

METHOD: loadPreferences() These methods clear the current preferences and load either the default preferences file or the specified file. Returns TRUE if loaded properly:


METHOD: loadPreferences()

Loads the preferences file specified in the runtime environment.

Fetch preferences file name from environment:

Load the preferences file into the static keywordlist object:

Check for error opening KWL:

Definition at line 78 of file ossimPreferences.cpp.

Referenced by ossimPreferences().

79 {
80  static const char MODULE[] = "ossimPreferences::loadPreferences()";
81  if (traceExec())
82  {
84  << "DEBUG: " << MODULE << " entering...\n";
85  }
86 
87  bool parsed_ok = false;
88 
92  char* pref_filename = getenv(PREF_FILE_ENV_VAR_NAME);
93 
94  //std::cout << "ossimPreferences::loadPreferences() ======== " << ossimString(pref_filename) << "\n";
95  if (pref_filename)
96  {
100  thePrefFilename = pref_filename;
101  parsed_ok = theKWL.addFile(pref_filename);
102 
106  if (!parsed_ok)
107  {
108  if(traceDebug())
109  {
111  << "WARNING: " << MODULE
112  << ", an error was encountered loading the prefererences "
113  << "file at \"" << thePrefFilename << "\" as specified by the "
114  << "environment variable \"" << PREF_FILE_ENV_VAR_NAME << "\"."
115  << "Preferences were not loaded.\n";
116 
117  }
118  }
119  }
120  if (traceExec())
121  {
123  << "DEBUG: " << MODULE << "returning...\n";
124  }
125  return parsed_ok;
126 }
bool addFile(const char *file)
ossimKeywordlist theKWL
ossimFilename thePrefFilename
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ loadPreferences() [2/2]

bool ossimPreferences::loadPreferences ( const ossimFilename pathname)

METHOD: loadPreferences(filename)

Loads the preferences file specified in the arg.

First clear the existing KWL:

Load the preferences file into the static keywordlist object:

Check for error opening KWL:

Definition at line 134 of file ossimPreferences.cpp.

135 {
136  static const char MODULE[] = "ossimPreferences::loadPreferences(filename)";
137  if (traceExec())
138  {
140  << "DEBUG: " << MODULE << ", entering...\n";
141  }
142 
143  bool parsed_ok;
144 
148  theKWL.clear();
149  theInstanceIsModified = true;
150 
154  thePrefFilename = pathname;
155  parsed_ok = theKWL.addFile(pathname);
156 
160  if (!parsed_ok)
161  {
163  << "WARNING: " << MODULE
164  << ", an error was encountered loading the prefererences "
165  << "file at \"" << pathname << "\". Preferences were not "
166  << "loaded.\n";
167  }
168 
169  if (traceExec())
170  {
172  << "DEBUG: " << MODULE<< ", returning...\n";
173  }
174 
175  return parsed_ok;
176 }
bool addFile(const char *file)
ossimKeywordlist theKWL
ossimFilename thePrefFilename
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator=()

void ossimPreferences::operator= ( const ossimPreferences ) const
inlineprotected

Definition at line 102 of file ossimPreferences.h.

102 {}

◆ preferencesKWL() [1/2]

const ossimKeywordlist& ossimPreferences::preferencesKWL ( ) const
inline

METHOD: preferencesKWL() An alternative to utilizing findPreference(), for objects derived from ossimObject, is to access the preferences KWL with this method (typically during construction) and provide it to the object's loadState() method.

Definition at line 77 of file ossimPreferences.h.

Referenced by ossimEpsgProjectionDatabase::initialize(), ossimInit::initializeLogFile(), ossimInit::initializePlugins(), ossimWktProjectionFactory::loadRecords(), ossimDtedElevationDatabase::loadState(), and ossimInfo::printConfiguration().

77 { return theKWL; }
ossimKeywordlist theKWL

◆ preferencesKWL() [2/2]

ossimKeywordlist& ossimPreferences::preferencesKWL ( )
inline

METHOD: preferencesKWL() An alternative to utilizing findPreference(), for objects derived from ossimObject, is to access the preferences KWL with this method (typically during construction) and provide it to the object's loadState() method.

Definition at line 86 of file ossimPreferences.h.

86 { return theKWL; }
ossimKeywordlist theKWL

◆ savePreferences() [1/2]

bool ossimPreferences::savePreferences ( ) const

METHOD: savePrefences() This method permits saving the preferences file to the default location or to a specified location:


METHOD: ossimPreferences::savePreferences()

Saves KWL to the current filename.

Save the file to current preferences filename:

Definition at line 184 of file ossimPreferences.cpp.

185 {
186  static const char MODULE[] = "ossimPreferences::savePreferences()";
187  if (traceExec())
188  {
190  << "DEBUG: " << MODULE << ", entering...\n";
191  }
192 
193  bool success = true;
194 
199  {
201  theInstanceIsModified = false;
202  }
203 
204  if (traceExec())
205  {
207  << "DEBUG:" << MODULE << ", returning...\n";
208  }
209 
210  return success;
211 }
ossimKeywordlist theKWL
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
ossimFilename thePrefFilename
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ savePreferences() [2/2]

bool ossimPreferences::savePreferences ( const ossimFilename pathname)

METHOD: ossimPreferences::savePreferences(filename)

Saves KWL to the specified filename.

Save the file to the specified preferences filename:

Definition at line 219 of file ossimPreferences.cpp.

220 {
221  static const char MODULE[] = "ossimPreferences::savePreferences()";
222  if (traceExec())
223  {
225  << "DEBUG: "<< MODULE << ", entering...\n";
226  }
227 
228  bool success = true;
229 
233  theKWL.write(pathname);
234 
235  thePrefFilename = pathname;
236  theInstanceIsModified = false;
237 
238  if (traceExec())
239  {
241  << "DEBUG: " << MODULE << ", returning...\n";
242  }
243 
244  return success;
245 }
ossimKeywordlist theKWL
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
ossimFilename thePrefFilename
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Data Documentation

◆ theInstance

ossimPreferences * ossimPreferences::theInstance = NULL
staticprotected

Definition at line 104 of file ossimPreferences.h.

Referenced by instance(), and ~ossimPreferences().

◆ theInstanceIsModified

bool ossimPreferences::theInstanceIsModified
mutableprotected

Definition at line 107 of file ossimPreferences.h.

Referenced by addPreference(), and addPreferences().

◆ theKWL

ossimKeywordlist ossimPreferences::theKWL
protected

Definition at line 105 of file ossimPreferences.h.

Referenced by addPreference(), addPreferences(), and ossimPreferences().

◆ thePrefFilename

ossimFilename ossimPreferences::thePrefFilename
protected

Definition at line 106 of file ossimPreferences.h.

Referenced by getPreferencesFilename().


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