File indexing completed on 2024-04-06 12:11:31
0001 #ifndef Fireworks_Core_FWEvePtr_h
0002 #define Fireworks_Core_FWEvePtr_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <memory>
0023 #include "TEveElement.h"
0024
0025
0026
0027
0028
0029 template <typename T>
0030 class FWEvePtr {
0031 public:
0032 FWEvePtr() {}
0033 explicit FWEvePtr(T* iElement) : m_container(new TEveElementList()) { m_container->AddElement(iElement); }
0034
0035 T* operator->() const {
0036 return m_container && m_container->HasChildren() ? static_cast<T*>(m_container->FirstChild()) : static_cast<T*>(0);
0037 }
0038 T& operator*() const { return *(operator->()); }
0039
0040 T* get() const { return (operator->()); }
0041
0042 operator bool() const { return m_container && m_container->HasChildren(); }
0043
0044
0045
0046 void reset() { m_container.reset(); }
0047 void reset(T* iNew) {
0048 FWEvePtr<T> temp(iNew);
0049 swap(temp);
0050 }
0051 void destroyElement() {
0052 if (m_container) {
0053 m_container->DestroyElements();
0054 }
0055 reset();
0056 }
0057
0058 void swap(FWEvePtr<T>& iOther) { m_container.swap(iOther.m_container); }
0059
0060 private:
0061
0062
0063
0064
0065
0066 std::shared_ptr<TEveElement> m_container;
0067 };
0068
0069 #endif