Alexandria  2.19
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QualifiedName.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef PHZDATAMODEL_QUALIFIEDNAME_H
26 #define PHZDATAMODEL_QUALIFIEDNAME_H
27 
28 #include <functional>
29 #include <iostream>
30 #include <string>
31 #include <vector>
32 
33 #include "ElementsKernel/Export.h"
34 
35 namespace Euclid {
36 namespace XYDataset {
37 
67 
68 public:
82 
92  QualifiedName(const std::string&);
93 
97  QualifiedName(const QualifiedName&) = default;
98 
103  QualifiedName& operator=(const QualifiedName&) = default;
104 
108  QualifiedName(QualifiedName&&) = default;
109 
114  QualifiedName& operator=(QualifiedName&&) = default;
115 
119  virtual ~QualifiedName() = default;
120 
125  const std::vector<std::string>& groups() const;
126 
131  const std::string& datasetName() const;
132 
140  const std::string& qualifiedName() const;
141 
143  bool belongsInGroup(const QualifiedName& group) const;
144 
149  size_t hash() const;
150 
160  bool operator<(const QualifiedName& other) const;
161 
169  bool operator==(const QualifiedName& other) const;
170 
178  bool operator!=(const QualifiedName& other) const;
179 
188  bool operator()(const QualifiedName& a, const QualifiedName& b) const {
189  if (a.qualifiedName().compare(b.qualifiedName()) < 0) {
190  return true;
191  } else {
192  return false;
193  }
194  }
195  };
196 
197 private:
201  mutable size_t m_hash{0};
202 
203 }; // class QualifiedName
204 
206 std::ostream& operator<<(std::ostream& stream, const QualifiedName& qualified_name);
207 
208 } // namespace XYDataset
209 } // end of namespace Euclid
210 
211 namespace std {
212 
222 template <>
223 struct hash<Euclid::XYDataset::QualifiedName> {
224  size_t operator()(const Euclid::XYDataset::QualifiedName& qualifiedName) const {
225  return qualifiedName.hash();
226  }
227 };
228 
229 } // namespace std
230 
231 #endif // PHZDATAMODEL_QUALIFIEDNAME_H
const std::string & qualifiedName() const
Returns the qualified name as a string.
size_t hash() const
Returns the hash value of the QualifiedName.
std::ostream & operator<<(std::ostream &stream, const QualifiedName &qualified_name)
Make the QualifiedName streamable.
Provides alphabetical comparison for the QualifiedNames a and b.
std::vector< std::string > m_groups
bool operator!=(const Euclid::SourceCatalog::Source::id_type &a, const Euclid::SourceCatalog::Source::id_type &b)
boost::variant specifies an equality operator (==), but, in older boost versions, not an inequality o...
Definition: Source.h:145
STL class.
#define ELEMENTS_API
size_t operator()(const Euclid::XYDataset::QualifiedName &qualifiedName) const
bool operator()(const QualifiedName &a, const QualifiedName &b) const
Represents a name qualified with a set of groups.
Definition: QualifiedName.h:66
STL class.
T compare(T...args)