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 public:
32  FWEvePtr() {}
33  explicit FWEvePtr(T* iElement) : m_container(new TEveElementList()) { m_container->AddElement(iElement); }
34  // ---------- const member functions ---------------------
35  T* operator->() const {
36  return m_container && m_container->HasChildren() ? static_cast<T*>(m_container->FirstChild()) : static_cast<T*>(0);
37  }
38  T& operator*() const { return *(operator->()); }
39 
40  T* get() const { return (operator->()); }
41 
42  operator bool() const { return m_container && m_container->HasChildren(); }
43  // ---------- static member functions --------------------
44 
45  // ---------- member functions ---------------------------
46  void reset() { m_container.reset(); }
47  void reset(T* iNew) {
48  FWEvePtr<T> temp(iNew);
49  swap(temp);
50  }
51  void destroyElement() {
52  if (m_container) {
53  m_container->DestroyElements();
54  }
55  reset();
56  }
57 
58  void swap(FWEvePtr<T>& iOther) { m_container.swap(iOther.m_container); }
59 
60 private:
61  //FWEvePtr(const FWEvePtr&); // stop default
62 
63  //const FWEvePtr& operator=(const FWEvePtr&); // stop default
64 
65  // ---------- member data --------------------------------
66  std::shared_ptr<TEveElement> m_container;
67 };
68 
69 #endif
std::shared_ptr< TEveElement > m_container
Definition: FWEvePtr.h:66
T & operator*() const
Definition: FWEvePtr.h:38
void reset()
Definition: FWEvePtr.h:46
void destroyElement()
Definition: FWEvePtr.h:51
void swap(FWEvePtr< T > &iOther)
Definition: FWEvePtr.h:58
void reset(T *iNew)
Definition: FWEvePtr.h:47
FWEvePtr()
Definition: FWEvePtr.h:32
T * operator->() const
Definition: FWEvePtr.h:35
long double T
FWEvePtr(T *iElement)
Definition: FWEvePtr.h:33