CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Core/interface/FWEvePtr.h

Go to the documentation of this file.
00001 #ifndef Fireworks_Core_FWEvePtr_h
00002 #define Fireworks_Core_FWEvePtr_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Core
00006 // Class  :     FWEvePtr
00007 //
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Wed Nov 12 11:08:49 EST 2008
00019 // $Id: FWEvePtr.h,v 1.2 2009/01/23 21:35:41 amraktad Exp $
00020 //
00021 
00022 // system include files
00023 #include <boost/shared_ptr.hpp>
00024 #include "TEveElement.h"
00025 
00026 // user include files
00027 
00028 // forward declarations
00029 
00030 template < typename T>
00031 class FWEvePtr {
00032 
00033 public:
00034    FWEvePtr() {
00035    }
00036    explicit FWEvePtr(T* iElement) : m_container(new TEveElementList()) {
00037       m_container->AddElement(iElement);
00038    }
00039    // ---------- const member functions ---------------------
00040    T* operator->() const {
00041       return m_container && m_container->HasChildren() ?
00042              static_cast<T*>(m_container->FirstChild()) :
00043              static_cast<T*>(0);
00044    }
00045    T& operator*() const {
00046       return *(operator->());
00047    }
00048 
00049    T* get() const {
00050       return (operator->());
00051    }
00052 
00053    operator bool() const {
00054       return m_container && m_container->HasChildren();
00055    }
00056    // ---------- static member functions --------------------
00057 
00058    // ---------- member functions ---------------------------
00059    void reset() {
00060       m_container.reset();
00061    }
00062    void reset(T* iNew) {
00063       FWEvePtr<T> temp(iNew);
00064       swap(temp);
00065    }
00066    void destroyElement() {
00067       if(m_container) {m_container->DestroyElements();}
00068       reset();
00069    }
00070 
00071    void swap(FWEvePtr<T>& iOther) {
00072       m_container.swap(iOther.m_container);
00073    }
00074 private:
00075    //FWEvePtr(const FWEvePtr&); // stop default
00076 
00077    //const FWEvePtr& operator=(const FWEvePtr&); // stop default
00078 
00079    // ---------- member data --------------------------------
00080    boost::shared_ptr<TEveElement> m_container;
00081 };
00082 
00083 
00084 #endif