WSL/SLF GitLab Repository

Commit 46a13f38 authored by Thomas Egger's avatar Thomas Egger
Browse files

BUGFIX: When adding a key on the fly to the ConfigReader object it disappeared...

BUGFIX: When adding a key on the fly to the ConfigReader object it disappeared when accessing it in a plugin. Reason: The dynamic instantiation used the filename parameter in the constructor of the plugins instead of the ConfigReader object itself. Architectural change inside DynamicLibrary was necessary.
parent 0ad03f63
......@@ -34,7 +34,7 @@ DynamicLibrary::~DynamicLibrary(void)
#endif
}
PluginObject* DynamicLibrary::newObject(const std::string& name, const std::string& filename)
PluginObject* DynamicLibrary::newObject(const std::string& name, const ConfigReader& cfg)
{
// If there is no valid library, return null
if(_objFile == NULL) {
......@@ -43,7 +43,7 @@ PluginObject* DynamicLibrary::newObject(const std::string& name, const std::stri
// Get the loadObject() function. If it doesn't exist, return NULL.
#ifdef WIN32
void (*loadSym)(const std::string&, const std::string&) = (void (*)(const std::string&, const std::string&))GetProcAddress(_objFile, "loadObject");
void (*loadSym)(const std::string&, const ConfigReader&) = (void (*)(const std::string&, const ConfigReader&))GetProcAddress(_objFile, "loadObject");
#else
void* loadSym = dlsym(_objFile, "loadObject");
#endif
......@@ -53,7 +53,7 @@ PluginObject* DynamicLibrary::newObject(const std::string& name, const std::stri
}
// Load a new instance of the requested class, and return it
void* obj = ((void* (*)(const std::string&, const std::string&))(loadSym))(name, filename);
void* obj = ((void* (*)(const std::string&, const ConfigReader&))(loadSym))(name, cfg);
return reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -18,6 +18,7 @@
#ifndef __DYNAMICLIB_H__
#define __DYNAMICLIB_H__
#include <meteoio/ConfigReader.h>
#ifndef USE_PRECOMPILED_HEADERS
#ifdef WIN32
......@@ -95,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 std::string& filename);
PluginObject* newObject(const std::string& name, const ConfigReader& cfg);
friend class DynamicLoader; ///< The friend class DynamicLoader can solely instantiate the DynamicLibrary class (protected constructor)
};
......
......@@ -160,7 +160,7 @@ void IOHandler::loadPlugin(const std::string& libname, const std::string& classn
if(dynLibrary == NULL) {
std::cout << "failed\n\tCouldn't load the dynamic library " << filename << "\n\t" << DynamicLoader::getErrorMessage() << std::endl;
} else {
io = dynamic_cast<IOInterface*>((dynLibrary)->newObject(classname, cfg.getSourceName()));
io = dynamic_cast<IOInterface*>((dynLibrary)->newObject(classname, cfg));
if(io == NULL) {
std::cout << "failed" << std::endl;
......
......@@ -101,7 +101,7 @@ The format is the following:
5426523.318065105000 (y coordinate of centre of upper left pixel in map units)
*/
ARCIO::ARCIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
ARCIO::ARCIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
......@@ -320,10 +320,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const string& classname, const string& filename) {
void* loadObject(const std::string& classname, const ConfigReader& cfg) {
if(classname == "ARCIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new ARCIO(deleteObject, filename);
return new ARCIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -41,7 +41,7 @@ namespace mio {
class ARCIO : public IOInterface {
public:
ARCIO(void (*delObj)(void*), const std::string& filename);
ARCIO(void (*delObj)(void*), const ConfigReader& i_cfg);
ARCIO(const std::string& configfile);
ARCIO(const ARCIO&);
......
......@@ -40,7 +40,7 @@ namespace mio {
const double ARPSIO::plugin_nodata = -999.; //plugin specific nodata value
ARPSIO::ARPSIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
ARPSIO::ARPSIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
dimx=dimy=dimz=0;
......@@ -382,10 +382,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const string& classname, const string& filename) {
void* loadObject(const std::string& classname, const ConfigReader& cfg) {
if(classname == "ARPSIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new ARPSIO(deleteObject, filename);
return new ARPSIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -45,7 +45,7 @@ namespace mio {
*/
class ARPSIO : public IOInterface {
public:
ARPSIO(void (*delObj)(void*), const std::string& filename);
ARPSIO(void (*delObj)(void*), const ConfigReader& i_cfg);
ARPSIO(const std::string& configfile);
ARPSIO(const ARPSIO&);
......
......@@ -46,7 +46,7 @@ namespace mio {
const double BormaIO::plugin_nodata = -999.0; //plugin specific nodata value
BormaIO::BormaIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
BormaIO::BormaIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
......@@ -540,10 +540,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const std::string& classname, const std::string& filename) {
void* loadObject(const string& classname, const ConfigReader& cfg) {
if(classname == "BormaIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new BormaIO(deleteObject, filename);
return new BormaIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -42,9 +42,7 @@ namespace mio {
class BormaIO : public IOInterface {
public:
//virtual BormaIO* clone() const;
BormaIO(void (*delObj)(void*), const std::string& filename);
BormaIO(void (*delObj)(void*), const ConfigReader& i_cfg);
BormaIO(const std::string& configfile);
BormaIO(const BormaIO&);
......
......@@ -67,7 +67,8 @@ namespace mio {
const double GSNIO::plugin_nodata = -999.0; //plugin specific nodata value
GSNIO::GSNIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename){
GSNIO::GSNIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
initGSNConnection();
}
......@@ -420,10 +421,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const std::string& classname, const std::string& filename) {
void* loadObject(const string& classname, const ConfigReader& cfg) {
if(classname == "GSNIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new GSNIO(deleteObject, filename);
return new GSNIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -44,7 +44,7 @@ namespace mio {
*/
class GSNIO : public IOInterface {
public:
GSNIO(void (*delObj)(void*), const std::string& filename);
GSNIO(void (*delObj)(void*), const ConfigReader& i_cfg);
GSNIO(const std::string& configfile);
GSNIO(const GSNIO&);
......
......@@ -45,7 +45,7 @@ namespace mio {
const double GeotopIO::plugin_nodata = -9999.0; //plugin specific nodata value
GeotopIO::GeotopIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
GeotopIO::GeotopIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
......@@ -206,7 +206,6 @@ void GeotopIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector< std::vector<StationData> >& vecStation,
const unsigned int& stationindex)
{
vector<std::string> tmpvec, vecColumnNames;
string line="", filename="", path="", prefix="";
......@@ -544,10 +543,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const std::string& classname, const std::string& filename) {
void* loadObject(const std::string& classname, const ConfigReader& cfg) {
if(classname == "GeotopIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new GeotopIO(deleteObject, filename);
return new GeotopIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -37,7 +37,7 @@ class GeotopIO : public IOInterface {
public:
//virtual GeotopIO* clone() const;
GeotopIO(void (*delObj)(void*), const std::string& filename);
GeotopIO(void (*delObj)(void*), const ConfigReader& i_cfg);
GeotopIO(const std::string& configfile);
GeotopIO(const GeotopIO&);
......
......@@ -41,7 +41,7 @@ namespace mio {
const double GrassIO::plugin_nodata = -999.0; //plugin specific nodata value
GrassIO::GrassIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
GrassIO::GrassIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
......@@ -281,10 +281,11 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const string& classname, const string& filename) {
void* loadObject(const string& classname, const ConfigReader& cfg) {
if(classname == "GrassIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new GrassIO(deleteObject, filename);
return new GrassIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -41,7 +41,7 @@ namespace mio {
*/
class GrassIO : public IOInterface {
public:
GrassIO(void (*delObj)(void*), const std::string& filename);
GrassIO(void (*delObj)(void*), const ConfigReader& i_cfg);
GrassIO(const std::string& configfile);
GrassIO(const GrassIO&);
......
......@@ -64,7 +64,7 @@ void ImisIO::getDBParameters()
cfg.getValue("DBPASS", "Output", oraclePassword_out);*/
}
ImisIO::ImisIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
ImisIO::ImisIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
getDBParameters();
......@@ -453,10 +453,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const string& classname, const string& filename) {
void* loadObject(const string& classname, const ConfigReader& cfg) {
if(classname == "ImisIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new ImisIO(deleteObject, filename);
return new ImisIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -43,7 +43,7 @@ namespace mio {
*/
class ImisIO : public IOInterface {
public:
ImisIO(void (*delObj)(void*), const std::string& filename);
ImisIO(void (*delObj)(void*), const ConfigReader& i_cfg);
ImisIO(const std::string& configfile);
ImisIO(const ImisIO&);
......
......@@ -43,7 +43,7 @@ namespace mio {
const double PGMIO::plugin_nodata = -999.; //plugin specific nodata value. It can also be read by the plugin (depending on what is appropriate)
PGMIO::PGMIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
PGMIO::PGMIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
}
......@@ -276,10 +276,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const string& classname, const string& filename) {
void* loadObject(const string& classname, const ConfigReader& cfg) {
if(classname == "PGMIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new PGMIO(deleteObject, filename);
return new PGMIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
......@@ -41,7 +41,7 @@ namespace mio {
*/
class PGMIO : public IOInterface {
public:
PGMIO(void (*delObj)(void*), const std::string& filename);
PGMIO(void (*delObj)(void*), const ConfigReader& i_cfg);
PGMIO(const std::string& configfile);
PGMIO(const PGMIO&);
......
......@@ -119,7 +119,7 @@ void SMETIO::checkColumnNames(const std::vector<std::string>& vecColumns, const
//END STATIC SECTION
SMETIO::SMETIO(void (*delObj)(void*), const std::string& filename) : IOInterface(delObj), cfg(filename)
SMETIO::SMETIO(void (*delObj)(void*), const ConfigReader& i_cfg) : IOInterface(delObj), cfg(i_cfg)
{
parseInputOutputSection();
}
......@@ -746,10 +746,10 @@ extern "C"
delete reinterpret_cast<PluginObject*>(obj);
}
void* loadObject(const string& classname, const string& filename) {
void* loadObject(const string& classname, const ConfigReader& cfg) {
if(classname == "SMETIO") {
//cerr << "Creating dynamic handle for " << classname << endl;
return new SMETIO(deleteObject, filename);
return new SMETIO(deleteObject, cfg);
}
//cerr << "Could not load " << classname << endl;
return NULL;
......
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