Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:08:57

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2021 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_DATASTOREITEM_H
0012 #define GAUDIKERNEL_DATASTOREITEM_H
0013 
0014 // STL include files
0015 #include <string>
0016 
0017 /** @class DataStoreItem DataStoreItem.h GaudiKernel/DataStoreItem.h
0018 
0019     Description of the DataStoreItem class.
0020     DataStoreItems describe in an abstract way an item in the data
0021     store. Items can be supplied to the services in order to
0022     e.g. trigger preloading or writing.
0023 
0024     @author M.Frank
0025     @version 1.0
0026 */
0027 class DataStoreItem {
0028 protected:
0029   /// Path of item to be loaded
0030   std::string m_path;
0031   /// Depth to be auto-loaded from the requested path onwards
0032   int m_depth;
0033 
0034 public:
0035   /// Standard Constructor
0036   DataStoreItem( std::string path, int depth = 1 ) : m_path( std::move( path ) ), m_depth( depth ) { analyse(); }
0037   /// Copy constructor
0038   DataStoreItem( const DataStoreItem& item ) : m_path( item.m_path ), m_depth( item.m_depth ) { analyse(); }
0039   /// Standard Destructor
0040   virtual ~DataStoreItem() = default;
0041 
0042   /// Equality operator
0043   bool operator==( const DataStoreItem& cmp ) const { return m_path == cmp.path() && m_depth == cmp.depth(); }
0044   /// Inequality operator
0045   bool operator!=( const DataStoreItem& cmp ) const { return !( m_path == cmp.path() && m_depth == cmp.depth() ); }
0046   /// Equivalence operator
0047   DataStoreItem& operator=( const DataStoreItem& cmp ) {
0048     m_path  = cmp.path();
0049     m_depth = cmp.depth();
0050     analyse();
0051     return *this;
0052   }
0053   /// Interprete the load path for special options
0054   void analyse() {
0055     if ( m_path.empty() ) return;
0056     const size_t len = m_path.length() - 1;
0057     if ( m_path[len] == '*' ) {
0058       m_depth = 99999999;
0059       ( len > 0 && m_path[len - 1] == '/' ) ? m_path.erase( len - 1, 2 ) : m_path.erase( len, 1 );
0060     } else if ( m_path[len] == '+' ) {
0061       ( len > 0 && m_path[len - 1] == '/' ) ? m_path.erase( len - 1, 2 ) : m_path.erase( len, 1 );
0062       m_depth = 2;
0063     }
0064   }
0065   /// Accessor: Retrieve load path
0066   const std::string& path() const { return m_path; }
0067   /// Accessor: Retrieve load depth
0068   int depth() const { return m_depth; }
0069 };
0070 #endif // GAUDIKERNEL_DATASTOREITEM_H