Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Represents a name qualified with a set of groups. More...
#include <QualifiedName.h>
Classes | |
class | AlphabeticalComparator |
Provides alphabetical comparison for the QualifiedNames a and b. More... | |
Public Member Functions | |
QualifiedName (std::vector< std::string > groups, std::string name) | |
Constructs a QualifiedName with the given group and name. | |
QualifiedName (const std::string &) | |
Constructs a QualifiedName object representing the given string. | |
QualifiedName (const QualifiedName &)=default | |
Copy constructor. | |
QualifiedName & | operator= (const QualifiedName &)=default |
Copy assignment operator. | |
QualifiedName (QualifiedName &&)=default | |
Move constructor. | |
QualifiedName & | operator= (QualifiedName &&)=default |
Move assignment operator. | |
virtual | ~QualifiedName ()=default |
Destructor. | |
const std::vector< std::string > & | groups () const |
Returns the groups qualifying the name. | |
const std::string & | datasetName () const |
Returns the unqualified name. | |
const std::string & | qualifiedName () const |
Returns the qualified name as a string. | |
bool | belongsInGroup (const QualifiedName &group) const |
Checks if the QualifiedName belongs in a given group. | |
size_t | hash () const |
Returns the hash value of the QualifiedName. | |
bool | operator< (const QualifiedName &other) const |
Compares this QualifiedName with the parameter. | |
bool | operator== (const QualifiedName &other) const |
Checks if this QualifiedName is equal with the parameter. | |
bool | operator!= (const QualifiedName &other) const |
Checks if this QualifiedName is not equal with the parameter. | |
Private Attributes | |
std::vector< std::string > | m_groups |
std::string | m_dataset_name |
std::string | m_qualified_name |
size_t | m_hash {0} |
Represents a name qualified with a set of groups.
The QualifiedName class represents a name qualified with a set of groups. The groups and the names are separated with the '/' character (eg group1/group2/name). Note that the qualified name is assumed to be unique and it can be used as identifier.
The QualifiedName class provides a method for calculating its hash. The "less than" and "equals" operators are implemented using this hash value as much as possible. This means the QualifiedName can be used as a key in ordered and unordered collections in an efficient way. Note that for favoring performance, the ordering of the QualifiedNames is not alphabetical, but based on the hash key. If the alphabetical ordering is important, then the provided QualifiedName::AlphabeticalComparator can be used:
Definition at line 66 of file QualifiedName.h.
Euclid::XYDataset::QualifiedName::QualifiedName | ( | std::vector< std::string > | groups, |
std::string | name | ||
) |
Constructs a QualifiedName with the given group and name.
Both group and name cannot be empty and they cannot contain the '/' character. In this case an Elements::Exception is thrown.
groups | One or more groups to qualify the name with |
name | The name |
Elements::Exception | if any of the parameters is empty or contains the '/' character |
Definition at line 33 of file QualifiedName.cpp.
References std::string::append(), std::string::empty(), std::string::find(), m_dataset_name, m_groups, and m_qualified_name.
Euclid::XYDataset::QualifiedName::QualifiedName | ( | const std::string & | qualified_name | ) |
Constructs a QualifiedName object representing the given string.
The given string must follow the rules of a qualified name (groups and name separated with the '/' character and no empty names allowed).
Elements::Exception | if the given string is an invalid qualified name |
Definition at line 62 of file QualifiedName.cpp.
|
default |
Copy constructor.
|
default |
Move constructor.
|
virtualdefault |
Destructor.
bool Euclid::XYDataset::QualifiedName::belongsInGroup | ( | const QualifiedName & | group | ) | const |
Checks if the QualifiedName belongs in a given group.
Definition at line 77 of file QualifiedName.cpp.
References std::vector< T >::at(), std::vector< T >::begin(), std::string::begin(), std::vector< T >::end(), std::equal(), m_dataset_name, m_groups, std::vector< T >::size(), and std::string::size().
const std::string & Euclid::XYDataset::QualifiedName::datasetName | ( | ) | const |
Returns the unqualified name.
Definition at line 69 of file QualifiedName.cpp.
References m_dataset_name.
Referenced by boost::serialization::save_construct_data().
const std::vector< std::string > & Euclid::XYDataset::QualifiedName::groups | ( | ) | const |
Returns the groups qualifying the name.
Definition at line 65 of file QualifiedName.cpp.
References m_groups.
Referenced by boost::serialization::save_construct_data().
size_t Euclid::XYDataset::QualifiedName::hash | ( | ) | const |
Returns the hash value of the QualifiedName.
Definition at line 85 of file QualifiedName.cpp.
References m_hash, and qualifiedName().
Referenced by std::hash< Euclid::XYDataset::QualifiedName >::operator()(), operator<(), and operator==().
bool Euclid::XYDataset::QualifiedName::operator!= | ( | const QualifiedName & | other | ) | const |
Checks if this QualifiedName is not equal with the parameter.
Two QualifiedNames are considered equal if they have the same groups and name.
other | The QualifiedName to compare with |
Definition at line 113 of file QualifiedName.cpp.
bool Euclid::XYDataset::QualifiedName::operator< | ( | const QualifiedName & | other | ) | const |
Compares this QualifiedName with the parameter.
The comparison is based on the hash values of the QualifiedNames (for performance reasons). For alphabetical comparison the QualifiedName::alphabeticalComparator can be used.
other | The QualifiedName to compare with |
Definition at line 93 of file QualifiedName.cpp.
References hash(), and qualifiedName().
|
default |
Copy assignment operator.
|
default |
Move assignment operator.
bool Euclid::XYDataset::QualifiedName::operator== | ( | const QualifiedName & | other | ) | const |
Checks if this QualifiedName is equal with the parameter.
Two QualifiedNames are considered equal if they have the same groups and name.
other | The QualifiedName to compare with |
Definition at line 103 of file QualifiedName.cpp.
References hash(), and qualifiedName().
const std::string & Euclid::XYDataset::QualifiedName::qualifiedName | ( | ) | const |
Returns the qualified name as a string.
The qualified name is the combination of the groups and name separated with the '/' character. For example: "group1/group2/name".
Definition at line 73 of file QualifiedName.cpp.
References m_qualified_name.
Referenced by hash(), Euclid::XYDataset::QualifiedName::AlphabeticalComparator::operator()(), operator<(), Euclid::XYDataset::operator<<(), operator==(), and Euclid::GridContainer::GridAxisToTable< Euclid::XYDataset::QualifiedName >::serialize().
|
private |
Definition at line 199 of file QualifiedName.h.
Referenced by belongsInGroup(), datasetName(), and QualifiedName().
|
private |
Definition at line 198 of file QualifiedName.h.
Referenced by belongsInGroup(), groups(), and QualifiedName().
|
mutableprivate |
Definition at line 201 of file QualifiedName.h.
Referenced by hash().
|
private |
Definition at line 200 of file QualifiedName.h.
Referenced by qualifiedName(), and QualifiedName().