| [bcf653] | 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 |  | 
|---|
| [75dc28] | 8 | /* | 
|---|
|  | 9 | * ValueStorage.cpp | 
|---|
|  | 10 | * | 
|---|
|  | 11 | *  Created on: Jul 22, 2010 | 
|---|
|  | 12 | *      Author: heber | 
|---|
|  | 13 | */ | 
|---|
|  | 14 |  | 
|---|
| [bf3817] | 15 | // include config.h | 
|---|
|  | 16 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 17 | #include <config.h> | 
|---|
|  | 18 | #endif | 
|---|
|  | 19 |  | 
|---|
| [ad011c] | 20 | #include "CodePatterns/MemDebug.hpp" | 
|---|
| [75dc28] | 21 |  | 
|---|
| [ad011c] | 22 | #include "CodePatterns/Singleton_impl.hpp" | 
|---|
| [9d33ba] | 23 |  | 
|---|
| [e4afb4] | 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" | 
|---|
| [ad011c] | 30 | #include "CodePatterns/Assert.hpp" | 
|---|
|  | 31 | #include "CodePatterns/Log.hpp" | 
|---|
|  | 32 | #include "CodePatterns/Verbose.hpp" | 
|---|
| [e4afb4] | 33 | #include "LinearAlgebra/BoxVector.hpp" | 
|---|
| [cca9ef] | 34 | #include "LinearAlgebra/RealSpaceMatrix.hpp" | 
|---|
| [e4afb4] | 35 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| [0275ad] | 36 | #include "RandomNumbers/RandomNumberDistribution_Parameters.hpp" | 
|---|
| [e4afb4] | 37 | #include "atom.hpp" | 
|---|
|  | 38 | #include "Box.hpp" | 
|---|
| [3bdb6d] | 39 | #include "Element/element.hpp" | 
|---|
| [e4afb4] | 40 | #include "molecule.hpp" | 
|---|
| [3bdb6d] | 41 | #include "Element/periodentafel.hpp" | 
|---|
| [e4afb4] | 42 | #include "World.hpp" | 
|---|
|  | 43 |  | 
|---|
| [03c902] | 44 | ValueStorage::ValueStorage() : | 
|---|
| [ce7fdc] | 45 | OptionRegistry_instance(MoleCuilder::OptionRegistry::getInstance()) | 
|---|
| [03c902] | 46 | {}; | 
|---|
| [75dc28] | 47 |  | 
|---|
|  | 48 | ValueStorage::~ValueStorage() {}; | 
|---|
|  | 49 |  | 
|---|
| [e4afb4] | 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()) | 
|---|
| [336e33] | 61 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 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()) | 
|---|
| [336e33] | 66 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 67 | atomID = lexical_cast<int>(CurrentValueMap[name].c_str()); | 
|---|
|  | 68 | CurrentValueMap.erase(name); | 
|---|
|  | 69 | } else | 
|---|
| [882678] | 70 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 71 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 72 | typeid(_T).name(), | 
|---|
|  | 73 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 74 | ); | 
|---|
| [e4afb4] | 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()) | 
|---|
| [336e33] | 82 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 83 | Z = lexical_cast<int>(CurrentValueMap[name].c_str()); | 
|---|
|  | 84 | CurrentValueMap.erase(name); | 
|---|
|  | 85 | } else | 
|---|
| [882678] | 86 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 87 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 88 | typeid(_T).name(), | 
|---|
|  | 89 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 90 | ); | 
|---|
| [e4afb4] | 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()) | 
|---|
| [336e33] | 98 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 99 | molID = lexical_cast<int>(CurrentValueMap[name].c_str()); | 
|---|
|  | 100 | CurrentValueMap.erase(name); | 
|---|
|  | 101 | } else | 
|---|
| [882678] | 102 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 103 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 104 | typeid(_T).name(), | 
|---|
|  | 105 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 106 | ); | 
|---|
| [e4afb4] | 107 | _T = World::getInstance().getMolecule(MoleculeById(molID)); | 
|---|
|  | 108 | } | 
|---|
|  | 109 |  | 
|---|
|  | 110 | void ValueStorage::queryCurrentValue(const char * name, class Box &_T) { | 
|---|
| [cca9ef] | 111 | RealSpaceMatrix M; | 
|---|
| [e4afb4] | 112 | double tmp; | 
|---|
|  | 113 | if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) { | 
|---|
|  | 114 | if (CurrentValueMap.find(name) == CurrentValueMap.end()) | 
|---|
| [336e33] | 115 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 135 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 136 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 137 | typeid(_T).name(), | 
|---|
|  | 138 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 139 | ); | 
|---|
| [e4afb4] | 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); | 
|---|
| [78bb14] | 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 | } | 
|---|
| [e4afb4] | 151 | } else | 
|---|
| [882678] | 152 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 153 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 154 | typeid(_T).name(), | 
|---|
|  | 155 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 156 | ); | 
|---|
| [e4afb4] | 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); | 
|---|
| [78bb14] | 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 | } | 
|---|
| [e4afb4] | 168 | } else | 
|---|
| [882678] | 169 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 170 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 171 | typeid(_T).name(), | 
|---|
|  | 172 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 173 | ); | 
|---|
| [e4afb4] | 174 | } | 
|---|
|  | 175 |  | 
|---|
| [0275ad] | 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 | 
|---|
| [882678] | 185 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 186 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 187 | typeid(_T).name(), | 
|---|
|  | 188 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 189 | ); | 
|---|
| [0275ad] | 190 | } | 
|---|
|  | 191 |  | 
|---|
| [e4afb4] | 192 | void ValueStorage::queryCurrentValue(const char * name, std::vector<const atom *>&_T) | 
|---|
|  | 193 | { | 
|---|
|  | 194 | int atomID = -1; | 
|---|
| [78bb14] | 195 | size_t count = 0; | 
|---|
| [e4afb4] | 196 | atom *Walker = NULL; | 
|---|
|  | 197 | if (typeid( std::vector<const atom *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) { | 
|---|
|  | 198 | if (CurrentValueMap.find(name) == CurrentValueMap.end()) | 
|---|
| [336e33] | 199 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 200 | std::istringstream stream(CurrentValueMap[name]); | 
|---|
|  | 201 | CurrentValueMap.erase(name); | 
|---|
|  | 202 | while (!stream.fail()) { | 
|---|
|  | 203 | stream >> atomID >> ws; | 
|---|
| [78bb14] | 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 | } | 
|---|
| [e4afb4] | 214 | } | 
|---|
|  | 215 | } else | 
|---|
| [882678] | 216 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 217 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 218 | typeid(_T).name(), | 
|---|
|  | 219 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 220 | ); | 
|---|
| [e4afb4] | 221 | } | 
|---|
|  | 222 |  | 
|---|
|  | 223 | void ValueStorage::queryCurrentValue(const char * name, std::vector<const element *>&_T) | 
|---|
|  | 224 | { | 
|---|
|  | 225 | int Z = -1; | 
|---|
| [78bb14] | 226 | size_t count = 0; | 
|---|
| [e4afb4] | 227 | const element *elemental = NULL; | 
|---|
|  | 228 | if (typeid( std::vector<const element *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) { | 
|---|
|  | 229 | if (CurrentValueMap.find(name) == CurrentValueMap.end()) | 
|---|
| [336e33] | 230 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 231 | std::istringstream stream(CurrentValueMap[name]); | 
|---|
|  | 232 | CurrentValueMap.erase(name); | 
|---|
|  | 233 | while (!stream.fail()) { | 
|---|
|  | 234 | stream >> Z >> ws; | 
|---|
| [78bb14] | 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 | } | 
|---|
| [e4afb4] | 244 | } | 
|---|
|  | 245 | } else | 
|---|
| [882678] | 246 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 247 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 248 | typeid(_T).name(), | 
|---|
|  | 249 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 250 | ); | 
|---|
| [4885f85] | 251 | } | 
|---|
|  | 252 |  | 
|---|
| [e4afb4] | 253 | void ValueStorage::queryCurrentValue(const char * name, std::vector<const molecule *>&_T) | 
|---|
|  | 254 | { | 
|---|
|  | 255 | int molID = -1; | 
|---|
| [78bb14] | 256 | size_t count = 0; | 
|---|
| [e4afb4] | 257 | molecule *mol = NULL; | 
|---|
|  | 258 | if (typeid( std::vector<const molecule *> ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) { | 
|---|
|  | 259 | if (CurrentValueMap.find(name) == CurrentValueMap.end()) | 
|---|
| [336e33] | 260 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 261 | std::istringstream stream(CurrentValueMap[name]); | 
|---|
|  | 262 | CurrentValueMap.erase(name); | 
|---|
|  | 263 | while (!stream.fail()) { | 
|---|
|  | 264 | stream >> molID >> ws; | 
|---|
| [78bb14] | 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 | } | 
|---|
| [e4afb4] | 275 | } | 
|---|
|  | 276 | } else | 
|---|
| [882678] | 277 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 278 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 279 | typeid(_T).name(), | 
|---|
|  | 280 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 281 | ); | 
|---|
| [9d33ba] | 282 | } | 
|---|
|  | 283 |  | 
|---|
| [e4afb4] | 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()) | 
|---|
| [336e33] | 289 | throw MissingValueException() << ValueStorageOptionName(name); | 
|---|
| [e4afb4] | 290 | std::istringstream stream(CurrentValueMap[name]); | 
|---|
|  | 291 | CurrentValueMap.erase(name); | 
|---|
| [78bb14] | 292 | stream >> tmp >> ws; | 
|---|
|  | 293 | ASSERT(!stream.fail(), | 
|---|
|  | 294 | "ValueStorage::queryCurrentValue() - boost::filesystem::path is missing!"); | 
|---|
|  | 295 | _T = tmp; | 
|---|
| [e4afb4] | 296 | } else | 
|---|
| [882678] | 297 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 298 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 299 | typeid(_T).name(), | 
|---|
|  | 300 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 301 | ); | 
|---|
| [4885f85] | 302 | } | 
|---|
|  | 303 |  | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 311 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 312 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 313 | typeid(_T).name(), | 
|---|
|  | 314 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 315 | ); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 325 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 326 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 327 | typeid(_T).name(), | 
|---|
|  | 328 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 329 | ); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 339 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 340 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 341 | typeid(_T).name(), | 
|---|
|  | 342 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 343 | ); | 
|---|
| [e4afb4] | 344 | } | 
|---|
|  | 345 |  | 
|---|
|  | 346 | void ValueStorage::setCurrentValue(const char * name, class Box &_T) | 
|---|
|  | 347 | { | 
|---|
| [cca9ef] | 348 | const RealSpaceMatrix &M = _T.getM(); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 359 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 360 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 361 | typeid(_T).name(), | 
|---|
|  | 362 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 363 | ); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 381 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 382 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 383 | typeid(_T).name(), | 
|---|
|  | 384 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 385 | ); | 
|---|
| [e4afb4] | 386 | } | 
|---|
|  | 387 |  | 
|---|
| [0275ad] | 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 | 
|---|
| [882678] | 396 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 397 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 398 | typeid(_T).name(), | 
|---|
|  | 399 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 400 | ); | 
|---|
| [0275ad] | 401 | } | 
|---|
|  | 402 |  | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 412 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 413 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 414 | typeid(_T).name(), | 
|---|
|  | 415 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 416 | ); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 428 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 429 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 430 | typeid(_T).name(), | 
|---|
|  | 431 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 432 | ); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 444 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 445 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 446 | typeid(_T).name(), | 
|---|
|  | 447 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 448 | ); | 
|---|
| [e4afb4] | 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 | 
|---|
| [882678] | 458 | throw IllegalTypeException() << ValueStorageOptionName(name) | 
|---|
|  | 459 | << ValueStoragePairTypeName(std::make_pair( | 
|---|
|  | 460 | typeid(_T).name(), | 
|---|
|  | 461 | OptionRegistry_instance.getOptionByName(name)->getTypeName().c_str()) | 
|---|
|  | 462 | ); | 
|---|
| [e4afb4] | 463 | } | 
|---|
|  | 464 |  | 
|---|
|  | 465 | const std::string ValueStorage::getCurrentValue(std::string actionname) { | 
|---|
|  | 466 | return CurrentValueMap[actionname]; | 
|---|
| [4885f85] | 467 | } | 
|---|
|  | 468 |  | 
|---|
| [75dc28] | 469 | CONSTRUCT_SINGLETON(ValueStorage) | 
|---|