#include <Property.h>
Public Member Functions | |
ReadOnlyProperty ()=delete | |
nonvirtual T | Get () const |
nonvirtual | operator const T () const |
nonvirtual const T | operator() () const |
Implement C#-like syntax for read-only properties (syntactically like data members but backed by a getter function)
Note - unlike with functions - you cannot overload properties, making one return const T& and one return T&
Definition at line 128 of file Property.h.
|
delete |
ReadOnlyProperty are NOT movable, nor copy constructible: the data doesn't logically exist in the property itself, but in its relationship to some parent object; if it were copied, it might be copied TO some place that didn't have an appropriate enclosing object.
T Stroika::Foundation::Common::ReadOnlyProperty< T >::Get | ( | ) | const |
Returns the value of the given property T (by calling the underlying 'getter' for the property. This is a non-const method if PropertyCommon::kIsMutableType<T>, and otherwise a const method.
Definition at line 24 of file Property.inl.
Stroika::Foundation::Common::ReadOnlyProperty< T >::operator const T | ( | ) | const |
A ReadOnlyProperty can be automatically converted to its underlying base type. Due to how conversion operators work, this won't always be helpful (like with overloading or multiple levels of conversions, for example with optional<int> compare with int property). But when it works (80% of the time) - its helpful.
When it doesn't work, simply throw in '()' - to use the 'operator()' call, or call Get() if you prefer that syntax.
This is a non-const method if PropertyCommon::kIsMutableType<T>, and otherwise a const method.
Definition at line 36 of file Property.inl.
const T Stroika::Foundation::Common::ReadOnlyProperty< T >::operator() | ( | ) | const |
This works 100% of the time. Just use the function syntax, and you get back a copy of the desired underlying type.
This is a non-const method if PropertyCommon::kIsMutableType<T>, and otherwise a const method.
Definition at line 48 of file Property.inl.