Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 3 4 #ifndef tools_sg_h2plot_cp 5 #define tools_sg_h2plot_cp 6 7 // Inheritance : 8 #include "h2plot" 9 10 namespace tools { 11 namespace sg { 12 13 class h1d2plot_cp : public h1d2plot { 14 public: 15 TOOLS_SCLASS(tools::sg::h1d2plot_cp) 16 public: 17 virtual void* cast(const std::string& a_class) const { 18 if(void* p = cmp_cast<h1d2plot_cp>(this,a_class)) {return p;} 19 return h1d2plot::cast(a_class); 20 } 21 public: 22 virtual plottable* copy() const {return new h1d2plot_cp(*this);} 23 public: 24 h1d2plot_cp(const histo::h1d& a_data) 25 :h1d2plot(m_cp) //give ref of m_cp to h1d2plot. 26 ,m_cp(a_data) //do a local copy. 27 //WARNING : the upper is ok as long as h1d2plot constructor does nothing 28 // else than keeping the ref to m_cp. Else it would do 29 // something on an empty histo (and not on a copy of the 30 // passed a_data). 31 { 32 #ifdef TOOLS_MEM 33 mem::increment(s_class().c_str()); 34 #endif 35 } 36 virtual ~h1d2plot_cp(){ 37 #ifdef TOOLS_MEM 38 mem::decrement(s_class().c_str()); 39 #endif 40 } 41 public: 42 h1d2plot_cp(const h1d2plot_cp& a_from) 43 :plottable(a_from) 44 ,bins1D(a_from) 45 ,h1d2plot(m_cp) 46 ,m_cp(a_from.m_cp) 47 { 48 #ifdef TOOLS_MEM 49 mem::increment(s_class().c_str()); 50 #endif 51 } 52 h1d2plot_cp& operator=(const h1d2plot_cp& a_from){ 53 h1d2plot::operator=(a_from); 54 m_cp = a_from.m_cp; 55 return *this; 56 } 57 public: 58 const histo::h1d& data() const {return m_cp;} 59 histo::h1d& data() {return m_cp;} 60 protected: 61 histo::h1d m_cp; 62 }; 63 64 class h2d2plot_cp : public h2d2plot { 65 public: 66 TOOLS_SCLASS(tools::sg::h2d2plot_cp) 67 public: 68 virtual void* cast(const std::string& a_class) const { 69 if(void* p = cmp_cast<h2d2plot_cp>(this,a_class)) {return p;} 70 return h2d2plot::cast(a_class); 71 } 72 public: 73 virtual plottable* copy() const {return new h2d2plot_cp(*this);} 74 public: 75 h2d2plot_cp(const histo::h2d& a_data) 76 :h2d2plot(m_cp) 77 ,m_cp(a_data) 78 { 79 #ifdef TOOLS_MEM 80 mem::increment(s_class().c_str()); 81 #endif 82 } 83 virtual ~h2d2plot_cp(){ 84 #ifdef TOOLS_MEM 85 mem::decrement(s_class().c_str()); 86 #endif 87 } 88 public: 89 h2d2plot_cp(const h2d2plot_cp& a_from) 90 :plottable(a_from),bins2D(a_from),h2d2plot(m_cp) 91 ,m_cp(a_from.m_cp) 92 { 93 #ifdef TOOLS_MEM 94 mem::increment(s_class().c_str()); 95 #endif 96 } 97 h2d2plot_cp& operator=(const h2d2plot_cp& a_from){ 98 h2d2plot::operator=(a_from); 99 m_cp = a_from.m_cp; 100 return *this; 101 } 102 protected: 103 histo::h2d m_cp; 104 }; 105 106 class p1d2plot_cp : public p1d2plot { 107 public: 108 TOOLS_SCLASS(tools::sg::p1d2plot_cp) 109 public: 110 virtual void* cast(const std::string& a_class) const { 111 if(void* p = cmp_cast<p1d2plot_cp>(this,a_class)) {return p;} 112 return p1d2plot::cast(a_class); 113 } 114 public: 115 virtual plottable* copy() const {return new p1d2plot_cp(*this);} 116 public: 117 p1d2plot_cp(const histo::p1d& a_data) 118 :p1d2plot(m_cp) 119 ,m_cp(a_data) 120 { 121 #ifdef TOOLS_MEM 122 mem::increment(s_class().c_str()); 123 #endif 124 } 125 virtual ~p1d2plot_cp(){ 126 #ifdef TOOLS_MEM 127 mem::decrement(s_class().c_str()); 128 #endif 129 } 130 public: 131 p1d2plot_cp(const p1d2plot_cp& a_from) 132 :plottable(a_from),bins1D(a_from),p1d2plot(m_cp) 133 ,m_cp(a_from.m_cp) 134 { 135 #ifdef TOOLS_MEM 136 mem::increment(s_class().c_str()); 137 #endif 138 } 139 p1d2plot_cp& operator=(const p1d2plot_cp& a_from){ 140 p1d2plot::operator=(a_from); 141 m_cp = a_from.m_cp; 142 return *this; 143 } 144 protected: 145 histo::p1d m_cp; 146 }; 147 148 }} 149 150 #endif