Rev 284 | Rev 315 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 284 | Rev 314 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | {
|
15 | {
|
16 | mInfile=0; |
16 | mInfile=0; |
17 | }
|
17 | }
|
18 | Environment::~Environment() |
18 | Environment::~Environment() |
19 | {
|
19 | {
|
20 | if (mInfile) |
- | |
- | 20 | if (mInfile) { |
|
21 | delete mInfile; |
21 | delete mInfile; |
- | 22 | qDeleteAll(mSpeciesSets); |
|
- | 23 | qDeleteAll(mClimate); |
|
- | 24 | }
|
|
22 | }
|
25 | }
|
23 | 26 | ||
24 | bool Environment::loadFromFile(const QString &fileName) |
27 | bool Environment::loadFromFile(const QString &fileName) |
25 | {
|
28 | {
|
26 | QString source = Helper::loadTextFile(GlobalSettings::instance()->path(fileName)); |
29 | QString source = Helper::loadTextFile(GlobalSettings::instance()->path(fileName)); |
Line 78... | Line 81... | ||
78 | set->setup(); |
81 | set->setup(); |
79 | mSpeciesSets.push_back(set); |
82 | mSpeciesSets.push_back(set); |
80 | mCreatedObjects[name] = (void*)set; |
83 | mCreatedObjects[name] = (void*)set; |
81 | }
|
84 | }
|
82 | qDebug() << mSpeciesSets.count() << "species sets created."; |
85 | qDebug() << mSpeciesSets.count() << "species sets created."; |
- | 86 | } else { |
|
- | 87 | // no species sets specified
|
|
- | 88 | SpeciesSet *speciesSet = new SpeciesSet(); |
|
- | 89 | mSpeciesSets.push_back(speciesSet); |
|
- | 90 | speciesSet->setup(); |
|
- | 91 | mCurrentSpeciesSet = speciesSet; |
|
83 | }
|
92 | }
|
84 | 93 | ||
85 | // ******** setup of Climate *******
|
94 | // ******** setup of Climate *******
|
86 | if ((index = mKeys.indexOf(climateKey))>-1) { |
95 | if ((index = mKeys.indexOf(climateKey))>-1) { |
87 | DebugTimer t("environment:load climate"); |
96 | DebugTimer t("environment:load climate"); |
Line 92... | Line 101... | ||
92 | xml.setNodeValue(climateKey,name); // set xml value |
101 | xml.setNodeValue(climateKey,name); // set xml value |
93 | // create climate sets
|
102 | // create climate sets
|
94 | Climate *climate = new Climate(); |
103 | Climate *climate = new Climate(); |
95 | climate->setup(); |
104 | climate->setup(); |
96 | mClimate.push_back(climate); |
105 | mClimate.push_back(climate); |
97 | mCreatedObjects[name]=(void*)climate; |
- | |
98 | }
|
106 | }
|
99 | qDebug() << mClimate.count() << "climates created"; |
107 | qDebug() << mClimate.count() << "climates created"; |
- | 108 | } else { |
|
- | 109 | // no climate defined - setup default climate
|
|
- | 110 | Climate *c = new Climate(); |
|
- | 111 | c->setup(); |
|
- | 112 | mClimate.push_back(c); |
|
- | 113 | mCreatedObjects["default_climate"]=(void*)c; // prepare clean cleanup |
|
- | 114 | mCurrentClimate = c; |
|
100 | }
|
115 | }
|
101 | return true; |
116 | return true; |
102 | 117 | ||
103 | } catch(const IException &e) { |
118 | } catch(const IException &e) { |
104 | QString error_msg = QString("An error occured during the setup of the environment: \n%1").arg(e.toString()); |
119 | QString error_msg = QString("An error occured during the setup of the environment: \n%1").arg(e.toString()); |