AMSmartProperties  201
Core library
Public Types | Public Member Functions | List of all members
AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member > Class Template Reference

Smart property class. More...

#include <AMProperty.h>

Inheritance diagram for AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >:
Inheritance graph
[legend]
Collaboration diagram for AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >:
Collaboration graph
[legend]

Public Types

typedef AMFunction< T()> type_fn
 Functor type for this property.
 

Public Member Functions

 AMProperty (AMPropertyPool &pool, T *const ptr)
 Constructor for subproperty. Do not use othervise. Suproperty has only reference to real type T. This should be only called from T subproperies class. More...
 
 AMProperty (AMPropertyPool &pool, const char *name=nullptr)
 "Default" constructor. More...
 
 AMProperty (AMPropertyPool &pool, T value, const char *name=nullptr)
 "Value" constructor. Every reading from property, returns this value. More...
 
constexpr AMProperty (AMPropertyPool &pool, type_fn f, const char *name=nullptr)
 "Functor" constructor. Every reading from property, returns result of this function. (i may be cached, ref: Smart properties) More...
 
 AMProperty (const AMProperty &other)
 "Copy" constructor. More...
 
constexpr AMProperty (AMProperty &&other)
 "Move" constructor. Smart roperty has not move constructor, due to composition. (All member are storaged inside smart property) More...
 
 ~AMProperty ()
 Destructor.
 
void setValueFn (const type_fn &_f)
 Copy functor into property. Do not use it directly..
 
void setValueFn (const type_fn &&_f)
 Move functor into property. Do not use it directly..
 
type_fn & getValueFn ()
 Get functor from property.
 
void setPool (AMPropertyPool &pool)
 Set Pool (AMSmartProperties::AMPropertyPool) You may reassign property to another pool(window), or inactives it(assign to AMSmartProperties::AMPropertyPool::defaultPool())
 
const T & getResult () const
 get last result. This function does not compute property. Consider use it directly.
 
void setResult (T value)
 set last result. This function does not compute property. Consider use it directly. Stored value will be there until next recompution.
 
constexpr TSubProperties * getSubProperties ()
 get subproperties. Consider use it directly.
 
bool isValueOnly () const
 test, if property has a constant value (functor is empty)
 
constexpr bool hasSubproperties () const
 test if proparty has subproperties.
 
T operator() ()
 returns a computed value. Freshly computed, or cached, in case of nothig is modified. More...
 
void compute ()
 computes result. Consider use it directly.
 
 operator const T & ()
 returns a computed value. Freshly computed, or cached, in case of nothig is modified. More...
 
const type_fn & operator= (const type_fn &right)
 Copy functor into property. More...
 
const type_fn & operator= (const type_fn &&right)
 Move functor into property. More...
 
const T & operator= (const T &right)
 set last result. This function does not compute property. Stored value will be there until next recompution. More...
 
constexpr TSubProperties * operator-> ()
 get subproperties.
 
T operator+ (const T &other)
 operator + computes a value and add it to right side parameter. More...
 
T operator- (const T &other)
 operator - computes a value and substract by right side parameter. More...
 
T operator* (const T &other)
 operator * computes a value and multiply by right side parameter. More...
 
T operator/ (const T &other)
 operator / computes a value and add divide by right side parameter. More...
 
T operator% (const T &other)
 operator % computes a value and add module by right side parameter. More...
 
T operator++ ()
 operator ++ computes a value and add increment it. Value does not store back! More...
 
T operator-- ()
 operator – computes a value and decrement it.Value does not store back! More...
 
void setDescription (const char *desc, const char *suffix)
 set description (variable names). Name consists from two equvalent parts. Reason for split is avoiding joining strings in case of varible names not active. More...
 
std::string to_string () const
 dumps a property info a std::string.
 
- Public Member Functions inherited from AMSmartProperties::AMPropertyBase
AMPropertyPool & getPool () const
 Get the pool assigned to property. More...
 
void setPool (AMPropertyPool &newPool)
 Move property from one pool to another. More...
 
AMPropertyBase * getNext () const
 Do not use it directly! More...
 
void resetState ()
 Reset state od property. This function is not intenden for use in common operation.
 
bool isNonComputed () const
 Information about property. More...
 
void setNoComputedFlag ()
 Information about property Set flag that property is not already computed. More...
 
void setNoComputed (bool noComputed)
 Information about property. More...
 
bool getComputingFlag ()
 Information about property. More...
 
bool isInProgress ()
 Information about property. More...
 
void runLoop ()
 Sets operation mode to loop. More...
 
void runDeleted ()
 Sets operation mode to deleted. It works, if current mode is normal. More...
 
AMPropertyState getState (AMPropertyState valueOnly) const
 Get state (AMSmartProperties::AMPropertyState) of property. Bits 0,1 comes from this property. Bit 2 is given from inherited class. Oher bits, 3,4 comes from AMSmartProperties::AMProperyPool. Warning! If parameter valueOnly has set any other bits than (0, AMPropertyState::VALUEONLY), result is undefined. More...
 
std::string to_string () const
 Debug helper. Simple dumps property into std::string. More...
 

Detailed Description

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
class AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >

Smart property class.

