WSL/SLF GitLab Repository

Commit a9e0da8c authored by Thomas Egger's avatar Thomas Egger
Browse files

Changed the name of ConfigReader to Config

parent da89437e
......@@ -81,7 +81,7 @@ METEOIO_OBJ = $(SRCDIR)/MeteoData.o \
$(SRCDIR)/DynamicLibrary.o \
$(SRCDIR)/A3DIO.o \
$(SRCDIR)/BufferedIOHandler.o \
$(SRCDIR)/ConfigReader.o \
$(SRCDIR)/Config.o \
$(SRCDIR)/Date.o \
$(SRCDIR)/Grid2DObject.o \
$(SRCDIR)/Grid3DObject.o \
......@@ -107,7 +107,7 @@ METEOIO_OBJ_POPC = $(SRCDIR)/IOInterface_par.o \
$(SRCDIR)/A3DIO_par.o \
$(SRCDIR)/MeteoData_par.o \
$(SRCDIR)/StationData_par.o \
$(SRCDIR)/ConfigReader_par.o \
$(SRCDIR)/Config_par.o \
$(SRCDIR)/Date_par.o \
$(SRCDIR)/Grid2DObject_par.o \
$(SRCDIR)/Grid3DObject_par.o \
......
......@@ -12,7 +12,7 @@ int main(int /*argc*/, char** argv) {
std::vector<StationData> vecStation;
//initializing the io handlers according to the config file
ConfigReader cfg("io.ini");
Config cfg("io.ini");
IOHandler raw_io(cfg);
BufferedIOHandler io(raw_io, cfg);
......
......@@ -14,7 +14,7 @@ int main(int /*argc*/, char** /*argv*/) {
std::vector< std::vector<MeteoData> > vecMeteo;
std::vector< std::vector<StationData> > vecStation;
ConfigReader cfg("io.ini");
Config cfg("io.ini");
IOHandler raw_io(cfg);
BufferedIOHandler io(raw_io, cfg);
......
......@@ -6,7 +6,7 @@ using namespace mio; //The MeteoIO namespace is called mio
//and a sub-dem is extracted starting at these coordinates and extending dist_x and dist_y and written out.
int main(void) {
DEMObject dem;
ConfigReader cfg("io.ini");
Config cfg("io.ini");
IOHandler io(cfg);
//reading dem
......
[General]
PLUGINPATH = ../../lib
PLUGINPATH = ../../lib/plugins
[Input]
COORDSYS = CH1903
......
......@@ -11,7 +11,7 @@ int main(int /*argc*/, char** argv) {
std::vector<MeteoData> vecMeteo;
std::vector<StationData> vecStation;
ConfigReader cfg("io.ini");
Config cfg("io.ini");
IOHandler raw_io(cfg);
BufferedIOHandler io(raw_io, cfg);
......
......@@ -575,7 +575,7 @@ gs 1 -1 sc (Array3D) dup sw pop 2 div neg 0 rm col0 sh gr
gs 1 -1 sc (Grid3DObject) dup sw pop 2 div neg 0 rm col0 sh gr
/Times-Bold ff 254.00 scf sf
11880 9450 m
gs 1 -1 sc (ConfigReader) dup sw pop 2 div neg 0 rm col0 sh gr
gs 1 -1 sc (Config) dup sw pop 2 div neg 0 rm col0 sh gr
/Times-Bold ff 254.00 scf sf
11880 10530 m
gs 1 -1 sc (IOUtils) dup sw pop 2 div neg 0 rm col0 sh gr
......
......@@ -105,7 +105,7 @@ Single
6 9765 8955 13950 9720
2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
9810 9000 13905 9000 13905 9675 9810 9675 9810 9000
4 1 0 50 -1 2 16 0.0000 4 255 1635 11880 9450 ConfigReader\001
4 1 0 50 -1 2 16 0.0000 4 255 1635 11880 9450 Config\001
-6
6 9765 10035 13950 10800
2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
......
......@@ -70,7 +70,7 @@ A3DIO::A3DIO(const A3DIO& aio) : IOInterface(NULL), cfg(aio.cfg)
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
A3DIO::A3DIO(const ConfigReader& cfgreader) : IOInterface(NULL), cfg(cfgreader)
A3DIO::A3DIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
......
......@@ -21,7 +21,7 @@
#include <meteoio/IOInterface.h>
#include <meteoio/Coords.h>
#include <meteoio/ConfigReader.h>
#include <meteoio/Config.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/IOUtils.h>
......@@ -39,7 +39,7 @@ class A3DIO : public IOInterface {
A3DIO(const std::string& configfile);
A3DIO(const A3DIO&);
A3DIO(const ConfigReader&);
A3DIO(const Config&);
~A3DIO() throw();
virtual void read2DGrid(Grid2DObject& dem_out, const std::string& name="");
......@@ -93,7 +93,7 @@ class A3DIO : public IOInterface {
const std::string& label);
void write2DMeteo(const std::vector< std::vector<MeteoData> >& data, const std::vector< std::vector<StationData> >& stations);
ConfigReader cfg;
Config cfg;
std::ifstream fin; //Input file streams
std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
};
......
......@@ -22,10 +22,10 @@ using namespace std;
namespace mio {
#ifdef _POPC_
BufferedIOHandler::BufferedIOHandler(IOHandler& _iohandler, const ConfigReader& _cfg)
BufferedIOHandler::BufferedIOHandler(IOHandler& _iohandler, const Config& _cfg)
: iohandler(_iohandler), cfg(_cfg), meteoprocessor(_cfg), meteoBuffer(), stationBuffer(), startDateBuffer(), endDateBuffer(), mapBufferedGrids()
#else
BufferedIOHandler::BufferedIOHandler(IOHandler& _iohandler, const ConfigReader& _cfg)
BufferedIOHandler::BufferedIOHandler(IOHandler& _iohandler, const Config& _cfg)
: IOInterface(NULL), iohandler(_iohandler), cfg(_cfg), meteoprocessor(_cfg), meteoBuffer(), stationBuffer(), startDateBuffer(), endDateBuffer(), mapBufferedGrids()
#endif
{
......
......@@ -24,7 +24,7 @@
#include <meteoio/IOHandler.h>
#endif
#include <meteoio/ConfigReader.h>
#include <meteoio/Config.h>
#include <meteoio/MeteoProcessor.h>
#include <map>
......@@ -54,17 +54,17 @@ class BufferedIOHandler : public IOInterface {
/**
* @brief The constructor accepts an already initialized child of IOInterface (e.g. A3DIO, BormaIO, ImisIO)
* and a ConfigReader object
* and a Config object
*
* Example Usage:
* @code
* IOHandler *io1;
* ConfigReader cfg("io.ini");
* Config cfg("io.ini");
* io1 = new A3DIO(cfg);
* BufferedIOHandler bio(*io1, cfg);
* @endcode
*/
BufferedIOHandler(IOHandler& _iohandler, const ConfigReader& _cfg);
BufferedIOHandler(IOHandler& _iohandler, const Config& _cfg);
#ifdef _POPC_
virtual ~BufferedIOHandler();
#else
......@@ -111,7 +111,7 @@ class BufferedIOHandler : public IOInterface {
* @code
* vector<MeteoData> vecMeteo; //empty vector
* vector<StationData> vecStation; //empty vector
* BufferedIOHandler bio(A3DIO("io.ini"), ConfigReader("io.ini"));
* BufferedIOHandler bio(A3DIO("io.ini"), Config("io.ini"));
* bio.readMeteoData(Date(2008,06,21,11,00), vecMeteo, vecStation); //21.6.2008 11:00
* @endcode
* @param _date A Date object representing the date/time for the sought MeteoData objects
......@@ -165,7 +165,7 @@ class BufferedIOHandler : public IOInterface {
void setBufferProperties();
IOHandler& iohandler;
ConfigReader cfg;
Config cfg;
MeteoProcessor meteoprocessor;
bool always_rebuffer;
......
......@@ -27,7 +27,7 @@ SET(meteoio_sources
IOInterface.cc
libinterpol1D.cc
StationData.cc
ConfigReader.cc
Config.cc
DynamicLibrary.cc
IOExceptions.cc
IOUtils.cc
......
......@@ -15,71 +15,71 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/ConfigReader.h>
#include <meteoio/Config.h>
using namespace std;
namespace mio {
const unsigned int ConfigReader::nothrow = 666;
const unsigned int Config::nothrow = 666;
//Constructors
ConfigReader::ConfigReader()
Config::Config()
{
//nothing is even put in the property map, the user will have to fill it by himself
}
ConfigReader::ConfigReader(const std::string& filename_in)
Config::Config(const std::string& filename_in)
{
addFile(filename_in);
}
//Populating the property map
void ConfigReader::addFile(const std::string& filename_in)
void Config::addFile(const std::string& filename_in)
{
sourcename = filename_in;
parseFile(filename_in);
}
void ConfigReader::addCmdLine(const std::string& cmd_line)
void Config::addCmdLine(const std::string& cmd_line)
{
sourcename = std::string("Command line");
parseCmdLine(cmd_line);
}
void ConfigReader::addKey(const std::string& key, const std::string& value)
void Config::addKey(const std::string& key, const std::string& value)
{
std::string section="GENERAL";
addKey(key, section, value);
}
void ConfigReader::addKey(const std::string& key, const std::string& section, const std::string& value)
void Config::addKey(const std::string& key, const std::string& section, const std::string& value)
{
std::string _section = section;
IOUtils::toUpper(_section);
properties[_section + "::" + key] = value;
}
std::ostream& operator<<(std::ostream &os, const ConfigReader& cfg)
std::ostream& operator<<(std::ostream &os, const Config& cfg)
{
os << "<ConfigReader>\n";
os << "<Config>\n";
map<string,string>::const_iterator it;
for (it=cfg.properties.begin(); it != cfg.properties.end(); it++){
os << (*it).first << " -> " << (*it).second << "\n";
}
os << "</ConfigReader>\n";
os << "</Config>\n";
return os;
}
//Parsing
void ConfigReader::parseCmdLine(const std::string& cmd_line)
void Config::parseCmdLine(const std::string& cmd_line)
{
(void)cmd_line;
throw IOException("Nothing implemented here", AT);
}
void ConfigReader::parseFile(const std::string& filename)
void Config::parseFile(const std::string& filename)
{
std::ifstream fin; //Input file streams
unsigned int linenr = 0;
......@@ -116,7 +116,7 @@ void ConfigReader::parseFile(const std::string& filename)
}
}
void ConfigReader::parseLine(const unsigned int& linenr, std::string& line, std::string& section)
void Config::parseLine(const unsigned int& linenr, std::string& line, std::string& section)
{
//First thing cut away any possible comments (may start with "#" or ";")
IOUtils::stripComments(line);
......@@ -146,12 +146,12 @@ void ConfigReader::parseLine(const unsigned int& linenr, std::string& line, std:
}
//Return key/value filename
std::string ConfigReader::getSourceName()
std::string Config::getSourceName()
{
return sourcename;
}
unsigned int ConfigReader::findKeys(std::vector<std::string>& vecResult,
unsigned int Config::findKeys(std::vector<std::string>& vecResult,
const std::string keystart,
const std::string section) const
{
......@@ -186,7 +186,7 @@ unsigned int ConfigReader::findKeys(std::vector<std::string>& vecResult,
#ifdef _POPC_
#include "marshal_meteoio.h"
using namespace mio; //HACK for POPC
void ConfigReader::Serialize(POPBuffer &buf, bool pack)
void Config::Serialize(POPBuffer &buf, bool pack)
{
if (pack)
{
......
......@@ -32,7 +32,7 @@ namespace mio {
/**
* @class ConfigReader
* @class Config
* @brief A class that reads a key/value file. These files (typically named *.ini) follow the INI file format standard (see http://en.wikipedia.org/wiki/INI_file) and have the following structure:
* - they consist of 0 or more explicitly indicated sections, which start with a sectionname enclosed in square brackets
* e.g. [General] or [Filter]
......@@ -56,23 +56,23 @@ namespace IOUtils {
}
#ifdef _POPC_
class ConfigReader : POPBase {
class Config : POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
#else
class ConfigReader {
class Config {
#endif
public:
/**
* @brief Empty constructor. The user MUST later one fill the internal key/value map object
*/
ConfigReader();
Config();
/**
* @brief Main constructor. The file is parsed and a key/value map object is internally created
* @param[in] filename_in string representing the absolute filename of the key/value file
*/
ConfigReader(const std::string& filename_in);
Config(const std::string& filename_in);
/**
* @brief Add the content of a file to the internal key/value map object
......@@ -102,16 +102,16 @@ class ConfigReader {
void addKey(const std::string& key, const std::string& section, const std::string& value);
/**
* @brief Returns the filename that the ConfigReader object was constructed with.
* @brief Returns the filename that the Config object was constructed with.
* @return std::string The absolute filename of the key/value file.
*/
std::string getSourceName();
/**
* @brief Print the content of the ConfigReader object (usefull for debugging)
* The ConfigReader is bound by "<ConfigReader>" and "</ConfigReader>" on separate lines
* @brief Print the content of the Config object (usefull for debugging)
* The Config is bound by "<Config>" and "</Config>" on separate lines
*/
friend std::ostream& operator<<(std::ostream& os, const ConfigReader& cfg);
friend std::ostream& operator<<(std::ostream& os, const Config& cfg);
/**
* @brief Template function to retrieve a vector of values of class T for a certain key
......@@ -150,9 +150,9 @@ class ConfigReader {
IOUtils::toUpper(_section);
IOUtils::getValueForKey<T>(properties, _section + "::" + key, vecT);
} catch(std::exception& e){
if (options != ConfigReader::nothrow) {
if (options != Config::nothrow) {
std::stringstream ss;
ss << "[E] Error for ConfigReader of " << sourcename << ": " << e.what();
ss << "[E] Error for Config of " << sourcename << ": " << e.what();
throw UnknownValueException(ss.str(), AT);
}
}
......@@ -183,9 +183,9 @@ class ConfigReader {
IOUtils::toUpper(_section);
IOUtils::getValueForKey<T>(properties, _section + "::" + key, t);
} catch(std::exception& e){
if (options != ConfigReader::nothrow) {
if (options != Config::nothrow) {
std::stringstream ss;
ss << "[E] Error for ConfigReader of " << sourcename << ": " << e.what();
ss << "[E] Error for Config of " << sourcename << ": " << e.what();
throw UnknownValueException(ss.str(), AT);
}
}
......@@ -217,7 +217,7 @@ class ConfigReader {
std::map<std::string, std::string> properties; //Save key value pairs
std::string sourcename; //description of the data source for the key/value pair
}; //end class definition ConfigReader
}; //end class definition Config
} //end namespace mio
......
......@@ -34,7 +34,7 @@ DynamicLibrary::~DynamicLibrary(void)
#endif
}
PluginObject* DynamicLibrary::newObject(const std::string& name, const ConfigReader& cfg)
PluginObject* DynamicLibrary::newObject(const std::string& name, const Config& cfg)
{
// If there is no valid library, return null
if(_objFile == NULL) {
......@@ -43,7 +43,7 @@ PluginObject* DynamicLibrary::newObject(const std::string& name, const ConfigRea
// Get the loadObject() function. If it doesn't exist, return NULL.
#ifdef WIN32
void (*loadSym)(const std::string&, const ConfigReader&) = (void (*)(const std::string&, const ConfigReader&))GetProcAddress(_objFile, "loadObject");
void (*loadSym)(const std::string&, const Config&) = (void (*)(const std::string&, const Config&))GetProcAddress(_objFile, "loadObject");
#else
void* loadSym = dlsym(_objFile, "loadObject");
#endif
......@@ -53,7 +53,7 @@ PluginObject* DynamicLibrary::newObject(const std::string& name, const ConfigRea
}
// Load a new instance of the requested class, and return it
void* obj = ((void* (*)(const std::string&, const ConfigReader&))(loadSym))(name, cfg);
void* obj = ((void* (*)(const std::string&, const Config&))(loadSym))(name, cfg);
return reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -18,7 +18,7 @@
#ifndef __DYNAMICLIB_H__
#define __DYNAMICLIB_H__
#include <meteoio/ConfigReader.h>
#include <meteoio/Config.h>
#ifndef USE_PRECOMPILED_HEADERS
#ifdef WIN32
......@@ -96,7 +96,7 @@ class DynamicLibrary {
// Creates a new instance of the named class, or returns NULL is the
// class isn't found.
PluginObject* newObject(const std::string& name, const ConfigReader& cfg);
PluginObject* newObject(const std::string& name, const Config& cfg);
friend class DynamicLoader; ///< The friend class DynamicLoader can solely instantiate the DynamicLibrary class (protected constructor)
};
......
......@@ -20,7 +20,7 @@
#include <meteoio/MeteoData.h>
#include <meteoio/StationData.h>
#include <meteoio/ConfigReader.h>
#include <meteoio/Config.h>
#include <meteoio/libinterpol1D.h>
#include <meteoio/FilterProperties.h>
......
......@@ -101,9 +101,9 @@ IOHandler::IOHandler(const IOHandler& aio) : IOInterface(NULL), cfg(aio.cfg), fi
#endif
#ifdef _POPC_
IOHandler::IOHandler(const ConfigReader& cfgreader) : cfg(cfgreader), fileio(cfgreader)
IOHandler::IOHandler(const Config& cfgreader) : cfg(cfgreader), fileio(cfgreader)
#else
IOHandler::IOHandler(const ConfigReader& cfgreader) : IOInterface(NULL), cfg(cfgreader), fileio(cfgreader)
IOHandler::IOHandler(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader), fileio(cfgreader)
#endif
{
#if defined(_POPC_) && defined(DEBUG_ARITHM)
......@@ -148,7 +148,7 @@ void IOHandler::loadPlugin(const std::string& libname, const std::string& classn
std::string pluginpath = "";
try {
cfg.getValue("PLUGINPATH", pluginpath, ConfigReader::nothrow);
cfg.getValue("PLUGINPATH", pluginpath, Config::nothrow);
if (pluginpath != "")
pluginpath += "/";
......
......@@ -43,7 +43,7 @@ class IOHandler : public IOInterface {
public:
IOHandler(const std::string& configfile);
IOHandler(const IOHandler&);
IOHandler(const ConfigReader&);
IOHandler(const Config&);
~IOHandler() throw();
//methods defined in the IOInterface class
......@@ -73,7 +73,7 @@ class IOHandler : public IOInterface {
void registerPlugins();
IOInterface *getPlugin(const std::string& cfgkey, const std::string& cfgsection="GENERAL");
ConfigReader cfg;
Config cfg;
std::map<std::string, IOPlugin::IOPlugin> mapPlugins;
A3DIO fileio;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment