Chemical Data Processing Library C++ API - Version 1.1.1
LookupKey.hpp
Go to the documentation of this file.
1 /*
2  * LookupKey.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_BASE_VALUEKEY_HPP
30 #define CDPL_BASE_VALUEKEY_HPP
31 
32 #include <cstddef>
33 #include <string>
34 
35 #include "CDPL/Base/APIPrefix.hpp"
36 
37 
38 namespace CDPL
39 {
40 
41  namespace Base
42  {
43 
54  {
55 
56  public:
60  struct HashFunc
61  {
62 
68  std::size_t operator()(const LookupKey& key) const;
69  };
70 
74  static const LookupKey NONE;
75 
86  static LookupKey create(const std::string& name);
87 
92  void setName(const std::string& name) const;
93 
99  const std::string& getName() const;
100 
105  std::size_t getID() const;
106 
113  bool operator<(const LookupKey& key) const;
114 
120  bool operator==(const LookupKey& key) const;
121 
127  bool operator!=(const LookupKey& key) const;
128 
129  private:
130  LookupKey(std::size_t id):
131  numericID(id) {}
132 
133  std::size_t numericID;
134  };
135  } // namespace Base
136 } // namespace CDPL
137 
138 
139 // Implementation
140 
141 inline std::size_t CDPL::Base::LookupKey::getID() const
142 {
143  return numericID;
144 }
145 
146 inline bool CDPL::Base::LookupKey::operator<(const LookupKey& key) const
147 {
148  return (numericID < key.numericID);
149 }
150 
151 inline bool CDPL::Base::LookupKey::operator==(const LookupKey& key) const
152 {
153  return (numericID == key.numericID);
154 }
155 
156 inline bool CDPL::Base::LookupKey::operator!=(const LookupKey& key) const
157 {
158  return (numericID != key.numericID);
159 }
160 
161 
162 inline std::size_t CDPL::Base::LookupKey::HashFunc::operator()(const LookupKey& key) const
163 {
164  return key.numericID;
165 }
166 
167 #endif // CDPL_BASE_VALUEKEY_HPP
CDPL::Base::LookupKey::create
static LookupKey create(const std::string &name)
Creates a new unique LookupKey instance and registers it under the specified name.
CDPL::Math::operator!=
GridEquality< E1, E2 >::ResultType operator!=(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:346
CDPL::Math::operator==
GridEquality< E1, E2 >::ResultType operator==(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:339
CDPL::Base::LookupKey::setName
void setName(const std::string &name) const
Sets the name of the LookupKey instance.
CDPL::Base::LookupKey::HashFunc::operator()
std::size_t operator()(const LookupKey &key) const
Returns the hash code of the LookupKey instance key.
Definition: LookupKey.hpp:162
CDPL::Base::LookupKey::HashFunc
A functor class implementing the generation of hash codes for LookupKey instances.
Definition: LookupKey.hpp:61
CDPL::Base::LookupKey::operator!=
bool operator!=(const LookupKey &key) const
Inequality comparison operator.
Definition: LookupKey.hpp:156
CDPL_BASE_API
#define CDPL_BASE_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Base::LookupKey::getName
const std::string & getName() const
Returns the name of the LookupKey instance.
CDPL::Base::LookupKey
An unique lookup key for control-parameter and property values.
Definition: LookupKey.hpp:54
APIPrefix.hpp
Definition of the preprocessor macro CDPL_BASE_API.
CDPL::Base::LookupKey::operator==
bool operator==(const LookupKey &key) const
Equality comparison operator.
Definition: LookupKey.hpp:151
CDPL::Util::operator<
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
CDPL::Base::LookupKey::NONE
static const LookupKey NONE
Used to denote an invalid, unused or unspecified key.
Definition: LookupKey.hpp:74
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Base::LookupKey::operator<
bool operator<(const LookupKey &key) const
Less than comparison operator.
Definition: LookupKey.hpp:146
CDPL::Base::LookupKey::getID
std::size_t getID() const
Returns the unique numeric identifier associated with the LookupKey instance.
Definition: LookupKey.hpp:141