CMS 3D CMS Logo

FWEvePtr.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWEvePtr_h
2 #define Fireworks_Core_FWEvePtr_h
3 // -*- C++ -*-
4 //
5 // Package: Core
6 // Class : FWEvePtr
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Wed Nov 12 11:08:49 EST 2008
19 //
20 
21 // system include files
22 #include <memory>
23 #include "TEveElement.h"
24 
25 // user include files
26 
27 // forward declarations
28 
29 template < typename T>
30 class FWEvePtr {
31 
32 public:
34  }
35  explicit FWEvePtr(T* iElement) : m_container(new TEveElementList()) {
36  m_container->AddElement(iElement);
37  }
38  // ---------- const member functions ---------------------
39  T* operator->() const {
40  return m_container && m_container->HasChildren() ?
41  static_cast<T*>(m_container->FirstChild()) :
42  static_cast<T*>(0);
43  }
44  T& operator*() const {
45  return *(operator->());
46  }
47 
48  T* get() const {
49  return (operator->());
50  }
51 
52  operator bool() const {
53  return m_container && m_container->HasChildren();
54  }
55  // ---------- static member functions --------------------
56 
57  // ---------- member functions ---------------------------
58  void reset() {
59  m_container.reset();
60  }
61  void reset(T* iNew) {
62  FWEvePtr<T> temp(iNew);
63  swap(temp);
64  }
65  void destroyElement() {
66  if(m_container) {m_container->DestroyElements();}
67  reset();
68  }
69 
70  void swap(FWEvePtr<T>& iOther) {
71  m_container.swap(iOther.m_container);
72  }
73 private:
74  //FWEvePtr(const FWEvePtr&); // stop default
75 
76  //const FWEvePtr& operator=(const FWEvePtr&); // stop default
77 
78  // ---------- member data --------------------------------
79  std::shared_ptr<TEveElement> m_container;
80 };
81 
82 
83 #endif
std::shared_ptr< TEveElement > m_container
Definition: FWEvePtr.h:79
void reset()
Definition: FWEvePtr.h:58
void destroyElement()
Definition: FWEvePtr.h:65
T & operator*() const
Definition: FWEvePtr.h:44
void swap(FWEvePtr< T > &iOther)
Definition: FWEvePtr.h:70
void reset(T *iNew)
Definition: FWEvePtr.h:61
FWEvePtr()
Definition: FWEvePtr.h:33
long double T
FWEvePtr(T *iElement)
Definition: FWEvePtr.h:35
T * operator->() const
Definition: FWEvePtr.h:39