WSL/SLF GitLab Repository

Commit 7dedf299 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The IOManager can now return a copy of its internal Config object. This is...

The IOManager can now return a copy of its internal Config object. This is convenient for times when one wants to create extra outputs but using a different plugin. A missing const has been added to Config and creating an IOHandler by passing it a config file name is not possible anymore (this was deprecated when we introduced the IOManager). Therefore, the IOHandler now only keeps a reference to a Config object. This means that in the full structure held within IOManager, only one copy of Config is kept, the rest being references.
parent 3b62f4d5
......@@ -162,7 +162,7 @@ void Config::parseLine(const unsigned int& linenr, std::string& line, std::strin
}
//Return key/value filename
std::string Config::getSourceName()
std::string Config::getSourceName() const
{
return sourcename;
}
......
......@@ -116,7 +116,7 @@ class Config {
* @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();
std::string getSourceName() const;
/**
* @brief Print the content of the Config object (usefull for debugging)
......
......@@ -82,16 +82,6 @@ void IOHandler::registerPlugins()
mapPlugins["COSMOXML"] = IOPlugin("libcosmoxmlio"+popc_extra+libsuffix, "CosmoXMLIO", NULL, NULL);
}
#ifdef _POPC_
IOHandler::IOHandler(const std::string& configfile) : cfg(configfile), fileio(configfile), enable_copying(false) {
#else
IOHandler::IOHandler(const std::string& configfile) : IOInterface(NULL), cfg(configfile), fileio(configfile),
enable_copying(false) {
#endif
registerPlugins();
parse_copy_config();
}
//Copy constructor
#ifdef _POPC_
//IOHandler::IOHandler(const IOHandler& aio) : cfg(aio.cfg), fileio(aio.cfg), bormaio(aio.cfg), imisio(aio.cfg){
......
......@@ -45,7 +45,6 @@ class IOHandler {
class IOHandler : public IOInterface {
#endif
public:
IOHandler(const std::string& configfile);
#ifndef _POPC_
IOHandler(const IOHandler&);
#endif
......@@ -103,7 +102,7 @@ class IOHandler : public IOInterface {
void parse_copy_config();
void copy_parameters(const size_t& stationindex, std::vector< METEO_TIMESERIE >& vecMeteo) const;
Config cfg;
const Config& cfg;
std::map<std::string, IOPlugin> mapPlugins;
A3DIO fileio;
......
......@@ -43,7 +43,6 @@ parclass IOHandler {
// Note : No heritage here for POPC++ : a parclass cannot herit from a class
classuid(1003);
public:
IOHandler(const std::string& configfile) @{od.url("localhost");}; // @{ power=100 ?: 50; };
//IOHandler(const IOHandler&) @{od.url("localhost");};
IOHandler(const Config&) @{od.url("localhost");}; //@{ power=100 ?: 50; };
~IOHandler();
......@@ -77,7 +76,7 @@ parclass IOHandler {
void registerPlugins();
IOInterface *getPlugin(const std::string& cfgkey, const std::string& cfgsection="GENERAL");
Config cfg;
const Config& cfg;
std::map<std::string, IOPlugin> mapPlugins;
A3DIO fileio;
};
......
......@@ -54,6 +54,11 @@ double IOManager::getAvgSamplingRate()
}
}
const Config IOManager::getConfig() const
{
return cfg;
}
void IOManager::push_meteo_data(const ProcessingLevel& level, const Date& date_start, const Date& date_end,
const std::vector< METEO_TIMESERIE >& vecMeteo)
{
......
......@@ -165,6 +165,12 @@ class IOManager {
#else
void writeMeteoData(const std::vector< METEO_TIMESERIE >& vecMeteo, const std::string& name="");
#endif
/**
* @brief Returns a copy of the internal Config object.
* This is convenient to clone an iomanager
* @return new Config object as a copy of the internal Config
*/
const Config getConfig() const;
std::string toString() const;
friend std::ostream& operator<<(std::ostream& os, const IOManager& io);
......
......@@ -72,6 +72,8 @@ parclass IOManager {
void writeMeteoData([in ,proc=marshal_vector_METEO_TIMESERIE]/*const*/ std::vector< METEO_TIMESERIE >& vecMeteo, [in]const std::string& name=""); //HACK popc
const Config getConfig() const;
std::string toString() /*const*/; //HACK popc
//friend std::ostream& operator<<(std::ostream& os, const IOManager& io);
......
......@@ -48,6 +48,7 @@ bool MeteoGrids::initStaticData()
paramname.push_back("V");
paramname.push_back("W");
paramname.push_back("SWE");
paramname.push_back("ROT");
paramname.push_back("ALB");
paramname.push_back("DEM");
paramname.push_back("SLOPE");
......
......@@ -60,6 +60,7 @@ class MeteoGrids {
V, ///< North component of wind
W, ///< Vertical component of wind
SWE, ///< Snow Water Equivalent
ROT, ///< Generated runoff
ALB, ///< Albedo
DEM, ///< Digital Elevation Model
SLOPE, ///< DEM slope angle
......
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