Parameters
T- type of property itself
TSubProperties- if AMSmartProperties::AMProperty<T> has nested subproperties, this associated subproperties class. Othervise T class.
TParent- if you intend have this property as subproperty os some parent and you want to acces it as parent.property, class of parent.
TTParent::*pointer_member - if you intend have this property as subproperty os some parent and you want to acces it as parent.property, poiner to member TParent::property.
Examples:
AMProperty_1.cpp, AMProperty_2.cpp, and AMProperty_3.cpp.

Constructor & Destructor Documentation

◆ AMProperty() [1/6]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::AMProperty ( AMPropertyPool &  pool,
T *const  ptr 
)
inline

Constructor for subproperty. Do not use othervise. Suproperty has only reference to real type T. This should be only called from T subproperies class.

Parameters
poolAMSmartProperties::AMPropertyPool.
ptr- pointer to real address of T within parent object.

◆ AMProperty() [2/6]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::AMProperty ( AMPropertyPool &  pool,
const char *  name = nullptr 
)
inline

"Default" constructor.

Parameters
poolAMSmartProperties::AMPropertyPool.
nameproperty name. Incase of AMSmartProperties::AMVariableNames is not enabled, it does nothing.

◆ AMProperty() [3/6]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::AMProperty ( AMPropertyPool &  pool,
T  value,
const char *  name = nullptr 
)
inline

"Value" constructor. Every reading from property, returns this value.

Parameters
poolAMSmartProperties::AMPropertyPool.
valueinitial value of type T.
nameproperty name. Incase of AMSmartProperties::AMVariableNames is not enabled, it does nothing.

◆ AMProperty() [4/6]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
constexpr AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::AMProperty ( AMPropertyPool &  pool,
type_fn  f,
const char *  name = nullptr 
)
inline

"Functor" constructor. Every reading from property, returns result of this function. (i may be cached, ref: Smart properties)

Parameters
poolAMSmartProperties::AMPropertyPool.
finitial functor of type AMSmartProperties::AMProperty::type_fn.
nameproperty name. Incase of AMSmartProperties::AMVariableNames is not enabled, it does nothing.

◆ AMProperty() [5/6]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::AMProperty ( const AMProperty< T, TSubProperties, TParent, pointer_member > &  other)
inline

"Copy" constructor.

Parameters
otherproperty copy from.

◆ AMProperty() [6/6]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
constexpr AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::AMProperty ( AMProperty< T, TSubProperties, TParent, pointer_member > &&  other)
inline

"Move" constructor. Smart roperty has not move constructor, due to composition. (All member are storaged inside smart property)

Parameters
otherproperty move from.

Member Function Documentation

◆ operator const T &()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator const T & ( )
inline

returns a computed value. Freshly computed, or cached, in case of nothig is modified.

Returns
T
Exceptions
maythwor and exception. (AMPropertyLoopException, AMPropertyNestingException, AMPropertyDeletedException)

◆ operator%()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator% ( const T &  other)
inline

operator % computes a value and add module by right side parameter.

Parameters
rightside
Returns
result

◆ operator()()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator() ( )
inline

returns a computed value. Freshly computed, or cached, in case of nothig is modified.

Returns
T
Exceptions
maythwor and exception. (AMPropertyLoopException, AMPropertyNestingException, AMPropertyDeletedException)

◆ operator*()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator* ( const T &  other)
inline

operator * computes a value and multiply by right side parameter.

Parameters
rightside
Returns
result

◆ operator+()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator+ ( const T &  other)
inline

operator + computes a value and add it to right side parameter.

Parameters
rightside
Returns
result

◆ operator++()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator++ ( )
inline

operator ++ computes a value and add increment it. Value does not store back!

Parameters
rightside
Returns
result

◆ operator-()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator- ( const T &  other)
inline

operator - computes a value and substract by right side parameter.

Parameters
rightside
Returns
result

◆ operator--()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator-- ( )
inline

operator – computes a value and decrement it.Value does not store back!

Parameters
rightside
Returns
result

◆ operator/()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
T AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator/ ( const T &  other)
inline

operator / computes a value and add divide by right side parameter.

Parameters
rightside
Returns
result

◆ operator=() [1/3]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
const type_fn& AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator= ( const type_fn &  right)
inline

Copy functor into property.

Parameters
newfunctor
Returns
new functor

◆ operator=() [2/3]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
const type_fn& AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator= ( const type_fn &&  right)
inline

Move functor into property.

Parameters
newfunctor
Returns
new functor

◆ operator=() [3/3]

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
const T& AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::operator= ( const T &  right)
inline

set last result. This function does not compute property. Stored value will be there until next recompution.

Parameters
constT right side
Returns
newly stored value

◆ setDescription()

template<typename T, typename TSubProperties = T, typename TParent = AMPropertyNonBase, T TParent::* pointer_member = nullptr>
void AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::setDescription ( const char *  desc,
const char *  suffix 
)
inline

set description (variable names). Name consists from two equvalent parts. Reason for split is avoiding joining strings in case of varible names not active.

Parameters
descfirst part of name
suffixsecond part of name

The documentation for this class was generated from the following file: