Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:16

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 #ifndef DD4HEP_MEMORY_H
0015 #define DD4HEP_MEMORY_H
0016 
0017 // Framework include files
0018 #include <RVersion.h>
0019 
0020 #ifdef __GNUC__
0021 #pragma GCC diagnostic push
0022 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
0023 #elif defined(__llvm__) || defined(__APPLE__)
0024 #pragma clang diagnostic push
0025 #pragma clang diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
0026 #endif
0027 
0028 
0029 // C/C++ include files
0030 #include <memory>
0031 
0032 
0033 /// Namespace for the AIDA detector description toolkit
0034 namespace dd4hep  {
0035 
0036   /// Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
0037   /**
0038    *  Only need to overload constructor. Everything else 
0039    *  like operator->, operator*, get, release etc. comes from base.
0040    *
0041    *   \author  M.Frank
0042    *   \version 1.0
0043    *   \ingroup DD4HEP_CORE
0044    */
0045   template <typename T> class dd4hep_ptr
0046     : public std::unique_ptr<T>  {
0047     public:
0048         typedef std::unique_ptr<T> base_t;
0049     public:
0050         /// Default Constructor.
0051         dd4hep_ptr() : base_t() {}
0052         /// Constructor from pointer
0053         dd4hep_ptr(T* p) : base_t(p) {}
0054         /// Constructor from copy
0055         dd4hep_ptr(base_t& c) : base_t(c) {}
0056         /// Assignment operator
0057         dd4hep_ptr& operator=(base_t& c) {
0058           if ( this != &c )  {
0059             this->swap(c);
0060           }
0061           return *this;
0062         }
0063         /// Assignment operator
0064         dd4hep_ptr& adopt(T* ptr) {
0065           base_t smart_ptr(ptr);
0066           this->swap(smart_ptr);
0067           return *this;
0068         }
0069       };
0070   }
0071 
0072 #ifdef __GNUC__
0073 #pragma GCC diagnostic pop
0074 #elif defined(__llvm__) || defined(__APPLE__)
0075 #pragma clang diagnostic pop
0076 #endif
0077 
0078 #endif  // DD4HEP_MEMORY_H