8 #ifndef META_OCEAN_BASE_SMART_OBJECT_REF_H
9 #define META_OCEAN_BASE_SMART_OBJECT_REF_H
88 template <
typename T,
typename TBase>
143 template <
typename T2>
199 template <
typename T,
typename TBase>
201 ObjectRef<TBase>(dynamic_cast<TBase*>(object))
209 template <
typename T,
typename TBase>
211 ObjectRef<TBase>(dynamic_cast<TBase*>(object, releaseCallback))
219 template <
typename T,
typename TBase>
234 template <
typename T,
typename TBase>
238 if (smartObjectRef.objectPointer_ !=
nullptr)
243 smartObjectRef.objectPointer_ =
nullptr;
244 smartObjectRef.objectHolder_ =
nullptr;
248 template <
typename T,
typename TBase>
263 template <
typename T,
typename TBase>
264 template <
typename T2>
279 template <
typename T,
typename TBase>
282 if (
this != &smartObjectRef)
286 ocean_assert(objectPointer_ !=
nullptr);
290 objectPointer_ =
nullptr;
293 ocean_assert(objectPointer_ ==
nullptr);
305 template <
typename T,
typename TBase>
308 if (
this != &smartObjectRef)
312 ocean_assert(objectPointer_);
316 objectPointer_ =
nullptr;
319 ocean_assert(objectPointer_ ==
nullptr);
321 objectPointer_ = smartObjectRef.objectPointer_;
324 smartObjectRef.objectPointer_ =
nullptr;
325 smartObjectRef.objectHolder_ =
nullptr;
331 template <
typename T,
typename TBase>
336 ocean_assert(objectPointer_ !=
nullptr);
340 objectPointer_ =
nullptr;
345 objectPointer_ =
dynamic_cast<T*
>(&*objectRef);
347 if (objectPointer_ !=
nullptr)
356 template <
typename T,
typename TBase>
360 objectPointer_ =
nullptr;
363 template <
typename T,
typename TBase>
366 return objectPointer_;
369 template <
typename T,
typename TBase>
372 ocean_assert(objectPointer_ !=
nullptr);
374 return objectPointer_;
377 template <
typename T,
typename TBase>
380 ocean_assert(objectPointer_ !=
nullptr);
382 return *objectPointer_;
This class implements a container for callback functions.
Definition: Callback.h:3456
This template class implements a object reference with an internal reference counter.
Definition: base/ObjectRef.h:58
ObjectHolder * objectHolder_
Pointer to the object holder.
Definition: base/ObjectRef.h:262
void release()
Releases the internal object, if any.
Definition: base/ObjectRef.h:407
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
SmartObjectRef(SmartObjectRef< T, TBase > &&smartObjectRef)
Move constructor.
Definition: SmartObjectRef.h:235
SmartObjectRef< T, TBase > & operator=(const SmartObjectRef< T, TBase > &smartObjectRef)
Assign operator.
Definition: SmartObjectRef.h:280
T * objectPointer_
Pointer to the internal object.
Definition: SmartObjectRef.h:196
SmartObjectRef< T, TBase > & operator=(SmartObjectRef< T, TBase > &&smartObjectRef)
Moves a smart object reference object to this smart object reference.
Definition: SmartObjectRef.h:306
T & operator*() const
Returns a reference to the internal object if existing.
Definition: SmartObjectRef.h:378
ObjectRef< TBase >::ReleaseCallback ReleaseCallback
Redefinition of the release callback function defined in ObjectRef.
Definition: SmartObjectRef.h:96
SmartObjectRef(T *object)
Creates a new SmartObjectRef by a given object.
Definition: SmartObjectRef.h:200
T * operator->() const
Returns a point to the internal object if existing.
Definition: SmartObjectRef.h:370
SmartObjectRef< T, TBase > & operator=(const ObjectRef< TBase > &objectRef)
Assigns a ObjectRef to this smart object reference.
Definition: SmartObjectRef.h:332
SmartObjectRef(const SmartObjectRef< T, TBase > &smartObjectRef)
Copy constructor.
Definition: SmartObjectRef.h:220
SmartObjectRef(T *object, const ReleaseCallback &releaseCallback)
Creates a new SmartObjectRef by a given object.
Definition: SmartObjectRef.h:210
T * pointer() const
Returns a pointer to the objects that is encapsulated by this wrapper.
Definition: SmartObjectRef.h:364
SmartObjectRef(const ObjectRef< TBase > &objectRef)
Creates a new SmartObjectRef by a given ObjectRef.
Definition: SmartObjectRef.h:249
SmartObjectRef()=default
Creates a new SmartObjectRef with no internal object.
void release()
Releases the internal object, if any.
Definition: SmartObjectRef.h:357
SmartObjectRef(const SmartObjectRef< T2, TBase > &smartObjectRef)
Copies a SmartObjectRef object.
Definition: SmartObjectRef.h:265
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15