Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:37

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 GAUDIHIVE_DATAOBJECTHANDLEBASE_H
0012 #define GAUDIHIVE_DATAOBJECTHANDLEBASE_H
0013 
0014 #include <mutex>
0015 
0016 #include "GaudiKernel/DataHandle.h"
0017 #include "GaudiKernel/IDataProviderSvc.h"
0018 #include "GaudiKernel/IMessageSvc.h"
0019 #include "GaudiKernel/IProperty.h"
0020 #include "GaudiKernel/SmartIF.h"
0021 
0022 //---------------------------------------------------------------------------
0023 
0024 /** DataObjectHandleBase  GaudiKernel/DataObjectHandleBase.h
0025  *
0026  * Base class for handles to Data Objects in the Event Store, to simplify
0027  * access via Properties.
0028  *
0029  * @author Charles Leggett
0030  * @date   2015-09-01
0031  */
0032 
0033 //---------------------------------------------------------------------------
0034 
0035 class DataObjectHandleBase : public Gaudi::DataHandle {
0036 
0037 public:
0038   DataObjectHandleBase( DataObjID k, Gaudi::DataHandle::Mode a, IDataHandleHolder* owner );
0039   DataObjectHandleBase( std::string k, Gaudi::DataHandle::Mode a, IDataHandleHolder* owner );
0040 
0041   ~DataObjectHandleBase() override;
0042   DataObjectHandleBase( const DataObjectHandleBase& ) = delete;
0043   DataObjectHandleBase( DataObjectHandleBase&& );
0044   DataObjectHandleBase& operator=( const DataObjectHandleBase& );
0045 
0046   /// Autodeclaring constructor with property name, mode, key and documentation.
0047   /// @note the use std::enable_if is required to avoid ambiguities
0048   template <class OWNER, class K, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
0049   inline DataObjectHandleBase( OWNER* owner, Gaudi::DataHandle::Mode m, std::string name, K key = {},
0050                                std::string doc = "" )
0051       : DataObjectHandleBase( std::move( key ), m, owner ) {
0052     auto p = owner->declareProperty( std::move( name ), *this, std::move( doc ) );
0053     p->template setOwnerType<OWNER>();
0054   }
0055 
0056   friend std::ostream& operator<<( std::ostream& str, const DataObjectHandleBase& d );
0057 
0058   /// Check if the data object declared is optional for the algorithm
0059   bool isOptional() const { return m_optional; }
0060   void setOptional( bool optional = true ) { m_optional = optional; }
0061 
0062   bool isValid() const;
0063 
0064 protected:
0065   bool init() override;
0066 
0067   DataObject* fetch() const;
0068 
0069 protected:
0070   SmartIF<IDataProviderSvc> m_EDS;
0071   SmartIF<IMessageSvc>      m_MS;
0072 
0073   bool m_init     = false;
0074   bool m_optional = false;
0075 };
0076 
0077 #endif