/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * TypeEnumContainer.cpp * * Created on: Oct 27, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif //#include "CodePatterns/MemDebug.hpp" #include #include #include #include #include "Actions/Values.hpp" #include "CodePatterns/Assert.hpp" #include "UIElements/CommandLineUI/TypeEnumContainer.hpp" #include "Atom/atom.hpp" #include "LinearAlgebra/BoxVector.hpp" #include "LinearAlgebra/RealSpaceMatrix.hpp" #include "LinearAlgebra/Vector.hpp" #include "Element/element.hpp" #include "molecule.hpp" #include "Parameters/Specifics/KeyValuePair.hpp" #include "RandomNumbers/RandomNumberDistribution_Parameters.hpp" /** Constructor for class TypeEnumContainer. * Just fills TypeEnumContainer::TypeEnumMap by hand. */ TypeEnumContainer::TypeEnumContainer() { TypeEnumMap[&typeid(void)] = NoneType; TypeEnumMap[&typeid(bool)] = BooleanType; TypeEnumMap[&typeid(RealSpaceMatrix)] = RealSpaceMatrixType; TypeEnumMap[&typeid(BoxVector)] = VectorType; TypeEnumMap[&typeid(Vector)] = VectorType; TypeEnumMap[&typeid(boost::filesystem::path)] = FileType; TypeEnumMap[&typeid(std::vector)] = ListOfFilesType; TypeEnumMap[&typeid(int)] = IntegerType; TypeEnumMap[&typeid(std::vector)] = ListOfIntegersType; TypeEnumMap[&typeid(unsigned int)] = UnsignedIntegerType; TypeEnumMap[&typeid(std::vector)] = ListOfUnsignedIntegersType; TypeEnumMap[&typeid(double)] = DoubleType; TypeEnumMap[&typeid(std::vector)] = ListOfDoublesType; TypeEnumMap[&typeid(std::string)] = StringType; TypeEnumMap[&typeid(std::vector)] = ListOfStringsType; TypeEnumMap[&typeid(VectorValue)] = VectorType; TypeEnumMap[&typeid(std::vector)] = ListOfVectorsType; TypeEnumMap[&typeid(const atom *)] = AtomType; TypeEnumMap[&typeid(std::vector)] = ListOfAtomsType; TypeEnumMap[&typeid(const molecule *)] = MoleculeType; TypeEnumMap[&typeid(std::vector)] = ListOfMoleculesType; TypeEnumMap[&typeid(const element *)] = ElementType; TypeEnumMap[&typeid(std::vector)] = ListOfElementsType; TypeEnumMap[&typeid(KeyValuePair)] = KeyValueType; TypeEnumMap[&typeid(std::vector)] = ListOfKeyValuesType; // for debugging: list all stored types //ListAllKnownTypes(); }; /** Destructor for class TypeEnumContainer. * Clears TypeEnumContainer::TypeEnumMap. */ TypeEnumContainer::~TypeEnumContainer() { TypeEnumMap.clear(); } /** Destructor for class TypeEnumContainer. * Clears TypeEnumContainer::TypeEnumMap. */ void TypeEnumContainer::ListAllKnownTypes() const { for (type_map::const_iterator iter = TypeEnumMap.begin(); iter != TypeEnumMap.end(); ++iter) { std::cout << " Known type is " << (iter->first)->name() << " or enum " << iter->second << std::endl; } } /** Getter for TypeEnumContainer::TypeEnumMap. * Note: \a *_type must be present, is checked by ASSERT(). * \param *_type type requested */ enum TypeEnumContainer::EnumOfTypes TypeEnumContainer::getEnumforType(const std::type_info *_type) { //std::cout << "Looking for type " << _type->name() << std::endl; ASSERT(TypeEnumMap.find(_type) != TypeEnumMap.end(), "CommandLineParser::getEnumforType() - cannot find the type as enum!."); return (TypeEnumMap[_type]); }