The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
DataStoreItem.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include <string>
14
26protected:
28 std::string m_path;
31
32public:
34 DataStoreItem( std::string path, int depth = 1 ) : m_path( std::move( path ) ), m_depth( depth ) { analyse(); }
36 DataStoreItem( const DataStoreItem& item ) : m_path( item.m_path ), m_depth( item.m_depth ) { analyse(); }
38 virtual ~DataStoreItem() = default;
39
41 bool operator==( const DataStoreItem& cmp ) const { return m_path == cmp.path() && m_depth == cmp.depth(); }
43 bool operator!=( const DataStoreItem& cmp ) const { return !( m_path == cmp.path() && m_depth == cmp.depth() ); }
46 m_path = cmp.path();
47 m_depth = cmp.depth();
48 analyse();
49 return *this;
50 }
51
52 void analyse() {
53 if ( m_path.empty() ) return;
54 const size_t len = m_path.length() - 1;
55 if ( m_path[len] == '*' ) {
56 m_depth = 99999999;
57 ( len > 0 && m_path[len - 1] == '/' ) ? m_path.erase( len - 1, 2 ) : m_path.erase( len, 1 );
58 } else if ( m_path[len] == '+' ) {
59 ( len > 0 && m_path[len - 1] == '/' ) ? m_path.erase( len - 1, 2 ) : m_path.erase( len, 1 );
60 m_depth = 2;
61 }
62 }
63
64 const std::string& path() const { return m_path; }
66 int depth() const { return m_depth; }
67};
bool operator!=(const DataStoreItem &cmp) const
Inequality operator.
void analyse()
Interprete the load path for special options.
DataStoreItem(const DataStoreItem &item)
Copy constructor.
int m_depth
Depth to be auto-loaded from the requested path onwards.
int depth() const
Accessor: Retrieve load depth.
const std::string & path() const
Accessor: Retrieve load path.
DataStoreItem & operator=(const DataStoreItem &cmp)
Equivalence operator.
DataStoreItem(std::string path, int depth=1)
Standard Constructor.
bool operator==(const DataStoreItem &cmp) const
Equality operator.
virtual ~DataStoreItem()=default
Standard Destructor.
std::string m_path
Path of item to be loaded.
STL namespace.