AMSmartProperties  201
Core library
Classes | Enumerations | Functions
Smart properties

Easy way to make reposnsivity of properties. More...

Collaboration diagram for Smart properties:

Classes

class  AMSmartProperties::AMFunction< _Res(_ArgTypes ...)>
 AMSmartProperties::AMFunction is a function wrapper for smart properties. More...
 
class  AMSmartProperties::AMPropertyPool
 AMSmartProperties::AMPropertyPool is a property pool for smart properties. More...
 
class  AMSmartProperties::AMPropertyGeneralException
 Generic functor type for specified type of property. More...
 
class  AMSmartProperties::AMPropertyDeletedException
 This exception is thrown when compuded property depends on deleted property. More...
 
class  AMSmartProperties::AMPropertyLoopException
 This exception is thrown when loop is detected. More...
 
class  AMSmartProperties::AMPropertyNestingException
 This exception is thrown when too much properties was nested. More...
 
class  AMSmartProperties::AMPropertyBase
 Base interface and basic fuction for smart property. Most of these funcions can be used, whenever you have only reference to base class. But, in spite of this base class is not virtual, you can't instantiate it directly. More...
 
class  AMSmartProperties::AMPropertyNonBase
 "NULL" type class. Used by AMSmartProperties::AMProperty, when parent class is not defined. More...
 
class  AMSmartProperties::AMPropertyRefBase
 Smart property reference base class. More...
 
class  AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >
 Smart property class. More...
 

Enumerations

enum  AMSmartProperties::AMPropertyState {
  AMSmartProperties::NORMAL = 0, AMSmartProperties::COMPUTING = 1, AMSmartProperties::NOCOMPUTED = 2, AMSmartProperties::NOCOMPUTED_COMPUTING = 3,
  AMSmartProperties::VALUEONLY = 4, AMSmartProperties::VALUEONLY_COMPUTING = 5, AMSmartProperties::VALUEONLY_NOCOMPUTED = 6, AMSmartProperties::VALUEONLY_NOCOMPUTED_COMPUTING = 7,
  AMSmartProperties::MODIFIED = 8, AMSmartProperties::MODIFIED_COMPUTING = 9, AMSmartProperties::MODIFIED_NOCOMPUTED = 10, AMSmartProperties::MODIFIED_NOCOMPUTED_COMPUTING = 11,
  AMSmartProperties::MODIFIED_VALUEONLY = 12, AMSmartProperties::MODIFIED_VALUEONLY_COMPUTING = 13, AMSmartProperties::MODIFIED_VALUEONLY_NOCOMPUTED = 14, AMSmartProperties::MODIFIED_VALUEONLY_NOCOMPUTED_COMPUTING = 15,
  AMSmartProperties::DESTROYED_NORMAL = 16, AMSmartProperties::DESTROYED_COMPUTING = 17, AMSmartProperties::DESTROYED_NOCOMPUTED = 18, AMSmartProperties::DESTROYED_NOCOMPUTED_COMPUTING = 19,
  AMSmartProperties::DESTROYED_VALUEONLY = 20, AMSmartProperties::DESTROYED_VALUEONLY_COMPUTING = 21, AMSmartProperties::DESTROYED_VALUEONLY_NOCOMPUTED = 22, AMSmartProperties::DESTROYED_VALUEONLY_NOCOMPUTED_COMPUTING = 23,
  AMSmartProperties::DESTROYED_MODIFIED = 24, AMSmartProperties::DESTROYED_MODIFIED_COMPUTING = 25, AMSmartProperties::DESTROYED_MODIFIED_NOCOMPUTED = 26, AMSmartProperties::DESTROYED_MODIFIED_NOCOMPUTED_COMPUTING = 27,
  AMSmartProperties::DESTROYED_MODIFIED_VALUEONLY = 28, AMSmartProperties::DESTROYED_MODIFIED_VALUEONLY_COMPUTING = 29, AMSmartProperties::DESTROYED_MODIFIED_VALUEONLY_NOCOMPUTED = 30, AMSmartProperties::DESTROYED_MODIFIED_VALUEONLY_NOCOMPUTED_COMPUTING = 31
}
 Smart property state This is combined state for each property. Bits 3-4 are stored in AMSmartProperties::AMPropertyPool, bits 0-2 are stored on each property (AMSmartProperties::AMProperty) itself. More...
 

Functions

template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator== (const AMFunction< _Res(_Args ...)> &__f, std::nullptr_t) noexcept
 Compares an AMFunction target with nullptr. More...
 
template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator== (std::nullptr_t, const AMFunction< _Res(_Args ...)> &__f) noexcept
 Compares an AMFunction target with nullptr. More...
 
template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator!= (const AMFunction< _Res(_Args ...)> &__f, std::nullptr_t) noexcept
 Compares an AMFunction target with nullptr. More...
 
