Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
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
34
35namespace Euclid {
36namespace XYDataset {
37
67
68public:
82
92 QualifiedName(const std::string&); // cppcheck-suppress noExplicitConstructor
93
97 QualifiedName(const QualifiedName&) = default;
98
104
109
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
197private:
201 mutable size_t m_hash{0};
202
203}; // class QualifiedName
204
206std::ostream& operator<<(std::ostream& stream, const QualifiedName& qualified_name);
207
208} // namespace XYDataset
209} // end of namespace Euclid
210
211namespace std {
212
222template <>
223struct 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
Represents a name qualified with a set of groups.
size_t hash() const
Returns the hash value of the QualifiedName.
QualifiedName(QualifiedName &&)=default
Move constructor.
virtual ~QualifiedName()=default
Destructor.
const std::string & qualifiedName() const
Returns the qualified name as a string.
QualifiedName(const QualifiedName &)=default
Copy constructor.
QualifiedName & operator=(QualifiedName &&)=default
Move assignment operator.
QualifiedName & operator=(const QualifiedName &)=default
Copy assignment operator.
std::vector< std::string > m_groups
T compare(T... args)
#define ELEMENTS_API
STL namespace.
Provides alphabetical comparison for the QualifiedNames a and b.
bool operator()(const QualifiedName &a, const QualifiedName &b) const
size_t operator()(const Euclid::XYDataset::QualifiedName &qualifiedName) const