CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: FWEvePtr.h,v 1.1 2008/11/14 15:08:31 chrjones Exp $
20 //
21 
22 // system include files
23 #include <boost/shared_ptr.hpp>
24 #include "TEveElement.h"
25 
26 // user include files
27 
28 // forward declarations
29 
30 template < typename T>
31 class FWEvePtr {
32 
33 public:
35  }
36  explicit FWEvePtr(T* iElement) : m_container(new TEveElementList()) {
37  m_container->AddElement(iElement);
38  }
39  // ---------- const member functions ---------------------
40  T* operator->() const {
41  return m_container && m_container->HasChildren() ?
42  static_cast<T*>(m_container->FirstChild()) :
43  static_cast<T*>(0);
44  }
45  T& operator*() const {
46  return *(operator->());
47  }
48 
49  T* get() const {
50  return (operator->());
51  }
52 
53  operator bool() const {
54  return m_container && m_container->HasChildren();
55  }
56  // ---------- static member functions --------------------
57 
58  // ---------- member functions ---------------------------
59  void reset() {
60  m_container.reset();
61  }
62  void reset(T* iNew) {
63  FWEvePtr<T> temp(iNew);
64  swap(temp);
65  }
66  void destroyElement() {
67  if(m_container) {m_container->DestroyElements();}
68  reset();
69  }
70 
71  void swap(FWEvePtr<T>& iOther) {
72  m_container.swap(iOther.m_container);
73  }
74 private:
75  //FWEvePtr(const FWEvePtr&); // stop default
76 
77  //const FWEvePtr& operator=(const FWEvePtr&); // stop default
78 
79  // ---------- member data --------------------------------
80  boost::shared_ptr<TEveElement> m_container;
81 };
82 
83 
84 #endif
void reset()
Definition: FWEvePtr.h:59
void destroyElement()
Definition: FWEvePtr.h:66
T & operator*() const
Definition: FWEvePtr.h:45
void swap(FWEvePtr< T > &iOther)
Definition: FWEvePtr.h:71
void reset(T *iNew)
Definition: FWEvePtr.h:62
FWEvePtr()
Definition: FWEvePtr.h:34
boost::shared_ptr< TEveElement > m_container
Definition: FWEvePtr.h:80
FWEvePtr(T *iElement)
Definition: FWEvePtr.h:36
T * operator->() const
Definition: FWEvePtr.h:40