HepMC event record
include/HepMC/Data/SmartPointer.icc
1 /**
2  * @file SmartPointer.icc
3  * @brief Implementation of inline functions from \b class SmartPointer
4  *
5  */
6 
7 namespace HepMC {
8 
9 template<class T>
10 SmartPointer<T>::SmartPointer() {
11 }
12 
13 template<class T>
14 SmartPointer<T>::SmartPointer( const SmartPointer<T> &rhs ):
15 m_data(rhs.m_data) {
16 }
17 
18 template<class T>
19 SmartPointer<T>::SmartPointer( const shared_ptr<T> &rhs ):
20 m_data(rhs) {
21  if(m_data) m_data->m_this = m_data;
22 }
23 
24 template<class T>
25 SmartPointer<T>::SmartPointer( T *raw_pointer ) {
26  if(raw_pointer) {
27  if(raw_pointer->m_this.expired()) {
28  m_data.reset(raw_pointer);
29  m_data->m_this = m_data;
30  }
31  else m_data = raw_pointer->m_this.lock();
32  }
33 }
34 
35 } // namespace HepMC