[e4afb4] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 5 | *
|
---|
| 6 | *
|
---|
| 7 | * This file is part of MoleCuilder.
|
---|
| 8 | *
|
---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
| 10 | * it under the terms of the GNU General Public License as published by
|
---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
---|
| 12 | * (at your option) any later version.
|
---|
| 13 | *
|
---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | * GNU General Public License for more details.
|
---|
| 18 | *
|
---|
| 19 | * You should have received a copy of the GNU General Public License
|
---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
[e4afb4] | 21 | */
|
---|
| 22 |
|
---|
| 23 | /*
|
---|
| 24 | * TypeEnumContainer.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: Oct 27, 2010
|
---|
| 27 | * Author: heber
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | // include config.h
|
---|
| 31 | #ifdef HAVE_CONFIG_H
|
---|
| 32 | #include <config.h>
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[9eb71b3] | 35 | //#include "CodePatterns/MemDebug.hpp"
|
---|
[e4afb4] | 36 |
|
---|
| 37 | #include <boost/filesystem.hpp>
|
---|
| 38 | #include <iosfwd>
|
---|
| 39 | #include <typeinfo>
|
---|
| 40 | #include <vector>
|
---|
| 41 |
|
---|
| 42 | #include "Actions/Values.hpp"
|
---|
[ad011c] | 43 | #include "CodePatterns/Assert.hpp"
|
---|
[e4afb4] | 44 |
|
---|
| 45 | #include "UIElements/CommandLineUI/TypeEnumContainer.hpp"
|
---|
| 46 |
|
---|
[6f0841] | 47 | #include "Atom/atom.hpp"
|
---|
[e4afb4] | 48 | #include "LinearAlgebra/BoxVector.hpp"
|
---|
[7d9416] | 49 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[e4afb4] | 50 | #include "LinearAlgebra/Vector.hpp"
|
---|
[3bdb6d] | 51 | #include "Element/element.hpp"
|
---|
[e4afb4] | 52 | #include "molecule.hpp"
|
---|
[33e801] | 53 | #include "Parameters/Specifics/KeyValuePair.hpp"
|
---|
[0275ad] | 54 | #include "RandomNumbers/RandomNumberDistribution_Parameters.hpp"
|
---|
[e4afb4] | 55 |
|
---|
| 56 | /** Constructor for class TypeEnumContainer.
|
---|
| 57 | * Just fills TypeEnumContainer::TypeEnumMap by hand.
|
---|
| 58 | */
|
---|
| 59 | TypeEnumContainer::TypeEnumContainer()
|
---|
| 60 | {
|
---|
| 61 | TypeEnumMap[&typeid(void)] = NoneType;
|
---|
| 62 | TypeEnumMap[&typeid(bool)] = BooleanType;
|
---|
[7d9416] | 63 | TypeEnumMap[&typeid(RealSpaceMatrix)] = RealSpaceMatrixType;
|
---|
[e4afb4] | 64 | TypeEnumMap[&typeid(BoxVector)] = VectorType;
|
---|
| 65 | TypeEnumMap[&typeid(Vector)] = VectorType;
|
---|
| 66 | TypeEnumMap[&typeid(boost::filesystem::path)] = FileType;
|
---|
| 67 | TypeEnumMap[&typeid(std::vector<boost::filesystem::path>)] = ListOfFilesType;
|
---|
| 68 | TypeEnumMap[&typeid(int)] = IntegerType;
|
---|
| 69 | TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegersType;
|
---|
[838cd0] | 70 | TypeEnumMap[&typeid(unsigned int)] = UnsignedIntegerType;
|
---|
[12948c] | 71 | TypeEnumMap[&typeid(std::vector<unsigned int>)] = ListOfUnsignedIntegersType;
|
---|
[e4afb4] | 72 | TypeEnumMap[&typeid(double)] = DoubleType;
|
---|
| 73 | TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoublesType;
|
---|
| 74 | TypeEnumMap[&typeid(std::string)] = StringType;
|
---|
| 75 | TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStringsType;
|
---|
| 76 | TypeEnumMap[&typeid(VectorValue)] = VectorType;
|
---|
| 77 | TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectorsType;
|
---|
| 78 | TypeEnumMap[&typeid(const atom *)] = AtomType;
|
---|
| 79 | TypeEnumMap[&typeid(std::vector<const atom *>)] = ListOfAtomsType;
|
---|
| 80 | TypeEnumMap[&typeid(const molecule *)] = MoleculeType;
|
---|
| 81 | TypeEnumMap[&typeid(std::vector<const molecule *>)] = ListOfMoleculesType;
|
---|
| 82 | TypeEnumMap[&typeid(const element *)] = ElementType;
|
---|
| 83 | TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElementsType;
|
---|
[33e801] | 84 | TypeEnumMap[&typeid(KeyValuePair)] = KeyValueType;
|
---|
| 85 | TypeEnumMap[&typeid(std::vector<KeyValuePair>)] = ListOfKeyValuesType;
|
---|
[e4afb4] | 86 |
|
---|
[ad7270] | 87 | // for debugging: list all stored types
|
---|
| 88 | //ListAllKnownTypes();
|
---|
[e4afb4] | 89 | };
|
---|
| 90 |
|
---|
| 91 | /** Destructor for class TypeEnumContainer.
|
---|
| 92 | * Clears TypeEnumContainer::TypeEnumMap.
|
---|
| 93 | */
|
---|
| 94 | TypeEnumContainer::~TypeEnumContainer()
|
---|
| 95 | {
|
---|
| 96 | TypeEnumMap.clear();
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /** Destructor for class TypeEnumContainer.
|
---|
| 100 | * Clears TypeEnumContainer::TypeEnumMap.
|
---|
| 101 | */
|
---|
| 102 | void TypeEnumContainer::ListAllKnownTypes() const
|
---|
| 103 | {
|
---|
| 104 | for (type_map::const_iterator iter = TypeEnumMap.begin(); iter != TypeEnumMap.end(); ++iter) {
|
---|
| 105 | std::cout << " Known type is " << (iter->first)->name() << " or enum " << iter->second << std::endl;
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /** Getter for TypeEnumContainer::TypeEnumMap.
|
---|
| 110 | * Note: \a *_type must be present, is checked by ASSERT().
|
---|
| 111 | * \param *_type type requested
|
---|
| 112 | */
|
---|
| 113 | enum TypeEnumContainer::EnumOfTypes TypeEnumContainer::getEnumforType(const std::type_info *_type)
|
---|
| 114 | {
|
---|
[ad7270] | 115 | //std::cout << "Looking for type " << _type->name() << std::endl;
|
---|
[e4afb4] | 116 | ASSERT(TypeEnumMap.find(_type) != TypeEnumMap.end(),
|
---|
| 117 | "CommandLineParser::getEnumforType() - cannot find the type as enum!.");
|
---|
| 118 | return (TypeEnumMap[_type]);
|
---|
| 119 | }
|
---|
| 120 |
|
---|