Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:38:30

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2020 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_DATAHANDLE
0012 #define GAUDIKERNEL_DATAHANDLE 1
0013 
0014 #include "GaudiKernel/DataHandleProperty.h"
0015 #include "GaudiKernel/DataObjID.h"
0016 
0017 //---------------------------------------------------------------------------
0018 
0019 /** DataHandle.h  GaudiKernel/DataHandle.h
0020  *
0021  * Base class for Handles to access data in Event Store, shared between
0022  * Gaudi and Atlas
0023  *
0024  * Objects are identified via a DataObjID
0025  *
0026  * Once object is created, Mode is not modifiable
0027  *
0028  * @author Charles Leggett
0029  * @date   2015-09-01
0030  */
0031 
0032 //---------------------------------------------------------------------------
0033 
0034 class IDataHandleHolder;
0035 
0036 namespace Gaudi {
0037 
0038   class DataHandle {
0039   public:
0040     enum Mode { Reader = 1 << 2, Writer = 1 << 4 };
0041 
0042     DataHandle( DataObjID k, Mode a = Reader, IDataHandleHolder* owner = nullptr )
0043         : m_key( std::move( k ) ), m_owner( owner ), m_mode( a ){};
0044 
0045     DataHandle( DataObjID k, bool isCond, Mode a = Reader, IDataHandleHolder* owner = nullptr )
0046         : m_key( std::move( k ) ), m_owner( owner ), m_mode( a ), m_isCond( isCond ){};
0047 
0048     using PropertyType = DataHandleProperty;
0049 
0050     virtual ~DataHandle() = default;
0051 
0052     virtual void               setOwner( IDataHandleHolder* o ) { m_owner = o; }
0053     virtual IDataHandleHolder* owner() const { return m_owner; }
0054 
0055     virtual Mode mode() const { return m_mode; }
0056 
0057     virtual void setKey( DataObjID key ) { m_key = std::move( key ); }
0058     virtual void updateKey( std::string key ) { m_key.updateKey( std::move( key ) ); }
0059 
0060     virtual const std::string& objKey() const { return m_key.key(); }
0061     virtual const DataObjID&   fullKey() const { return m_key; }
0062 
0063     virtual void reset( bool ){};
0064 
0065     virtual std::string pythonRepr() const;
0066     virtual bool        init() { return true; }
0067 
0068     // is this a ConditionHandle?
0069     virtual bool isCondition() const { return m_isCond; }
0070 
0071     friend std::ostream& operator<<( std::ostream& str, const DataHandle& d );
0072 
0073   protected:
0074     /**
0075      * The key of the object behind this DataHandle
0076      * Although it may look strange to have it mutable, this can actually
0077      * change in case the object had alternative names, and it should not
0078      * be visible to the end user, for which the Handle is still the same
0079      */
0080     DataObjID          m_key   = { "NONE" };
0081     IDataHandleHolder* m_owner = nullptr;
0082 
0083     static const std::string default_type;
0084 
0085   private:
0086     Mode m_mode   = Reader;
0087     bool m_isCond = false;
0088   };
0089 
0090   namespace Parsers {
0091     StatusCode parse( DataHandle&, const std::string& );
0092   }
0093   namespace Utils {
0094     GAUDI_API std::ostream& toStream( const DataHandle& v, std::ostream& o );
0095   }
0096 } // namespace Gaudi
0097 
0098 #endif