Wrapper to manipulate user objects in the Ponder system.
More...
#include <userobject.hpp>
|
template<typename T > |
static UserObject | makeRef (T &object) |
| Construct a user object from a reference to an object. More...
|
|
template<typename T > |
static UserObject | makeRef (T *object) |
| Construct a user object from a const reference to an object. More...
|
|
template<typename T > |
static UserObject | makeCopy (const T &object) |
| Construct a user object with a copy of an object. More...
|
|
template<typename T > |
static UserObject | makeOwned (T &&object) |
|
Wrapper to manipulate user objects in the Ponder system.
ponder::UserObject is an abstract representation of object instances, which can safely be passed to and manipulated by all the entities in Ponder.
- Note
- UserObjects are stored interally as objects (a copy) or references (an existing object). To be sure which you are constructing use UserObject::makeRef() or UserObject::makeCopy().
- See also
- EnumObject
◆ UserObject() [1/5]
ponder::UserObject::UserObject |
( |
| ) |
|
Default constructor.
Constructs an empty/invalid object
◆ UserObject() [2/5]
ponder::UserObject::UserObject |
( |
const UserObject & |
other | ) |
|
Copy constructor.
- Parameters
-
◆ UserObject() [3/5]
ponder::UserObject::UserObject |
( |
UserObject && |
other | ) |
|
|
noexcept |
Move constructor.
- Parameters
-
◆ UserObject() [4/5]
template<typename T >
ponder::UserObject::UserObject |
( |
const T & |
object | ) |
|
Construct the user object from an instance copy.
- Parameters
-
object | Instance to store in the user object |
- See also
- makeRef(), makeCopy()
◆ UserObject() [5/5]
template<typename T >
ponder::UserObject::UserObject |
( |
T * |
object | ) |
|
Construct the user object from an instance reference.
- Parameters
-
object | Pointer to the object to reference in the user object |
- See also
- makeRef(), makeCopy()
◆ cref()
template<typename T >
const T& ponder::UserObject::cref |
( |
| ) |
const |
Get a const reference to the object data contained.
Returns a const reference to the contained object, of type T. The user is responsible for ensuring that the type passed is correct. See ref() for non-const ref.
- Returns
- A const reference to the contained object.
◆ get() [1/3]
template<typename T >
detail::TypeTraits<T>::ReferenceType ponder::UserObject::get |
( |
| ) |
const |
Retrieve the instance stored in the user object.
The template parameter T is the type to convert the instance to. T must be compatible with the original type of the instance.
- Returns
- Reference to the instance of the stored object
- Exceptions
-
◆ get() [2/3]
Value ponder::UserObject::get |
( |
IdRef |
property | ) |
const |
Get the value of an object's property by name.
This function is defined for convenience, it is a shortcut for object.getClass().property(name).get(object);
- Parameters
-
property | Name of the property to get |
- Returns
- Current value of the property
- Exceptions
-
◆ get() [3/3]
Value ponder::UserObject::get |
( |
size_t |
index | ) |
const |
Get the value of an object's property by index.
This function is defined for convenience, it is a shortcut for object.getClass().property(index).get(object);
- Parameters
-
index | Index of the property to get |
- Returns
- Current value of the property
- Exceptions
-
◆ getClass()
const Class& ponder::UserObject::getClass |
( |
| ) |
const |
Retrieve the metaclass of the stored instance.
- Returns
- Reference to the instance's metaclass
- Exceptions
-
◆ makeCopy()
template<typename T >
static UserObject ponder::UserObject::makeCopy |
( |
const T & |
object | ) |
|
|
static |
Construct a user object with a copy of an object.
This functions is not equivalent to calling UserObject(object).
- Parameters
-
object | Instance to store in the user object |
- Returns
- UserObject containing a copy of object
◆ makeRef() [1/2]
template<typename T >
static UserObject ponder::UserObject::makeRef |
( |
T & |
object | ) |
|
|
static |
Construct a user object from a reference to an object.
This functions is equivalent to calling UserObject(&object)
.
- Parameters
-
object | Instance to store in the user object |
- Returns
- UserObject containing a reference to object
◆ makeRef() [2/2]
template<typename T >
static UserObject ponder::UserObject::makeRef |
( |
T * |
object | ) |
|
|
static |
Construct a user object from a const reference to an object.
This functions is equivalent to calling UserObject(&object)
.
- Parameters
-
object | Instance to store in the user object |
- Returns
- UserObject containing a const reference to object
◆ operator!=()
bool ponder::UserObject::operator!= |
( |
const UserObject & |
other | ) |
const |
|
inline |
Operator != to compare inequality between two user objects.
- See also
- operator ==
◆ operator<()
bool ponder::UserObject::operator< |
( |
const UserObject & |
other | ) |
const |
Operator < to compare two user objects.
- Parameters
-
other | User object to compare with this |
- Returns
- True if this < other
◆ operator=() [1/2]
Copy assignment operator.
- Parameters
-
other | User object to assign |
- Returns
- Reference to this
◆ operator=() [2/2]
Move assignment operator.
- Parameters
-
other | User object to assign |
- Returns
- Reference to this
◆ operator==()
bool ponder::UserObject::operator== |
( |
const UserObject & |
other | ) |
const |
Operator == to compare equality between two user objects.
Two user objects are equal if their metaclasses and pointers are both equal, i.e. they point to the same object, not if the object values are the same.
- Parameters
-
other | User object to compare with this |
- Returns
- True if both user objects are the same, false otherwise
◆ pointer()
void* ponder::UserObject::pointer |
( |
| ) |
const |
Retrieve the address of the stored object.
This function must be used with caution, as the returned address may not be what you expect it to be!
- Returns
- Pointer to the stored object
◆ ref()
template<typename T >
T& ponder::UserObject::ref |
( |
| ) |
const |
Get a non-const reference to the object data contained.
Returns a reference to the contained object, of type T. The user is responsible for ensuring that the type passed is correct. See cref() for const ref.
- Returns
- A reference to the contained object.
◆ set() [1/2]
void ponder::UserObject::set |
( |
IdRef |
property, |
|
|
const Value & |
value |
|
) |
| const |
Set the value of an object's property by name.
This function is defined for convenience, it is a shortcut for object.getClass().property(name).set(object, value);
- Parameters
-
property | Name of the property to set |
value | Value to set |
- Exceptions
-
◆ set() [2/2]
void ponder::UserObject::set |
( |
size_t |
index, |
|
|
const Value & |
value |
|
) |
| const |
Set the value of an object's property by index.
This function is defined for convenience, it is a shortcut for object.getClass().property(index).set(object, value);
- Parameters
-
index | Index of the property to set |
value | Value to set |
- Exceptions
-
The documentation for this class was generated from the following file:
- include/ponder/userobject.hpp