Scenario.h
浏览该文件的文档.
1/*!
2 * \file Scenario.h
3 * \brief Scenario class in BMP database
4 *
5 * Changelog:
6 * - 1. 2016-06-16 - lj - Replaced SQLite by MongoDB to manager BMP scenario data.
7 *
8 * \author Liang-Jun Zhu
9 */
10#ifndef SEIMS_SCENARIO_H
11#define SEIMS_SCENARIO_H
12
13#include "basic.h"
14#include "db_mongoc.h"
15#include "BMPText.h"
16#include "BMPFactory.h"
17#include "BMPPlantMgtFactory.h"
21
22using namespace ccgl;
23
24/*!
25 * \namespace bmps
26 * \ingroup bmps
27 * \brief Namespace for all BMP related
28 */
29namespace bmps {
30/*!
31 * \class Scenario
32 * \brief Main class of scenario in BMP database
33 *
34 * Scenario contains a collection of BMPFactory.
35 * Each BMPFactory is corresponding to one type of BMP.
36 *
37 * Usage:
38 * - 1. Instantiate the class.
39 * - 2. Invoke DataCenter::SetRasterForScenario() function to set raster data if needed.
40 * - 3. Invoke setRasterForEachBMP().
41 * - 4. Set as an input parameter for module use.
42 *
43 * Revised:
44 * - 1. Replaced SQLite by MongoDB, 2016-6-16.
45 * - 2. Add setRasterForEachBMP() function, 2017-7-12.
46 */
48public:
49 //! Constructor according to BMP database name and scenario ID
50 Scenario(MongoClient* conn, const string& dbName, int subbsnID = 0, int scenarioID = 0,
51 time_t startTime = -1, time_t endTime = -1);
52
53 //! Destructor
55
56 //! Get scenario ID, base scenario iD is 0
57 int ID() const { return m_sceneID; }
58
59 //! If this is base scenario
60 bool IsBaseScenario() { return m_sceneID == 0; }
61
62 //! Get scenario name
63 string Name() { return m_name; };
64
65 //! Get BMPs Factories
66 map<int, BMPFactory *>& GetBMPFactories() { return m_bmpFactories; }
67
68 //! Write all BMPs information of this scenario to a text file
69 void Dump(string& fileName);
70
71 //! Output all BMPs information of this scenario to ostream
72 void Dump(std::ostream* fs);
73
74 //! get scenario required raster map. DO NOT DEFINE AS CONST FUNCTION, SINCE m_sceneRsMap WILL BE CHANGED ELSEWHERE!
75 map<string, IntRaster *>& getSceneRasterDataMap() { return m_sceneRsMap; }
76
77 //! set raster data for BMPs
79
80
81private:
82 /*!
83 * \brief Map of BMPs Factory
84 * the Key is unique BMP ID, and the value is BMPFactory
85 */
86 map<int, BMPFactory *> m_bmpFactories;
87 /*!
88 * \brief Map of spatial data of scenario data, both 1D and 2D
89 */
90 map<string, IntRaster *> m_sceneRsMap;
91
92 /// Load scenario information
93 void loadScenario();
94
95 /// Get scenario name
96 void loadScenarioName();
97
98 /// Load each BMP in current scenario
99 void loadBMPs();
100
101 /// Load a single BMP information via BMPFactory
102 void loadBMPDetail();
103
104private:
105 //! MongoDB client object, added by Liangjun
106 MongoClient* m_conn;
107 //! MongoDB name of BMP
108 string m_bmpDBName;
109 //! Collections in BMP database used for data checking
110 vector<string> m_bmpCollections;
111 //! Scenario ID, e.g., 0
112 int m_sceneID;
113 //! Scenario Name, e.g., base scenario
114 string m_name;
115 //! Subbasin ID, 0 for the entire basin
116 int m_subbsnID;
117 //! the start time of scenario simulation
118 time_t m_startTime;
119 //! the start time of scenario simulation
120 time_t m_endTime;
121};
122
123} /* MainBMP */
124#endif /* SEIMS_SCENARIO_H */
Areal source pollution and BMP factory
Areal struct BMP factory
Base namespace for implementation of BMP configuration
Plant management operations factory
Point source pollution and BMP factory
BMP related const strings
Basic definitions.
Main class of scenario in BMP database
Definition: Scenario.h:47
void Dump(string &fileName)
Write all BMPs information of this scenario to a text file
map< int, BMPFactory * > & GetBMPFactories()
Get BMPs Factories
Definition: Scenario.h:66
void setRasterForEachBMP()
set raster data for BMPs
int ID() const
Get scenario ID, base scenario iD is 0
Definition: Scenario.h:57
void Dump(std::ostream *fs)
Output all BMPs information of this scenario to ostream
map< string, IntRaster * > & getSceneRasterDataMap()
get scenario required raster map. DO NOT DEFINE AS CONST FUNCTION, SINCE m_sceneRsMap WILL BE CHANGED...
Definition: Scenario.h:75
~Scenario()
Destructor
bool IsBaseScenario()
If this is base scenario
Definition: Scenario.h:60
string Name()
Get scenario name
Definition: Scenario.h:63
Scenario(MongoClient *conn, const string &dbName, int subbsnID=0, int scenarioID=0, time_t startTime=-1, time_t endTime=-1)
Constructor according to BMP database name and scenario ID
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
Simple wrappers of the API of MongoDB C driver mongo-c-driver, see MongoDB C Driver for more informat...
All BMPs scenario related data, classes, and functions.
Definition: BMPArealSourceFactory.h:22
Common Cross-platform Geographic Library (CCGL)