1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * ValueStorage.cpp
|
---|
10 | *
|
---|
11 | * Created on: Jul 22, 2010
|
---|
12 | * Author: heber
|
---|
13 | */
|
---|
14 |
|
---|
15 | // include config.h
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include <config.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "CodePatterns/MemDebug.hpp"
|
---|
21 |
|
---|
22 | #include "CodePatterns/Singleton_impl.hpp"
|
---|
23 |
|
---|
24 | #include "Actions/OptionTrait.hpp"
|
---|
25 | #include "Actions/OptionRegistry.hpp"
|
---|
26 | #include "Actions/Values.hpp"
|
---|
27 | #include "Actions/ValueStorage.hpp"
|
---|
28 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
29 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
30 | #include "CodePatterns/Assert.hpp"
|
---|
31 | #include "CodePatterns/Log.hpp"
|
---|
32 | #include "CodePatterns/Verbose.hpp"
|
---|
33 | #include "LinearAlgebra/BoxVector.hpp"
|
---|
34 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
35 | #include "LinearAlgebra/Vector.hpp"
|
---|
36 | #include "RandomNumbers/RandomNumberDistribution_Parameters.hpp"
|
---|
37 | #include "atom.hpp"
|
---|
38 | #include "Box.hpp"
|
---|
39 | #include "element.hpp"
|
---|
40 | #include "molecule.hpp"
|
---|
41 | #include "periodentafel.hpp"
|
---|
42 | #include "World.hpp"
|
---|
43 |
|
---|
44 | ValueStorage::ValueStorage() :
|
---|
45 | OptionRegistry_instance(OptionRegistry::getInstance())
|
---|
46 | {};
|
---|
47 |
|
---|
48 | ValueStorage::~ValueStorage() {};
|
---|
49 |
|
---|
50 |
|
---|
51 | bool ValueStorage::isCurrentValuePresent(const char *name) const
|
---|
52 | {
|
---|
53 | return (CurrentValueMap.find(name) != CurrentValueMap.end());
|
---|
54 | }
|
---|
55 |
|
---|
56 | void ValueStorage::queryCurrentValue(const char * name, const atom * &_T)
|
---|
57 | {
|
---|
58 | int atomID = -1;
|
---|
59 | if (typeid( atom *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
60 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
61 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
62 | atomID = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
63 | CurrentValueMap.erase(name);
|
---|
64 | } else if (typeid( const atom *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
65 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
66 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
67 | atomID = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
68 | CurrentValueMap.erase(name);
|
---|
69 | } else
|
---|
70 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
71 | << ValueStoragePairTypeName(std::make_pair(
|
---|
72 | typeid(_T).name(),
|
---|
73 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
74 | );
|
---|
75 | _T = World::getInstance().getAtom(AtomById(atomID));
|
---|
76 | }
|
---|
77 |
|
---|
78 | void ValueStorage::queryCurrentValue(const char * name, const element * &_T) {
|
---|
79 | int Z = -1;
|
---|
80 | if (typeid(const element *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
81 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
82 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
83 | Z = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
84 | CurrentValueMap.erase(name);
|
---|
85 | } else
|
---|
86 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
87 | << ValueStoragePairTypeName(std::make_pair(
|
---|
88 | typeid(_T).name(),
|
---|
89 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
90 | );
|
---|
91 | _T = World::getInstance().getPeriode()->FindElement(Z);
|
---|
92 | }
|
---|
93 |
|
---|
94 | void ValueStorage::queryCurrentValue(const char * name, const molecule * &_T) {
|
---|
95 | int molID = -1;
|
---|
96 | if (typeid( const molecule *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
97 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
98 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
99 | molID = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
100 | CurrentValueMap.erase(name);
|
---|
101 | } else
|
---|
102 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
103 | << ValueStoragePairTypeName(std::make_pair(
|
---|
104 | typeid(_T).name(),
|
---|
105 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
106 | );
|
---|
107 | _T = World::getInstance().getMolecule(MoleculeById(molID));
|
---|
108 | }
|
---|
109 |
|
---|
110 | void ValueStorage::queryCurrentValue(const char * name, class Box &_T) {
|
---|
111 | RealSpaceMatrix M;
|
---|
112 | double tmp;
|
---|
113 | if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
114 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
115 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
116 | std::istringstream stream(CurrentValueMap[name]);
|
---|
117 | stream >> tmp;
|
---|
118 | M.set(0,0,tmp);
|
---|
119 | stream >> tmp;
|
---|
120 | M.set(0,1,tmp);
|
---|
121 | M.set(1,0,tmp);
|
---|
122 | stream >> tmp;
|
---|
123 | M.set(0,2,tmp);
|
---|
124 | M.set(2,0,tmp);
|
---|
125 | stream >> tmp;
|
---|
126 | M.set(1,1,tmp);
|
---|
127 | stream >> tmp;
|
---|
128 | M.set(1,2,tmp);
|
---|
129 | M.set(2,1,tmp);
|
---|
130 | stream >> tmp;
|
---|
131 | M.set(2,2,tmp);
|
---|
132 | _T = M;
|
---|
133 | CurrentValueMap.erase(name);
|
---|
134 | } else
|
---|
135 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
136 | << ValueStoragePairTypeName(std::make_pair(
|
---|
137 | typeid(_T).name(),
|
---|
138 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
139 | );
|
---|
140 | }
|
---|
141 |
|
---|
142 | void ValueStorage::queryCurrentValue(const char * name, class Vector &_T) {
|
---|
143 | if (typeid( Vector ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
144 | std::istringstream stream(CurrentValueMap[name]);
|
---|
145 | CurrentValueMap.erase(name);
|
---|
146 | for (size_t i = 0; i < NDIM; ++i) {
|
---|
147 | stream >> _T[i];
|
---|
148 | ASSERT(!stream.fail(),
|
---|
149 | "ValueStorage::queryCurrentValue() - Vector in value map has only "+toString(i)+" components!");
|
---|
150 | }
|
---|
151 | } else
|
---|
152 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
153 | << ValueStoragePairTypeName(std::make_pair(
|
---|
154 | typeid(_T).name(),
|
---|
155 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
156 | );
|
---|
157 | }
|
---|
158 |
|
---|
159 | void ValueStorage::queryCurrentValue(const char * name, class BoxVector &_T) {
|
---|
160 | if (typeid( BoxVector ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
161 | std::istringstream stream(CurrentValueMap[name]);
|
---|
162 | CurrentValueMap.erase(name);
|
---|
163 | for (size_t i = 0; i < NDIM; ++i) {
|
---|
164 | stream >> _T[i];
|
---|
165 | ASSERT(!stream.fail(),
|
---|
166 | "ValueStorage::queryCurrentValue() - BoxVector in value map has only "+toString(i)+" components!");
|
---|
167 | }
|
---|
168 | } else
|
---|
169 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
170 | << ValueStoragePairTypeName(std::make_pair(
|
---|
171 | typeid(_T).name(),
|
---|
172 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
173 | );
|
---|
174 | }
|
---|
175 |
|
---|
176 | void ValueStorage::queryCurrentValue(const char * name, class RandomNumberDistribution_Parameters &_T) {
|
---|
177 | if (typeid( RandomNumberDistribution_Parameters ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
178 | std::istringstream stream(CurrentValueMap[name]);
|
---|
179 | DoLog(0) && (Log() << Verbose(0) << "ValueStorage::queryCurrentValue() for "+toString(name)+" is "+CurrentValueMap[name]+"." << std::endl);
|
---|
180 | CurrentValueMap.erase(name);
|
---|
181 | stream >> _T;
|
---|
182 | ASSERT(!stream.fail(),
|
---|
183 | "ValueStorage::queryCurrentValue() - RandomNumberDistribution_Parameters in value map has only no components!");
|
---|
184 | } else
|
---|
185 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
186 | << ValueStoragePairTypeName(std::make_pair(
|
---|
187 | typeid(_T).name(),
|
---|
188 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
189 | );
|
---|
190 | }
|
---|
191 |
|
---|
192 | void ValueStorage::queryCurrentValue(const char * name, std::vector<const atom *>&_T)
|
---|
193 | {
|
---|
194 | int atomID = -1;
|
---|
195 | size_t count = 0;
|
---|
196 | atom *Walker = NULL;
|
---|
197 | if (typeid( std::vector<const atom *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
198 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
199 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
200 | std::istringstream stream(CurrentValueMap[name]);
|
---|
201 | CurrentValueMap.erase(name);
|
---|
202 | while (!stream.fail()) {
|
---|
203 | stream >> atomID >> ws;
|
---|
204 | ASSERT((!stream.fail()) || (count != 0),
|
---|
205 | "ValueStorage::queryCurrentValue() - Atom is missing id!");
|
---|
206 | if (!stream.fail()) {
|
---|
207 | Walker = World::getInstance().getAtom(AtomById(atomID));
|
---|
208 | if (Walker != NULL)
|
---|
209 | _T.push_back(Walker);
|
---|
210 | atomID = -1;
|
---|
211 | Walker = NULL;
|
---|
212 | ++count;
|
---|
213 | }
|
---|
214 | }
|
---|
215 | } else
|
---|
216 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
217 | << ValueStoragePairTypeName(std::make_pair(
|
---|
218 | typeid(_T).name(),
|
---|
219 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
220 | );
|
---|
221 | }
|
---|
222 |
|
---|
223 | void ValueStorage::queryCurrentValue(const char * name, std::vector<const element *>&_T)
|
---|
224 | {
|
---|
225 | int Z = -1;
|
---|
226 | size_t count = 0;
|
---|
227 | const element *elemental = NULL;
|
---|
228 | if (typeid( std::vector<const element *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
229 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
230 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
231 | std::istringstream stream(CurrentValueMap[name]);
|
---|
232 | CurrentValueMap.erase(name);
|
---|
233 | while (!stream.fail()) {
|
---|
234 | stream >> Z >> ws;
|
---|
235 | ASSERT((!stream.fail()) || (count != 0),
|
---|
236 | "ValueStorage::queryCurrentValue() - atomic number is missing!");
|
---|
237 | if (!stream.fail()) {
|
---|
238 | elemental = World::getInstance().getPeriode()->FindElement(Z);
|
---|
239 | if (elemental != NULL)
|
---|
240 | _T.push_back(elemental);
|
---|
241 | Z = -1;
|
---|
242 | ++count;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | } else
|
---|
246 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
247 | << ValueStoragePairTypeName(std::make_pair(
|
---|
248 | typeid(_T).name(),
|
---|
249 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
250 | );
|
---|
251 | }
|
---|
252 |
|
---|
253 | void ValueStorage::queryCurrentValue(const char * name, std::vector<const molecule *>&_T)
|
---|
254 | {
|
---|
255 | int molID = -1;
|
---|
256 | size_t count = 0;
|
---|
257 | molecule *mol = NULL;
|
---|
258 | if (typeid( std::vector<const molecule *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
259 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
260 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
261 | std::istringstream stream(CurrentValueMap[name]);
|
---|
262 | CurrentValueMap.erase(name);
|
---|
263 | while (!stream.fail()) {
|
---|
264 | stream >> molID >> ws;
|
---|
265 | ASSERT((!stream.fail()) || (count != 0),
|
---|
266 | "ValueStorage::queryCurrentValue() - molecule is missing id!");
|
---|
267 | if (!stream.fail()) {
|
---|
268 | mol = World::getInstance().getMolecule(MoleculeById(molID));
|
---|
269 | if (mol != NULL)
|
---|
270 | _T.push_back(mol);
|
---|
271 | molID = -1;
|
---|
272 | mol = NULL;
|
---|
273 | ++count;
|
---|
274 | }
|
---|
275 | }
|
---|
276 | } else
|
---|
277 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
278 | << ValueStoragePairTypeName(std::make_pair(
|
---|
279 | typeid(_T).name(),
|
---|
280 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
281 | );
|
---|
282 | }
|
---|
283 |
|
---|
284 | void ValueStorage::queryCurrentValue(const char * name, boost::filesystem::path&_T)
|
---|
285 | {
|
---|
286 | std::string tmp;
|
---|
287 | if (typeid( boost::filesystem::path ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
288 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
289 | throw MissingValueException() << ValueStorageOptionName(name);
|
---|
290 | std::istringstream stream(CurrentValueMap[name]);
|
---|
291 | CurrentValueMap.erase(name);
|
---|
292 | stream >> tmp >> ws;
|
---|
293 | ASSERT(!stream.fail(),
|
---|
294 | "ValueStorage::queryCurrentValue() - boost::filesystem::path is missing!");
|
---|
295 | _T = tmp;
|
---|
296 | } else
|
---|
297 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
298 | << ValueStoragePairTypeName(std::make_pair(
|
---|
299 | typeid(_T).name(),
|
---|
300 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
301 | );
|
---|
302 | }
|
---|
303 |
|
---|
304 | void ValueStorage::setCurrentValue(const char * name, const atom * &_T)
|
---|
305 | {
|
---|
306 | if (typeid( const atom *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
307 | std::ostringstream stream;
|
---|
308 | stream << _T->getId();
|
---|
309 | CurrentValueMap[name] = stream.str();
|
---|
310 | } else
|
---|
311 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
312 | << ValueStoragePairTypeName(std::make_pair(
|
---|
313 | typeid(_T).name(),
|
---|
314 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
315 | );
|
---|
316 | }
|
---|
317 |
|
---|
318 | void ValueStorage::setCurrentValue(const char * name, const element * &_T)
|
---|
319 | {
|
---|
320 | if (typeid( const element *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
321 | std::ostringstream stream;
|
---|
322 | stream << _T->getAtomicNumber();
|
---|
323 | CurrentValueMap[name] = stream.str();
|
---|
324 | } else
|
---|
325 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
326 | << ValueStoragePairTypeName(std::make_pair(
|
---|
327 | typeid(_T).name(),
|
---|
328 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
329 | );
|
---|
330 | }
|
---|
331 |
|
---|
332 | void ValueStorage::setCurrentValue(const char * name, const molecule * &_T)
|
---|
333 | {
|
---|
334 | if (typeid( const molecule *) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
335 | std::ostringstream stream;
|
---|
336 | stream << _T->getId();
|
---|
337 | CurrentValueMap[name] = stream.str();
|
---|
338 | } else
|
---|
339 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
340 | << ValueStoragePairTypeName(std::make_pair(
|
---|
341 | typeid(_T).name(),
|
---|
342 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
343 | );
|
---|
344 | }
|
---|
345 |
|
---|
346 | void ValueStorage::setCurrentValue(const char * name, class Box &_T)
|
---|
347 | {
|
---|
348 | const RealSpaceMatrix &M = _T.getM();
|
---|
349 | if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
350 | std::ostringstream stream;
|
---|
351 | stream << M.at(0,0) << " ";
|
---|
352 | stream << M.at(0,1) << " ";
|
---|
353 | stream << M.at(0,2) << " ";
|
---|
354 | stream << M.at(1,1) << " ";
|
---|
355 | stream << M.at(1,2) << " ";
|
---|
356 | stream << M.at(2,2) << " ";
|
---|
357 | CurrentValueMap[name] = stream.str();
|
---|
358 | } else
|
---|
359 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
360 | << ValueStoragePairTypeName(std::make_pair(
|
---|
361 | typeid(_T).name(),
|
---|
362 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
363 | );
|
---|
364 | }
|
---|
365 |
|
---|
366 | void ValueStorage::setCurrentValue(const char * name, class Vector &_T)
|
---|
367 | {
|
---|
368 | if (typeid( Vector ) == *(OptionRegistry_instance.getOptionByName(name)->getType())){
|
---|
369 | std::ostringstream stream;
|
---|
370 | stream << _T[0] << " ";
|
---|
371 | stream << _T[1] << " ";
|
---|
372 | stream << _T[2] << " ";
|
---|
373 | CurrentValueMap[name] = stream.str();
|
---|
374 | } else if (typeid( BoxVector ) == *(OptionRegistry_instance.getOptionByName(name)->getType())){
|
---|
375 | std::ostringstream stream;
|
---|
376 | stream << _T[0] << " ";
|
---|
377 | stream << _T[1] << " ";
|
---|
378 | stream << _T[2] << " ";
|
---|
379 | CurrentValueMap[name] = stream.str();
|
---|
380 | } else
|
---|
381 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
382 | << ValueStoragePairTypeName(std::make_pair(
|
---|
383 | typeid(_T).name(),
|
---|
384 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
385 | );
|
---|
386 | }
|
---|
387 |
|
---|
388 | void ValueStorage::setCurrentValue(const char * name, class RandomNumberDistribution_Parameters &_T)
|
---|
389 | {
|
---|
390 | if (typeid( RandomNumberDistribution_Parameters ) == *(OptionRegistry_instance.getOptionByName(name)->getType())){
|
---|
391 | std::ostringstream stream;
|
---|
392 | stream << _T;
|
---|
393 | CurrentValueMap[name] = stream.str();
|
---|
394 | DoLog(0) && (Log() << Verbose(0) << "ValueStorage::setCurrentValue() for "+toString(name)+" to "+stream.str()+"." << std::endl);
|
---|
395 | } else
|
---|
396 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
397 | << ValueStoragePairTypeName(std::make_pair(
|
---|
398 | typeid(_T).name(),
|
---|
399 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
400 | );
|
---|
401 | }
|
---|
402 |
|
---|
403 | void ValueStorage::setCurrentValue(const char * name, std::vector<const atom *>&_T)
|
---|
404 | {
|
---|
405 | if (typeid( std::vector<const atom *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
406 | std::ostringstream stream;
|
---|
407 | for (std::vector<const atom *>::const_iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
408 | stream << (*iter)->getId() << " ";
|
---|
409 | }
|
---|
410 | CurrentValueMap[name] = stream.str();
|
---|
411 | } else
|
---|
412 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
413 | << ValueStoragePairTypeName(std::make_pair(
|
---|
414 | typeid(_T).name(),
|
---|
415 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
416 | );
|
---|
417 | }
|
---|
418 |
|
---|
419 | void ValueStorage::setCurrentValue(const char * name, std::vector<const element *>&_T)
|
---|
420 | {
|
---|
421 | if (typeid( std::vector<const element *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
422 | std::ostringstream stream;
|
---|
423 | for (std::vector<const element *>::const_iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
424 | stream << (*iter)->getAtomicNumber() << " ";
|
---|
425 | }
|
---|
426 | CurrentValueMap[name] = stream.str();
|
---|
427 | } else
|
---|
428 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
429 | << ValueStoragePairTypeName(std::make_pair(
|
---|
430 | typeid(_T).name(),
|
---|
431 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
432 | );
|
---|
433 | }
|
---|
434 |
|
---|
435 | void ValueStorage::setCurrentValue(const char * name, std::vector<const molecule *>&_T)
|
---|
436 | {
|
---|
437 | if (typeid( std::vector<const molecule *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
438 | std::ostringstream stream;
|
---|
439 | for (std::vector<const molecule *>::const_iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
440 | stream << (*iter)->getId() << " ";
|
---|
441 | }
|
---|
442 | CurrentValueMap[name] = stream.str();
|
---|
443 | } else
|
---|
444 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
445 | << ValueStoragePairTypeName(std::make_pair(
|
---|
446 | typeid(_T).name(),
|
---|
447 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
448 | );
|
---|
449 | }
|
---|
450 |
|
---|
451 | void ValueStorage::setCurrentValue(const char * name, boost::filesystem::path &_T)
|
---|
452 | {
|
---|
453 | if (typeid( boost::filesystem::path ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
|
---|
454 | std::ostringstream stream;
|
---|
455 | stream << _T.string();
|
---|
456 | CurrentValueMap[name] = stream.str();
|
---|
457 | } else
|
---|
458 | throw IllegalTypeException() << ValueStorageOptionName(name)
|
---|
459 | << ValueStoragePairTypeName(std::make_pair(
|
---|
460 | typeid(_T).name(),
|
---|
461 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str())
|
---|
462 | );
|
---|
463 | }
|
---|
464 |
|
---|
465 | const std::string ValueStorage::getCurrentValue(std::string actionname) {
|
---|
466 | return CurrentValueMap[actionname];
|
---|
467 | }
|
---|
468 |
|
---|
469 | CONSTRUCT_SINGLETON(ValueStorage)
|
---|