Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:30

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_GENERICADDRESS_H
0012 #define GAUDIKERNEL_GENERICADDRESS_H
0013 
0014 // Framework include files
0015 #include "GaudiKernel/IOpaqueAddress.h"
0016 #include "GaudiKernel/Kernel.h"
0017 
0018 // Forward declarations
0019 class IRegistry;
0020 
0021 /** @class GenericAddress GenericAddress.h GaudiKernel/GenericAddress.h
0022 
0023     Generic Transient Address.
0024     The generic transient address describes the recipe to load/save
0025     a persistent object from/to its transient representation.
0026 
0027     @author Markus Frank
0028     @version 1.0
0029 */
0030 class GAUDI_API GenericAddress : public IOpaqueAddress {
0031 protected:
0032   /// Reference count
0033   unsigned long m_refCount = 0;
0034   /// Storage type
0035   long m_svcType = 0;
0036   /// Class id
0037   CLID m_clID = 0;
0038   /// String parameters to be accessed
0039   std::string m_par[3];
0040   /// Integer parameters to be accessed
0041   unsigned long m_ipar[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
0042   /// Pointer to corresponding directory
0043   IRegistry* m_pRegistry = nullptr;
0044 
0045 public:
0046   /// Dummy constructor
0047   GenericAddress() = default;
0048   /// Standard Copy Constructor (note: m_refCount is NOT copied)
0049   GenericAddress( const GenericAddress& copy )
0050       : IOpaqueAddress( copy ), m_svcType( copy.m_svcType ), m_clID( copy.m_clID ), m_pRegistry( copy.m_pRegistry ) {
0051     m_par[0]  = copy.m_par[0];
0052     m_par[1]  = copy.m_par[1];
0053     m_ipar[0] = copy.m_ipar[0];
0054     m_ipar[1] = copy.m_ipar[1];
0055   }
0056   /// Standard Constructor
0057   GenericAddress( long svc, const CLID& clid, std::string p1 = "", std::string p2 = "", unsigned long ip1 = 0,
0058                   unsigned long ip2 = 0 )
0059       : m_svcType( svc ), m_clID( clid ) {
0060     m_par[0]  = std::move( p1 );
0061     m_par[1]  = std::move( p2 );
0062     m_ipar[0] = ip1;
0063     m_ipar[1] = ip2;
0064   }
0065 
0066   GenericAddress& operator=( const GenericAddress& copy ) = default;
0067 
0068   /// Add reference to object
0069   unsigned long addRef() override { return ++m_refCount; }
0070   /// release reference to object
0071   unsigned long release() override {
0072     unsigned long cnt = --m_refCount;
0073     if ( 0 == cnt ) delete this;
0074     return cnt;
0075   }
0076   /// Pointer to directory
0077   IRegistry* registry() const override { return m_pRegistry; }
0078   /// Set pointer to directory
0079   void setRegistry( IRegistry* pRegistry ) override { m_pRegistry = pRegistry; }
0080   /// Access : Retrieve class ID of the link
0081   const CLID& clID() const override { return m_clID; }
0082   /// Access : Set class ID of the link
0083   void setClID( const CLID& clid ) { m_clID = clid; }
0084   /// Access : retrieve the storage type of the class id
0085   long svcType() const override { return m_svcType; }
0086   /// Access : set the storage type of the class id
0087   void setSvcType( long typ ) { m_svcType = typ; }
0088   /// Retrieve string parameters
0089   const std::string* par() const override { return m_par; }
0090   /// Retrieve integer parameters
0091   const unsigned long* ipar() const override { return m_ipar; }
0092 };
0093 #endif // GAUDIKERNEL_GENERICADDRESS_H