The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::Details::PropertyId Class Referencefinal

Helper to record a property identifier as a sequence of SharedString instances. More...

#include </builds/gaudi/Gaudi/GaudiCoreSvc/src/JobOptionsSvc/PropertyId.h>

Collaboration diagram for Gaudi::Details::PropertyId:

Public Member Functions

 PropertyId (const std::string &s)
 
 PropertyId (std::string_view s)
 
std::string str () const
 
 operator std::string () const
 
std::size_t hash () const noexcept
 

Private Attributes

std::vector< SharedStringm_chunks
 
std::size_t m_hash
 

Friends

bool operator== (const PropertyId &lhs, const PropertyId &rhs)
 

Detailed Description

Helper to record a property identifier as a sequence of SharedString instances.

A PropertyId instance initilized from a string like SomeName.OtherName.AnotherLevel.PropertyName will use internally a vector of 4 SharedString instances so that the storage for the various components can be shared with other PropertyId instances.

To be afficiently used as key in an std::unordered_map, PropertyId caches the hash computed from the string it was constructed from.

Definition at line 65 of file PropertyId.h.

Constructor & Destructor Documentation

◆ PropertyId() [1/2]

Gaudi::Details::PropertyId::PropertyId ( const std::string & s)
inline

Definition at line 67 of file PropertyId.h.

67: PropertyId( std::string_view{ s } ) {}
PropertyId(const std::string &s)
Definition PropertyId.h:67

◆ PropertyId() [2/2]

Gaudi::Details::PropertyId::PropertyId ( std::string_view s)
inline

Definition at line 68 of file PropertyId.h.

68 {
69 m_hash = std::hash<std::string_view>()( s );
70 if ( !s.empty() ) {
71 m_chunks.reserve( std::count( begin( s ), end( s ), '.' ) + 1 );
72 while ( true ) {
73 if ( auto pos = s.find( '.' ); pos != std::string_view::npos ) {
74 m_chunks.emplace_back( s.substr( 0, pos ) );
75 s.remove_prefix( pos + 1 );
76 } else {
77 m_chunks.emplace_back( s );
78 break;
79 }
80 }
81 }
82 }
std::vector< SharedString > m_chunks
Definition PropertyId.h:99
AttribStringParser::Iterator begin(const AttribStringParser &parser)

Member Function Documentation

◆ hash()

std::size_t Gaudi::Details::PropertyId::hash ( ) const
inlinenoexcept

Definition at line 96 of file PropertyId.h.

96{ return m_hash; }

◆ operator std::string()

Gaudi::Details::PropertyId::operator std::string ( ) const
inline

Definition at line 94 of file PropertyId.h.

94{ return str(); }
std::string str() const
Definition PropertyId.h:84

◆ str()

std::string Gaudi::Details::PropertyId::str ( ) const
inline

Definition at line 84 of file PropertyId.h.

84 {
85 auto it = m_chunks.begin();
86 std::string s{ *it++ };
87 while ( it != m_chunks.end() ) {
88 s += '.';
89 s += *it++;
90 }
91 return s;
92 }

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const PropertyId & lhs,
const PropertyId & rhs )
friend

Definition at line 103 of file PropertyId.h.

103{ return lhs.m_chunks == rhs.m_chunks; }

Member Data Documentation

◆ m_chunks

std::vector<SharedString> Gaudi::Details::PropertyId::m_chunks
private

Definition at line 99 of file PropertyId.h.

◆ m_hash

std::size_t Gaudi::Details::PropertyId::m_hash
private

Definition at line 100 of file PropertyId.h.


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