8 #ifndef ATLAS_OBJECTS_SMARTPTR_H 9 #define ATLAS_OBJECTS_SMARTPTR_H 11 #include <Atlas/Exception.h> 13 namespace Atlas {
namespace Objects {
27 template<
class U>
friend 32 typedef typename T::iterator iterator;
33 typedef typename T::const_iterator const_iterator;
35 SmartPtr() : ptr(T::allocator.alloc()) {
47 template<
class oldType>
51 template<
class oldType>
59 if (a.get() != this->
get()) {
66 template<
class newType>
70 template<
class newType>
74 bool isValid()
const {
75 return ptr !=
nullptr;
77 bool operator!()
const noexcept {
78 return this->ptr ==
nullptr;
81 explicit operator bool ()
const noexcept
83 return !this->operator!();
86 T& operator*()
const {
92 T* operator->()
const {
111 void decRef()
const {
112 if (ptr !=
nullptr) {
116 void incRef()
const {
117 if (ptr !=
nullptr) {
124 template<
typename returnPtrType,
class fromType>
127 return returnPtrType(dynamic_cast<typename returnPtrType::DataT*>(o.get()));
130 template<
typename returnPtrType,
class fromType>
133 return returnPtrType((
typename returnPtrType::DataT *)o.get());
138 #endif // ATLAS_OBJECTS_SMARTPTR_H The Atlas namespace.
Definition: Bridge.h:20
Definition: SmartPtr.h:15
Base class for all exceptions thrown by Atlas-C++.
Definition: Exception.h:17