BMPArealStructFactory.h
Go to the documentation of this file.
1/*!
2 * \file BMPArealStructFactory.h
3 * \brief Areal struct BMP factory
4 *
5 * Changelog:
6 * - 1. 2017-07-13 - lj - Partially rewrite this class, Scenario data only read from MongoDB.
7 * DataCenter will perform the data updating.
8 * - 2. 2017-11-29 - lj - Code style review.
9 * - 3. 2018-04-12 - lj - Code reformat.
10 *
11 * \author Huiran Gao, Liangjun Zhu
12 */
13#ifndef SEIMS_BMP_AREALSTRUCT_H
14#define SEIMS_BMP_AREALSTRUCT_H
15
16#include "tinyxml.h"
17#include "basic.h"
18#include "data_raster.hpp"
19
20#include "BMPFactory.h"
21#include "ParamInfo.h"
22
23using namespace ccgl;
24using namespace bmps;
25
26namespace bmps {
27/*!
28 * \class bmps::BMPArealStruct
29 * \brief Manage areal Structural BMP data, inherited from ParamInfo
30 */
32public:
33 //! Constructor
34 BMPArealStruct(const bson_t*& bsonTab, bson_iter_t& iter);
35 //! Destructor
37 //! Get name
38 string getBMPName() { return m_name; }
39 //! Get suitable landuse
40 vector<int>& getSuitableLanduse() { return m_landuse; }
41 //! Get parameters
42 map<string, ParamInfo<FLTPT>*>& getParameters() { return m_parameters; }
43 ////! Is EffectivenessVariable
44 //bool isEffectivenessVariable(){ return m_effectivenessVariable; }
45 ////! get change frequency
46 //int getChangeFrequency(){ return m_changeFrequency; }
47 //! getter and setter for last update time
48 time_t getLastUpdateTime() const { return m_lastUpdateTime; }
49 void setLastUpdateTime(time_t val) { m_lastUpdateTime = val; }
50private:
51 int m_id; ///< unique BMP ID
52 string m_name; ///< name
53 string m_desc; ///< description
54 string m_refer; ///< references
55 vector<int> m_landuse; ///< suitable placement landuse
56
57 ////! Is BMP effectiveness variable or not
58 //bool m_effectivenessVariable;
59 ////! Set the change frequency in seconds, if the BMP effectiveness is variable
60 //int m_changeFrequency;
61 //! last update time of BMP effectiveness
62 time_t m_lastUpdateTime;
63 /*!
64 * \key the parameter name, remember to add subbasin number as prefix when use GridFS file in MongoDB
65 * \value the ParamInfo class
66 */
67 map<string, ParamInfo<FLTPT>*> m_parameters;
68};
69
70/*!
71 * \class bmps::BMPArealStructFactory
72 * \brief Initiate Areal Structural BMPs
73 *
74 */
76public:
77 /// Constructor
78 BMPArealStructFactory(int scenarioId, int bmpId, int subScenario,
79 int bmpType, int bmpPriority, vector<string>& distribution,
80 const string& collection, const string& location, bool effectivenessChangeable = false,
81 time_t changeFrequency = -1, int variableTimes = -1);
82
83 /// Destructor
85
86 //! Load BMP parameters from MongoDB
87 void loadBMP(MongoClient* conn, const string& bmpDBName) OVERRIDE;
88
89 //! Set raster data if needed
90 void setRasterData(map<string, IntRaster*>& sceneRsMap) OVERRIDE;
91
92 //! Get management fields data
93 int* GetRasterData() OVERRIDE { return m_mgtFieldsRs; }
94
95 //! Get effect unit IDs
96 const vector<int>& getUnitIDs() const { return m_unitIDs; }
97 const vector<int>& getUnitIDsByIndex(){ return m_unitIDsSeries[m_seriesIndex]; }
98 const map<int, int>& getUpdateTimesByIndex(){ return m_unitUpdateTimes[m_seriesIndex]; }
99 void increaseSeriesIndex(){ m_seriesIndex++; }
100 int getSeriesIndex() { return m_seriesIndex; }
101
102 //! Get areal BMP parameters
103 const map<int, BMPArealStruct*>& getBMPsSettings() const { return m_bmpStructMap; }
104
105 //! Output
106 void Dump(std::ostream* fs) OVERRIDE;
107
108private:
109 //! management units file name
110 string m_mgtFieldsName;
111 //! management units raster data
112 int* m_mgtFieldsRs;
113 //! locations
114 vector<int> m_unitIDs;
115 //! Store the spatial unit IDs that need to update every year
116 vector<vector<int> > m_unitIDsSeries;
117 //! How many times are the above spatial units updated respectively
118 vector<map<int,int> > m_unitUpdateTimes;
119 int m_seriesIndex;
120 /*!
121 *\key The unique areal BMP ID
122 *\value Instance of BMPArealStruct
123 */
124 map<int, BMPArealStruct*> m_bmpStructMap;
125};
126}
127#endif /* SEIMS_BMP_AREALSTRUCT_H */
Base namespace for implementation of BMP configuration.
Class to store parameter item information.
Basic definitions.
#define OVERRIDE
A compatible reference to override or blank if not supported by the compiler.
Definition: basic.h:160
Initiate Areal Structural BMPs.
Definition: BMPArealStructFactory.h:75
const vector< int > & getUnitIDs() const
Get effect unit IDs.
Definition: BMPArealStructFactory.h:96
void Dump(std::ostream *fs) OVERRIDE
Output.
int * GetRasterData() OVERRIDE
Get management fields data.
Definition: BMPArealStructFactory.h:93
BMPArealStructFactory(int scenarioId, int bmpId, int subScenario, int bmpType, int bmpPriority, vector< string > &distribution, const string &collection, const string &location, bool effectivenessChangeable=false, time_t changeFrequency=-1, int variableTimes=-1)
Constructor.
const map< int, BMPArealStruct * > & getBMPsSettings() const
Get areal BMP parameters.
Definition: BMPArealStructFactory.h:103
void setRasterData(map< string, IntRaster * > &sceneRsMap) OVERRIDE
Set raster data if needed.
~BMPArealStructFactory()
Destructor.
void loadBMP(MongoClient *conn, const string &bmpDBName) OVERRIDE
Load BMP parameters from MongoDB.
Manage areal Structural BMP data, inherited from ParamInfo.
Definition: BMPArealStructFactory.h:31
vector< int > & getSuitableLanduse()
Get suitable landuse.
Definition: BMPArealStructFactory.h:40
map< string, ParamInfo< FLTPT > * > & getParameters()
Get parameters.
Definition: BMPArealStructFactory.h:42
time_t getLastUpdateTime() const
getter and setter for last update time
Definition: BMPArealStructFactory.h:48
string getBMPName()
Get name.
Definition: BMPArealStructFactory.h:38
~BMPArealStruct()
Destructor.
BMPArealStruct(const bson_t *&bsonTab, bson_iter_t &iter)
Constructor.
Base class of all kind of BMPs Factory.
Definition: BMPFactory.h:33
int bmpType()
Get BMP type 1 - reach BMPs which are attached to specific reaches and will change the character of t...
int bmpPriority()
Get BMP priority.
Base type of all interfaces.
Definition: basic.h:407
A simple wrapper of the class of MongoDB Client mongoc_client_t.
Definition: db_mongoc.h:46
All BMPs scenario related data, classes, and functions.
Definition: BMPArealSourceFactory.h:22
Common Cross-platform Geographic Library (CCGL)