votca 2024-dev
Loading...
Searching...
No Matches
identity.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19#ifndef VOTCA_TOOLS_IDENTITY_H
20#define VOTCA_TOOLS_IDENTITY_H
21
22// Standard includes
23#include <cassert>
24
25namespace votca {
26namespace tools {
27
35template <typename T>
36class Identity {
37 private:
38 T id_;
39 bool id_set_;
40
41 public:
43 Identity() : id_set_(false) {}
45 Identity(const T &id) : id_(id), id_set_(true){};
47 const T &getId() const {
48 assert(id_set_ && "No id has been set, cannot get id");
49 return id_;
50 }
52 void setId(const T &id) {
53 id_set_ = true;
54 id_ = id;
55 }
56};
57} // namespace tools
58} // namespace votca
59
60#endif // VOTCA_TOOLS_IDENTITY_H
Information about Identity.
Definition identity.h:36
Identity()
Constructor.
Definition identity.h:43
const T & getId() const
Gets the id returns error of the id has not been set.
Definition identity.h:47
Identity(const T &id)
Constructor that takes initial id.
Definition identity.h:45
void setId(const T &id)
Set the id.
Definition identity.h:52
base class for all analysis tools
Definition basebead.h:33