The Gaudi Framework  master (37c0b60a)
DataStoreItem.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2021 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 #ifndef GAUDIKERNEL_DATASTOREITEM_H
12 #define GAUDIKERNEL_DATASTOREITEM_H
13 
14 // STL include files
15 #include <string>
16 
28 protected:
32  int m_depth;
33 
34 public:
36  DataStoreItem( std::string path, int depth = 1 ) : m_path( std::move( path ) ), m_depth( depth ) { analyse(); }
38  DataStoreItem( const DataStoreItem& item ) : m_path( item.m_path ), m_depth( item.m_depth ) { analyse(); }
40  virtual ~DataStoreItem() = default;
41 
43  bool operator==( const DataStoreItem& cmp ) const { return m_path == cmp.path() && m_depth == cmp.depth(); }
45  bool operator!=( const DataStoreItem& cmp ) const { return !( m_path == cmp.path() && m_depth == cmp.depth() ); }
48  m_path = cmp.path();
49  m_depth = cmp.depth();
50  analyse();
51  return *this;
52  }
54  void analyse() {
55  if ( m_path.empty() ) return;
56  const size_t len = m_path.length() - 1;
57  if ( m_path[len] == '*' ) {
58  m_depth = 99999999;
59  ( len > 0 && m_path[len - 1] == '/' ) ? m_path.erase( len - 1, 2 ) : m_path.erase( len, 1 );
60  } else if ( m_path[len] == '+' ) {
61  ( len > 0 && m_path[len - 1] == '/' ) ? m_path.erase( len - 1, 2 ) : m_path.erase( len, 1 );
62  m_depth = 2;
63  }
64  }
66  const std::string& path() const { return m_path; }
68  int depth() const { return m_depth; }
69 };
70 #endif // GAUDIKERNEL_DATASTOREITEM_H
std::string
STL class.
std::string::length
T length(T... args)
DataStoreItem::~DataStoreItem
virtual ~DataStoreItem()=default
Standard Destructor.
DataStoreItem::depth
int depth() const
Accessor: Retrieve load depth.
Definition: DataStoreItem.h:68
DataStoreItem::m_depth
int m_depth
Depth to be auto-loaded from the requested path onwards.
Definition: DataStoreItem.h:32
DataStoreItem::m_path
std::string m_path
Path of item to be loaded.
Definition: DataStoreItem.h:30
DataStoreItem::operator!=
bool operator!=(const DataStoreItem &cmp) const
Inequality operator.
Definition: DataStoreItem.h:45
DataStoreItem
Definition: DataStoreItem.h:27
std::string::erase
T erase(T... args)
DataStoreItem::DataStoreItem
DataStoreItem(const DataStoreItem &item)
Copy constructor.
Definition: DataStoreItem.h:38
DataStoreItem::operator==
bool operator==(const DataStoreItem &cmp) const
Equality operator.
Definition: DataStoreItem.h:43
DataStoreItem::DataStoreItem
DataStoreItem(std::string path, int depth=1)
Standard Constructor.
Definition: DataStoreItem.h:36
std
STL namespace.
std::string::empty
T empty(T... args)
DataStoreItem::path
const std::string & path() const
Accessor: Retrieve load path.
Definition: DataStoreItem.h:66
DataStoreItem::analyse
void analyse()
Interprete the load path for special options.
Definition: DataStoreItem.h:54
DataStoreItem::operator=
DataStoreItem & operator=(const DataStoreItem &cmp)
Equivalence operator.
Definition: DataStoreItem.h:47