DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Memory.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 #ifndef DD4HEP_MEMORY_H
15 #define DD4HEP_MEMORY_H
16 
17 // Framework include files
18 #include <RVersion.h>
19 
20 #ifdef __GNUC__
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
23 #elif defined(__llvm__) || defined(__APPLE__)
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
26 #endif
27 
28 
29 // C/C++ include files
30 #include <memory>
31 
32 
34 namespace dd4hep {
35 
37 
45  template <typename T> class dd4hep_ptr
46  : public std::unique_ptr<T> {
47  public:
48  typedef std::unique_ptr<T> base_t;
49  public:
51  dd4hep_ptr() : base_t() {}
53  dd4hep_ptr(T* p) : base_t(p) {}
55  dd4hep_ptr(base_t& c) : base_t(c) {}
58  if ( this != &c ) {
59  this->swap(c);
60  }
61  return *this;
62  }
64  dd4hep_ptr& adopt(T* ptr) {
65  base_t smart_ptr(ptr);
66  this->swap(smart_ptr);
67  return *this;
68  }
69  };
70  }
71 
72 #ifdef __GNUC__
73 #pragma GCC diagnostic pop
74 #elif defined(__llvm__) || defined(__APPLE__)
75 #pragma clang diagnostic pop
76 #endif
77 
78 #endif // DD4HEP_MEMORY_H
dd4hep::dd4hep_ptr::dd4hep_ptr
dd4hep_ptr(base_t &c)
Constructor from copy.
Definition: Memory.h:55
dd4hep::dd4hep_ptr::dd4hep_ptr
dd4hep_ptr(T *p)
Constructor from pointer.
Definition: Memory.h:53
dd4hep::dd4hep_ptr::adopt
dd4hep_ptr & adopt(T *ptr)
Assignment operator.
Definition: Memory.h:64
dd4hep::dd4hep_ptr::operator=
dd4hep_ptr & operator=(base_t &c)
Assignment operator.
Definition: Memory.h:57
dd4hep::dd4hep_ptr::base_t
std::unique_ptr< T > base_t
Definition: Memory.h:48
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::dd4hep_ptr::dd4hep_ptr
dd4hep_ptr()
Default Constructor.
Definition: Memory.h:51
dd4hep::dd4hep_ptr
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
Definition: Memory.h:46