1#ifndef FMTparallelwriter_Hm_included
2#define FMTparallelwriter_Hm_included
7#include <boost/thread/recursive_mutex.hpp>
64 const std::string& driver,
65 const std::vector<Core::FMTOutput>& outputs,
66 const std::vector<Models::FMTModel*>& allmodels,
67 std::vector<std::string>layersoptions = std::vector<std::string>(),
68 double minimaldrift = 0.5,
82 const std::string& driver,
84 std::vector<std::string>layersoptions = std::vector<std::string>(),
87 std::string primaryfilelocation = std::string());
103 void write(
const std::string& modelname,
104 const std::map<std::string, std::vector<std::vector<double>>>& results,
105 const int& firstPeriod,
const int& lastPeriod,
const int& iteration)
const;
113 void writeSchedules(
const std::string seqName,
const std::vector<Core::FMTSchedule> scheduleList,
bool append)
const;
122 std::map<std::string, std::vector<std::vector<double>>>
getResults(
const std::unique_ptr<Models::FMTModel>& modelptr,
const int& firstPeriod,
const int& lastPeriod)
const;
136 void getAndWrite(
const std::unique_ptr<Models::FMTModel>& modelptr,
const std::vector<Core::FMTOutput>& loutputs);
151 const
std::map<
std::
string,
std::map<
double,
std::vector<
double>>>_getDriftProbability(
152 const
std::map<
std::
string,
std::vector<
std::vector<
double>>>& globalvalues,
153 const
std::map<
std::
string,
std::vector<
std::vector<
double>>>& localvalues,
154 const
bool lower = true) const;
158 std::vector<
Core::FMTOutput>m_outputstowrite;
162 GDALDataset* m_resultsdataset;
165 std::map<std::string, OGRLayer*> m_resultslayer;
168 OGRLayer* m_driftlayer;
172 mutable boost::recursive_mutex m_mtx;
175 double m_resultsminimaldrift;
181 std::vector<std::string> m_alllayeroptions;
184 int m_outputfirstperiod;
187 int m_outputlastperiod;
190 std::string m_projectdirectory;
193 std::string m_projectname;
196 std::string m_outputLocationPath;
#define FMTEXPORT
Definition: FMTutility.h:125
Writer used in concurrency to write multiple results in the same layer.
Definition: FMTParallelWriter.h:27
FMTParallelWriter(const std::string &location, const std::string &driver, const std::vector< Core::FMTOutput > &outputs, const std::vector< Models::FMTModel * > &allmodels, std::vector< std::string >layersoptions=std::vector< std::string >(), double minimaldrift=0.5, Core::FMToutputlevel outputlevel=Core::FMToutputlevel::totalonly)
Construct a FMTParallelWriter from the location, driver and outputs and the base models to write.
void setLayer(const std::string &p_name)
Add a new layer for a given model.
FMTParallelWriter(const std::string &location, const std::string &driver, Core::FMToutputlevel outputlevel=Core::FMToutputlevel::totalonly, std::vector< std::string >layersoptions=std::vector< std::string >(), int firstPeriod=1, int lastPeriod=1, std::string primaryfilelocation=std::string())
Construct a FMTParallelWriter without layers and outputs.
void getAndWrite(const std::unique_ptr< Models::FMTModel > &modelptr, const std::vector< Core::FMTOutput > &loutputs)
Get the results of a model and write them down.
std::map< std::string, std::vector< std::vector< double > > > getResults(const std::unique_ptr< Models::FMTModel > &modelptr, const int &firstPeriod, const int &lastPeriod) const
Get the results of a model.
void setDriftProbability(const std::string &globalmodel, const std::string &localmodel) const
Compute the drift probability from the global and local models starting from a minimal drift proporti...
FMTParallelWriter(const FMTParallelWriter &rhs)=default
Default copy constructor for FMTParallelWriter.
void close() noexcept
Close the dataset and destroy the layers, after which the writer is no longer usable.
FMTParallelWriter()=default
Default constructor for FMTParallelWriter.
void writeSchedules(const std::string seqName, const std::vector< Core::FMTSchedule > scheduleList, bool append) const
Write schedules to a file.
void write(const std::string &modelname, const std::map< std::string, std::vector< std::vector< double > > > &results, const int &firstPeriod, const int &lastPeriod, const int &iteration) const
Write the model results from the first to the last period for a given iteration (replicate).
virtual ~FMTParallelWriter()
Default destructor for FMTParallelWriter.
Main parser reading and writing model files, for single or multiple scenarios, using all the other FM...
Definition: FMTModelParser.h:48
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
FMToutputlevel
Enumerator describing the level of detail of an output (standard, total only, development).
Definition: FMTutility.h:22
@ totalonly
Definition: FMTutility.h:24
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTAreaParser.h:54
Namespace for parallel tasking may include multithreading / multiprocessing.
Definition: FMTOpAreaSchedulerTask.h:40