Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
Euclid::XYDataset::QualifiedName Class Reference

Represents a name qualified with a set of groups. More...

#include <QualifiedName.h>

Collaboration diagram for Euclid::XYDataset::QualifiedName:
Collaboration graph
[legend]

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.
 
QualifiedNameoperator= (const QualifiedName &)=default
 Copy assignment operator.
 
 QualifiedName (QualifiedName &&)=default
 Move constructor.
 
QualifiedNameoperator= (QualifiedName &&)=default
 Move assignment operator.
 
virtual ~QualifiedName ()=default
 Destructor.
 
const std::vector< std::string > & groups () const
 Returns the groups qualifying the name.
 
const std::stringdatasetName () const
 Returns the unqualified name.
 
const std::stringqualifiedName () 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::stringm_groups
 
std::string m_dataset_name
 
std::string m_qualified_name
 
size_t m_hash {0}
 

Detailed Description

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:

// This set will order the QualifiedNames based on their hash values
std::set<QualifiedName> hashOrderedSet {};
// This set will order the QualifiedNames in alphabetical order of their
// qualified names

Definition at line 66 of file QualifiedName.h.

Constructor & Destructor Documentation

◆ QualifiedName() [1/4]

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.

Parameters
groupsOne or more groups to qualify the name with
nameThe name
Exceptions
Elements::Exceptionif 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.

Here is the call graph for this function:

◆ QualifiedName() [2/4]

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).

Exceptions
Elements::Exceptionif the given string is an invalid qualified name

Definition at line 62 of file QualifiedName.cpp.

◆ QualifiedName() [3/4]

Euclid::XYDataset::QualifiedName::QualifiedName ( const QualifiedName )
default

Copy constructor.

◆ QualifiedName() [4/4]

Euclid::XYDataset::QualifiedName::QualifiedName ( QualifiedName &&  )
default

Move constructor.

◆ ~QualifiedName()

virtual Euclid::XYDataset::QualifiedName::~QualifiedName ( )
virtualdefault

Destructor.

Member Function Documentation

◆ belongsInGroup()

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().

Here is the call graph for this function:

◆ datasetName()

const std::string & Euclid::XYDataset::QualifiedName::datasetName ( ) const

Returns the unqualified name.

Returns
The unqualified name

Definition at line 69 of file QualifiedName.cpp.

References m_dataset_name.

Referenced by boost::serialization::save_construct_data().

◆ groups()

const std::vector< std::string > & Euclid::XYDataset::QualifiedName::groups ( ) const

Returns the groups qualifying the name.

Returns
The groups qualifying the name

Definition at line 65 of file QualifiedName.cpp.

References m_groups.

Referenced by boost::serialization::save_construct_data().

◆ hash()

size_t Euclid::XYDataset::QualifiedName::hash ( ) const

Returns the hash value of the QualifiedName.

Returns
The hash value

Definition at line 85 of file QualifiedName.cpp.

References m_hash, and qualifiedName().

Referenced by std::hash< Euclid::XYDataset::QualifiedName >::operator()(), operator<(), and operator==().

Here is the call graph for this function:

◆ 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.

Parameters
otherThe QualifiedName to compare with
Returns
true if the two QualifiedName are not equal, false otherwise

Definition at line 113 of file QualifiedName.cpp.

◆ operator<()

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.

Parameters
otherThe QualifiedName to compare with
Returns

Definition at line 93 of file QualifiedName.cpp.

References hash(), and qualifiedName().

Here is the call graph for this function:

◆ operator=() [1/2]

QualifiedName & Euclid::XYDataset::QualifiedName::operator= ( const QualifiedName )
default

Copy assignment operator.

Returns
A reference to the QualifiedName which was copied to

◆ operator=() [2/2]

QualifiedName & Euclid::XYDataset::QualifiedName::operator= ( QualifiedName &&  )
default

Move assignment operator.

Returns
A reference to the QualifiedName in which was moved in

◆ 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.

Parameters
otherThe QualifiedName to compare with
Returns
true if the two QualifiedName are equal, false otherwise

Definition at line 103 of file QualifiedName.cpp.

References hash(), and qualifiedName().

Here is the call graph for this function:

◆ 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".

Returns
The qualified name as a string

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().

Member Data Documentation

◆ m_dataset_name

std::string Euclid::XYDataset::QualifiedName::m_dataset_name
private

Definition at line 199 of file QualifiedName.h.

Referenced by belongsInGroup(), datasetName(), and QualifiedName().

◆ m_groups

std::vector<std::string> Euclid::XYDataset::QualifiedName::m_groups
private

Definition at line 198 of file QualifiedName.h.

Referenced by belongsInGroup(), groups(), and QualifiedName().

◆ m_hash

size_t Euclid::XYDataset::QualifiedName::m_hash {0}
mutableprivate

Definition at line 201 of file QualifiedName.h.

Referenced by hash().

◆ m_qualified_name

std::string Euclid::XYDataset::QualifiedName::m_qualified_name
private

Definition at line 200 of file QualifiedName.h.

Referenced by qualifiedName(), and QualifiedName().


The documentation for this class was generated from the following files: