Plasma Engine  2.0
Loading...
Searching...
No Matches
ObjectAccessorBase_inl.h
1#include <Foundation/Logging/Log.h>
2
3template <typename T>
4T plObjectAccessorBase::Get(const plDocumentObject* pObject, const plAbstractProperty* pProp, plVariant index /*= plVariant()*/)
5{
6 plVariant value;
7 plStatus res = GetValue(pObject, pProp, value, index);
8 if (res.m_Result.Failed())
9 plLog::Error("GetValue failed: {0}", res.m_sMessage);
10 return value.ConvertTo<T>();
11}
12
13template <typename T>
14T plObjectAccessorBase::Get(const plDocumentObject* pObject, plStringView sProp, plVariant index /*= plVariant()*/)
15{
16 plVariant value;
17 plStatus res = GetValue(pObject, sProp, value, index);
18 if (res.m_Result.Failed())
19 plLog::Error("GetValue failed: {0}", res.m_sMessage);
20 return value.ConvertTo<T>();
21}
22
23inline plInt32 plObjectAccessorBase::GetCount(const plDocumentObject* pObject, const plAbstractProperty* pProp)
24{
25 plInt32 iCount = 0;
26 plStatus res = GetCount(pObject, pProp, iCount);
27 if (res.m_Result.Failed())
28 plLog::Error("GetCount failed: {0}", res.m_sMessage);
29 return iCount;
30}
31
32inline plInt32 plObjectAccessorBase::GetCount(const plDocumentObject* pObject, plStringView sProp)
33{
34 plInt32 iCount = 0;
35 plStatus res = GetCount(pObject, sProp, iCount);
36 if (res.m_Result.Failed())
37 plLog::Error("GetCount failed: {0}", res.m_sMessage);
38 return iCount;
39}
This is the base interface for all properties in the reflection system. It provides enough informatio...
Definition AbstractProperty.h:150
Definition DocumentObjectBase.h:11
static void Error(plLogInterface *pInterface, const plFormatString &string)
An error that needs to be fixed as soon as possible.
Definition Log.cpp:375
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
T ConvertTo(plResult *out_pConversionStatus=nullptr) const
Tries to convert the stored value to the given type. The optional status parameter can be used to che...
Definition Variant_inl.h:421
An plResult with an additional message for the reason of failure.
Definition Status.h:12