template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator!= (std::nullptr_t, const AMFunction< _Res(_Args ...)> &__f) noexcept
 Compares an AMFunction target with nullptr. More...
 
std::string AMSmartProperties::to_string (const AMPropertyState &state)
 Converts AMPropertyState to std::string. More...
 

Detailed Description

Easy way to make reposnsivity of properties.

Lets imagine, that ou have nad coord of some graphical item. For this example, it represents coords of button on the screen. Lets assign lambda function to this coord rather than float number. Now, you are able to signe simple formulat such as "parent width / 2 + 300px". Your view with button is now responsive.

Grouping

Smart properties are grouped into separate groups-pools represented by AMSmartProperties::AMPropertyPool class. It reduces CPU compution cost, because you typically need recompute only one group. CPU cost may grow quadratically in some case of usage. You may imagine properties as tree of SmartProperties properties with root window rect. Typically, this group is owned by one window.

Multi thread

Since Smart properties itself are not thread safe, Using pools allow to use in multithreaded environment. If every thread has its own separated polls, it may coexist simlutaneously and safe.

Nesting

Smart properties are designed also for nesting. For example, You shlould have smart property of type rect, which consists from smart properties origin and size, and origin consists of x,y and size consists from smart properties width, height. Subproperty has only reference to real type T, because generating any data strucures on type T is unwanted. So, there is two classes in this case. One is very simple type T, frees from any data structures related to Smart properties, and isolated class with definition of Smart subpropertes.

Smart properties lifecycle

When smart properties are set up. are a reset state, i.e. the first reading of the Smart property causes them to be executed. After the execution, the calculated value is placed into the variable. Each subsequent read then only reads this variable. There's one exception. If you save a value directly to the properties, it is copied to the variable and no calculation is should be carried out. Now the stored value is always read. And that's until you change the smart property. Smart property signals for the entire pool(AMSmartProperties::AMProperyPool) status modified. Smart properties on which Smart property depends can no longer be relied on, so the smart property must be recalculated and saved when read. Recomputing all variables on which the property may depend, it does not seem to make sense, so the calculation is calculated after each and for any reading from smart properties within the pool. It is now possible to perform a reset operation on the pool that sets up all smart properties in the pool stored. Life cycle returns to the beginning. It is advisable to perform the reset operation once per a certain time, preferably in the main thread loop.

Debugging smart properties

Also, smart properties has debugging capabilities. You can trace computing path after exception, give a text names to pointers (addresses of properties) and every property has function to_string. More at Smart properties debug.

Tutorial

Look at tutorial Smart Properties Tutorial.

Enumeration Type Documentation

◆ AMPropertyState

#include <include/AMSmartProperties/AMProperty.h>

Smart property state This is combined state for each property. Bits 3-4 are stored in AMSmartProperties::AMPropertyPool, bits 0-2 are stored on each property (AMSmartProperties::AMProperty) itself.

Enumerator
NORMAL 

NORMAL = 0x00 | 0x0 | 0x0

COMPUTING 

COMPUTING = 0x00 | 0x0 | 0x1

NOCOMPUTED 

NOCOMPUTED = 0x00 | 0x0 | 0x2

NOCOMPUTED_COMPUTING 

NOCOMPUTED_COMPUTING = 0x00 | 0x0 | 0x3

VALUEONLY 

VALUEONLY = 0x00 | 0x0 | 0x4

VALUEONLY_COMPUTING 

VALUEONLY_COMPUTING = 0x00 | 0x0 | 0x5

VALUEONLY_NOCOMPUTED 

VALUEONLY_NOCOMPUTED = 0x00 | 0x0 | 0x6

VALUEONLY_NOCOMPUTED_COMPUTING 

VALUEONLY_NOCOMPUTED_COMPUTING = 0x00 | 0x0 | 0x7

MODIFIED 

MODIFIED = 0x00 | 0x8 | 0x0

MODIFIED_COMPUTING 

MODIFIED_COMPUTING = 0x00 | 0x8 | 0x1

MODIFIED_NOCOMPUTED 

MODIFIED_NOCOMPUTED = 0x00 | 0x8 | 0x2

MODIFIED_NOCOMPUTED_COMPUTING 

MODIFIED_NOCOMPUTED_COMPUTING = 0x00 | 0x8 | 0x3

MODIFIED_VALUEONLY 

MODIFIED_VALUEONLY = 0x00 | 0x8 | 0x4

MODIFIED_VALUEONLY_COMPUTING 

MODIFIED_VALUEONLY_COMPUTING = 0x00 | 0x8 | 0x5

MODIFIED_VALUEONLY_NOCOMPUTED 

MODIFIED_VALUEONLY_NOCOMPUTED = 0x00 | 0x8 | 0x6

