The Gaudi Framework  v36r9p1 (5c15b2bb)
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 72 of file PropertyId.h.

Constructor & Destructor Documentation

◆ PropertyId() [1/2]

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

Definition at line 74 of file PropertyId.h.

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

◆ PropertyId() [2/2]

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

Definition at line 75 of file PropertyId.h.

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

Member Function Documentation

◆ hash()

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

Definition at line 103 of file PropertyId.h.

103 { return m_hash; }

◆ operator std::string()

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

Definition at line 101 of file PropertyId.h.

101 { return str(); }

◆ str()

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

Definition at line 91 of file PropertyId.h.

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

Friends And Related Function Documentation

◆ operator==

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

Definition at line 110 of file PropertyId.h.

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

Member Data Documentation

◆ m_chunks

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

Definition at line 106 of file PropertyId.h.

◆ m_hash

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

Definition at line 107 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:74
gaudirun.s
string s
Definition: gaudirun.py:346
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
Gaudi::Details::PropertyId::str
std::string str() const
Definition: PropertyId.h:91
Gaudi::Details::PropertyId::m_hash
std::size_t m_hash
Definition: PropertyId.h:107
Gaudi::Details::PropertyId::m_chunks
std::vector< SharedString > m_chunks
Definition: PropertyId.h:106
IOTest.end
def end
Definition: IOTest.py:128
std::count
T count(T... args)
std::hash