votca 2024-dev
Loading...
Searching...
No Matches
structureparameters.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_TOOLS_STRUCTUREPARAMETERS_H
19#define VOTCA_TOOLS_STRUCTUREPARAMETERS_H
20
21// Standard includes
22#include <cassert>
23#include <unordered_map>
24
25// Third party includes
26#include <boost/any.hpp>
27
28namespace votca {
29namespace tools {
30
46};
47
103
104 public:
105 void set(const StructureParameter parameter, boost::any value) noexcept;
106
107 template <class T>
108 T get(const StructureParameter parameter) const;
109
110 private:
111 std::unordered_map<StructureParameter, boost::any, std::hash<int>> parameters;
112};
113
115 boost::any value) noexcept {
116 parameters[parameter] = value;
117}
118
119template <class T>
121 assert(parameters.count(parameter) &&
122 "StructureParameter is not stored in StructureParameters class");
123 assert(typeid(T) == parameters.at(parameter).type() &&
124 "Cannot return boost any value from parameters class because it is "
125 "not being cast to the correct type");
126 return boost::any_cast<T>(parameters.at(parameter));
127}
128
129} // namespace tools
130} // namespace votca
131#endif // VOTCA_TOOLS_STRUCTUREPARAMETERS_H
Provides a means to standardise the constructors of different classes.
void set(const StructureParameter parameter, boost::any value) noexcept
T get(const StructureParameter parameter) const
std::unordered_map< StructureParameter, boost::any, std::hash< int > > parameters
StructureParameter
Supported and Standardized parameter types.
base class for all analysis tools
Definition basebead.h:33