MODIFIED_VALUEONLY_NOCOMPUTED_COMPUTING 

MODIFIED_VALUEONLY_NOCOMPUTED_COMPUTING = 0x00 | 0x8 | 0x7

DESTROYED_NORMAL 

DESTROYED_NORMAL = 0x10 | 0x0 | 0x0

DESTROYED_COMPUTING 

DESTROYED_COMPUTING = 0x10 | 0x0 | 0x1

DESTROYED_NOCOMPUTED 

DESTROYED_NOCOMPUTED = 0x10 | 0x0 | 0x2

DESTROYED_NOCOMPUTED_COMPUTING 

DESTROYED_NOCOMPUTED_COMPUTING = 0x10 | 0x0 | 0x3

DESTROYED_VALUEONLY 

DESTROYED_VALUEONLY = 0x10 | 0x0 | 0x4

DESTROYED_VALUEONLY_COMPUTING 

DESTROYED_VALUEONLY_COMPUTING = 0x10 | 0x0 | 0x5

DESTROYED_VALUEONLY_NOCOMPUTED 

DESTROYED_VALUEONLY_NOCOMPUTED = 0x10 | 0x0 | 0x6

DESTROYED_VALUEONLY_NOCOMPUTED_COMPUTING 

DESTROYED_VALUEONLY_NOCOMPUTED_COMPUTING = 0x10 | 0x0 | 0x7

DESTROYED_MODIFIED 

DESTROYED_MODIFIED = 0x10 | 0x8 | 0x0

DESTROYED_MODIFIED_COMPUTING 

DESTROYED_MODIFIED_COMPUTING = 0x10 | 0x8 | 0x1

DESTROYED_MODIFIED_NOCOMPUTED 

DESTROYED_MODIFIED_NOCOMPUTED = 0x10 | 0x8 | 0x2

DESTROYED_MODIFIED_NOCOMPUTED_COMPUTING 

DESTROYED_MODIFIED_NOCOMPUTED_COMPUTING = 0x10 | 0x8 | 0x3

DESTROYED_MODIFIED_VALUEONLY 

DESTROYED_MODIFIED_VALUEONLY = 0x10 | 0x8 | 0x4

DESTROYED_MODIFIED_VALUEONLY_COMPUTING 

DESTROYED_MODIFIED_VALUEONLY_COMPUTING = 0x10 | 0x8 | 0x5

DESTROYED_MODIFIED_VALUEONLY_NOCOMPUTED 

DESTROYED_MODIFIED_VALUEONLY_NOCOMPUTED = 0x10 | 0x8 | 0x6

DESTROYED_MODIFIED_VALUEONLY_NOCOMPUTED_COMPUTING 

DESTROYED_MODIFIED_VALUEONLY_NOCOMPUTED_COMPUTING = 0x10 | 0x8 | 0x7

Function Documentation

◆ operator!=() [1/2]

template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator!= ( const AMFunction< _Res(_Args ...)> &  __f,
std::nullptr_t   
)
inlinenoexcept

#include <include/AMSmartProperties/AMFunction.h>

Compares an AMFunction target with nullptr.

Returns
false if the wrapper has no target, true otherwise
Exceptions
Thisfunction will not throw an exception.

◆ operator!=() [2/2]

template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator!= ( std::nullptr_t  ,
const AMFunction< _Res(_Args ...)> &  __f 
)
inlinenoexcept

#include <include/AMSmartProperties/AMFunction.h>

Compares an AMFunction target with nullptr.

Returns
false if the wrapper has no target, true otherwise
Exceptions
Thisfunction will not throw an exception.

◆ operator==() [1/2]

template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator== ( const AMFunction< _Res(_Args ...)> &  __f,
std::nullptr_t   
)
inlinenoexcept

#include <include/AMSmartProperties/AMFunction.h>

Compares an AMFunction target with nullptr.

Returns
true if the wrapper has no target, false otherwise
Exceptions
Thisfunction will not throw an exception.

◆ operator==() [2/2]

template<typename _Res , typename ... _Args>
bool AMSmartProperties::operator== ( std::nullptr_t  ,
const AMFunction< _Res(_Args ...)> &  __f 
)
inlinenoexcept

#include <include/AMSmartProperties/AMFunction.h>

Compares an AMFunction target with nullptr.

Returns
true if the wrapper has no target, false otherwise
Exceptions
Thisfunction will not throw an exception.

◆ to_string()

std::string AMSmartProperties::to_string ( const AMPropertyState &  state)

#include <include/AMSmartProperties/AMProperty.h>

Converts AMPropertyState to std::string.

Parameters
state
Returns
string with state

Referenced by AMSmartProperties::AMPropertyBase::getState(), and AMSmartProperties::AMProperty< T, TSubProperties, TParent, pointer_member >::to_string().