Apama
10.0.0.2
|
A wrapper type for holding arbitrary objects inside a data_t. More...
#include <custom_t.hpp>
Inherits sag_underlying_custom_t.
Public Member Functions | |
custom_t () | |
Create an empty custom_t. More... | |
custom_t (T *payload) | |
Create a custom_t which owns the given payload. More... | |
~custom_t () | |
deletes the underlying pointer. More... | |
T * | get () const |
Return the wrapped pointer as the correct type. More... | |
custom_t (custom_t &&other) | |
Move constructor. More... | |
custom_t & | operator= (custom_t &&other) |
Move assignment, destroying the current contents. More... | |
void | swap (custom_t &&other) |
Swap with another custom_t of the same type. More... | |
custom_t | copy () const |
Return a copy of the underlying pointer. More... | |
T & | operator* () const |
Return the wrapped pointer as the correct type. More... | |
T * | operator-> () const |
Return the wrapped pointer as the correct type. More... | |
A wrapper type for holding arbitrary objects inside a data_t.
It behaves like a std::unique_ptr with an explict copy method and will delete the contents when destroyed unless they are moved out first.
The wrapped class must have a nothrow destructor and a nothrow copy constructor.
You must ensure that you extract your object with the same type that was inserted, or the behaviour is undefined. If you have a hierarchy of objects and you need to determine the type at runtime then you must extract as a custom_t<BaseClass> and then dynamic_cast or call virtual methods to determine the type. This means you must have a virtual hierarchy of objects.
This can be used with get<> or get_custom<> to retrieve the contents of a data_t:
get<custom_t<MyClass> >(data); get_custom<MyClass>(data);
however visitors will still visit a sag_underlying_custom_t& which can be cast to a custom_t<MyClass>&.
Create a custom_t which owns the given payload.
Return a copy of the underlying pointer.
|
inline |
Return the wrapped pointer as the correct type.
|
inline |
Return the wrapped pointer as the correct type.
|
inline |
Return the wrapped pointer as the correct type.
Move assignment, destroying the current contents.
Swap with another custom_t of the same type.