ActiveLib
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
active::setting::Value Class Referenceabstract

#include <Value.h>

Inheritance diagram for active::setting::Value:
Inheritance graph
[legend]
Collaboration diagram for active::setting::Value:
Collaboration graph
[legend]

Public Types

enum class  Status { undefined = 0 , bad , good }
 The value status (defines whether a value has been explicitly set and (if so) if it's meaningful.
 
enum class  Type {
  null = 0 , boolType , idType , intType ,
  floatType , stringType , timeType
}
 Supported value types (broad groups, e.g. int32_t and int64_t are both intType)
 
using Unique = std::unique_ptr<Value>
 Unique pointer.
 
using Shared = std::shared_ptr<Value>
 Shared pointer.
 
using Option = std::optional<Value>
 Optional.
 

Public Member Functions

 Value (Status stat=good)
 
virtual ~Value ()=default
 
virtual ValueclonePtr () const override=0
 
virtual bool operator== (const Value &ref) const =0
 
bool operator!= (const Value &ref) const
 
virtual bool operator< (const Value &ref) const =0
 
virtual Valueoperator= (const Value &val)=0
 
virtual Valueoperator= (bool val)=0
 
virtual Valueoperator= (int32_t val)=0
 
virtual Valueoperator= (uint32_t val)=0
 
virtual Valueoperator= (int64_t val)=0
 
virtual Valueoperator= (double val)=0
 
virtual Valueoperator= (const active::utility::String &val)=0
 
virtual Valueoperator= (const char *val)
 
virtual Valueoperator= (const active::utility::Guid &val)=0
 
virtual Valueoperator= (const active::utility::Time &val)=0
 
virtual operator bool () const =0
 
virtual operator int32_t () const =0
 
virtual operator uint32_t () const =0
 
virtual operator int64_t () const =0
 
virtual operator double () const =0
 
virtual operator active::utility::String () const =0
 
virtual operator active::utility::Guid () const =0
 
virtual operator active::utility::Time () const =0
 
virtual bool isGood () const
 
virtual bool isNull () const =0
 
virtual Type getType () const =0
 
virtual void setDefault ()=0
 
- Public Member Functions inherited from active::utility::Cloner
virtual ~Cloner ()=default
 

Static Public Member Functions

static std::optional< TypetypeFromName (const utility::String &text)
 
static utility::String nameForType (Type type)
 

Public Attributes

Status status
 The value status.
 

Detailed Description

Base class for all single-item values

This base class essentially anonymises the value type, allowing a setting sender and receiver to work with the type it expects, e.g. a sender may have numeric value that the receiver will display as a string. This helps facilitate loose coupling between modules. Settings/parameters can share a common identity, but the senders/receivers of these values do not need a shared understanding of value types, formatting or purpose (which may vary if there are multiple receivers). This is particulary relevant to the UI, where the app business logic understands value types and formatting, but the UI must facilitate display/entry of values. The UI code can read/write to the value as a string irrespective of its internal type and allow the Value to validate user entry (meaning that no business logic for the value type is replicated or exposed in the UI code).

There are many other uses for this type abstraction, e.g. data passed with an Event to Subscribers.

Subclasses should override the following functions as appropriate

Constructor & Destructor Documentation

◆ Value()

active::setting::Value::Value ( Status stat = good)
inline

Default constructor

Parameters
statThe value status

◆ ~Value()

virtual active::setting::Value::~Value ( )
virtualdefault

Destructor

Member Function Documentation

◆ clonePtr()

virtual Value * active::setting::Value::clonePtr ( ) const
overridepure virtual

Clone method

Returns
A clone of this object

Implements active::utility::Cloner.

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ getType()

virtual Type active::setting::Value::getType ( ) const
pure virtual

Get the value type

Returns
The value type

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ isGood()

virtual bool active::setting::Value::isGood ( ) const
inlinevirtual

Determine if the value has a good status

Returns
True if the status is good
Here is the caller graph for this function:

◆ isNull()

virtual bool active::setting::Value::isNull ( ) const
pure virtual

Determine if the value is null, e.g. zero, empty, undefined

Returns
True if the value is null

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

Here is the caller graph for this function:

◆ nameForType()

String Value::nameForType ( Value::Type type)
static

Get the text for a Value::Type

Parameters
typeThe incoming type
Returns
The type name as text
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator active::utility::Guid()

virtual active::setting::Value::operator active::utility::Guid ( ) const
pure virtual

Get a guid value

Returns
A guid value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator active::utility::String()

virtual active::setting::Value::operator active::utility::String ( ) const
pure virtual

Get a string value

Returns
A string value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator active::utility::Time()

virtual active::setting::Value::operator active::utility::Time ( ) const
pure virtual

Get a time value

Returns
A time value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator bool()

virtual active::setting::Value::operator bool ( ) const
pure virtual

Get a boolean value

Returns
A boolean value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator double()

virtual active::setting::Value::operator double ( ) const
pure virtual

Get a double precision value

Returns
A double precision value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator int32_t()

virtual active::setting::Value::operator int32_t ( ) const
pure virtual

Get a 32-bit integer value

Returns
A 32-bit integer value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator int64_t()

virtual active::setting::Value::operator int64_t ( ) const
pure virtual

Get a 64-bit integer value

Returns
A 64-bit integer value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator uint32_t()

virtual active::setting::Value::operator uint32_t ( ) const
pure virtual

Get an unsigned 32-bit integer value

Returns
An unsigned 32-bit integer value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator!=()

bool active::setting::Value::operator!= ( const Value & ref) const
inline

Inequality operator

Parameters
refA value to compare with this
Returns
True if this is not identical to ref

◆ operator<()

virtual bool active::setting::Value::operator< ( const Value & ref) const
pure virtual

Less-than operator

Parameters
refA value to compare with this
Returns
True if this is less than ref

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [1/10]

virtual Value & active::setting::Value::operator= ( bool val)
pure virtual

Assignment operator

Parameters
valA boolean value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [2/10]

virtual Value & active::setting::Value::operator= ( const active::utility::Guid & val)
pure virtual

Assignment operator

Parameters
valA guid value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [3/10]

virtual Value & active::setting::Value::operator= ( const active::utility::String & val)
pure virtual

◆ operator=() [4/10]

virtual Value & active::setting::Value::operator= ( const active::utility::Time & val)
pure virtual

Assignment operator

Parameters
valA time value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [5/10]

virtual Value & active::setting::Value::operator= ( const char * val)
inlinevirtual

Assignment operator

Parameters
valA string value to assign
Returns
A reference to this

Reimplemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, and active::setting::ValueBase< T >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [6/10]

virtual Value & active::setting::Value::operator= ( const Value & val)
pure virtual

◆ operator=() [7/10]

virtual Value & active::setting::Value::operator= ( double val)
pure virtual

Assignment operator

Parameters
valA double precision value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [8/10]

virtual Value & active::setting::Value::operator= ( int32_t val)
pure virtual

Assignment operator

Parameters
valA 32-bit integer value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [9/10]

virtual Value & active::setting::Value::operator= ( int64_t val)
pure virtual

Assignment operator

Parameters
valA 64-bit integer value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator=() [10/10]

virtual Value & active::setting::Value::operator= ( uint32_t val)
pure virtual

Assignment operator

Parameters
valAn unsigned 32-bit integer value to assign
Returns
A reference to this

Implemented in active::setting::MeasuredValue< T >, active::setting::MeasuredValue< active::measure::AngleUnit >, active::setting::NullValue, and active::setting::ValueBase< T >.

◆ operator==()

virtual bool active::setting::Value::operator== ( const Value & ref) const
pure virtual

Equality operator

Parameters
refA value to compare with this
Returns
True if this is identical to ref

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ setDefault()

virtual void active::setting::Value::setDefault ( )
pure virtual

Set a default value

Implemented in active::setting::NullValue, and active::setting::ValueBase< T >.

◆ typeFromName()

std::optional< Value::Type > Value::typeFromName ( const utility::String & text)
static

Get a Value::Type enumerator from text

Parameters
textThe incoming text
Returns
The equivalent type (nullopt on failure)

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