The Gaudi Framework  master (37c0b60a)
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 73 of file PropertyId.h.

Constructor & Destructor Documentation

◆ PropertyId() [1/2]

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

Definition at line 75 of file PropertyId.h.

75 : PropertyId( std::string_view{ s } ) {}

◆ PropertyId() [2/2]

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

Definition at line 76 of file PropertyId.h.

76  {
78  if ( !s.empty() ) {
79  m_chunks.reserve( std::count( begin( s ), end( s ), '.' ) + 1 );
80  while ( true ) {
81  if ( auto pos = s.find( '.' ); pos != std::string_view::npos ) {
82  m_chunks.emplace_back( s.substr( 0, pos ) );
83  s.remove_prefix( pos + 1 );
84  } else {
85  m_chunks.emplace_back( s );
86  break;
87  }
88  }
89  }
90  }

Member Function Documentation

◆ hash()

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

Definition at line 104 of file PropertyId.h.

104 { return m_hash; }

◆ operator std::string()

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

Definition at line 102 of file PropertyId.h.

102 { return str(); }

◆ str()

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

Definition at line 92 of file PropertyId.h.

92  {
93  auto it = m_chunks.begin();
94  std::string s{ *it++ };
95  while ( it != m_chunks.end() ) {
96  s += '.';
97  s += *it++;
98  }
99  return s;
100  }

Friends And Related Function Documentation

◆ operator==

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

Definition at line 111 of file PropertyId.h.

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

Member Data Documentation

◆ m_chunks

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

Definition at line 107 of file PropertyId.h.

◆ m_hash

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

Definition at line 108 of file PropertyId.h.


The documentation for this class was generated from the following file:
std::string
STL class.
Gaudi::Details::PropertyId::PropertyId
PropertyId(const std::string &s)
Definition: PropertyId.h:75
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:136
Gaudi::Details::PropertyId::str
std::string str() const
Definition: PropertyId.h:92
Gaudi::Details::PropertyId::m_hash
std::size_t m_hash
Definition: PropertyId.h:108
Gaudi::Details::PropertyId::m_chunks
std::vector< SharedString > m_chunks
Definition: PropertyId.h:107
std::count
T count(T... args)
IOTest.end
end
Definition: IOTest.py:125
std::hash