NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
SettingsValue Class Reference

This class represents a single abstract settings value implemented as void*. We're using asserts to avoid memory issues. Those won't trigger in release mode, of course. A setting value might either be a boolean, a unsigned int or a std::string. More...

#include <settings.hpp>

Collaboration diagram for SettingsValue:

Public Types

enum  SettingsValueType { TYPELESS , BOOL , UINT , STRING }
 The type of the setting value. More...
 
enum  SettingsValueProperties {
  NONE = 0x0 , SAVE = 0x1 , HIDDEN = 0x2 , PATH = 0x4 ,
  IMMUTABLE = 0x8 , UIREFRESH = 0x10
}
 Additional setting value properties. More...
 

Public Member Functions

 SettingsValue ()
 Default constructor. Creates an empty and typeless setting value. More...
 
 SettingsValue (bool value, int properties=SettingsValue::SAVE)
 Create a setting value from a boolean. More...
 
 SettingsValue (size_t value, size_t _min, size_t _max, int properties=SettingsValue::SAVE)
 Create a setting value from an unsigned integer and define its minimal and maximal possible values. More...
 
 SettingsValue (const char *value, int properties=SettingsValue::SAVE)
 Create a setting value from a const char*, represented as a std::string internally. More...
 
 SettingsValue (const std::string &value, int properties=SettingsValue::SAVE)
 Create a setting value from a std::string. More...
 
 ~SettingsValue ()
 Destructor. Will free the allocated memory. More...
 
 SettingsValue (const SettingsValue &value)
 Copy constructor. Creates a new instance and copies all contents. (Does not copy the pointers themselves, of course.) More...
 
SettingsValueoperator= (const SettingsValue &value)
 Assignment operator overload. Clears the contents of the assignee and takes the value and the type of the assigned value. More...
 
SettingsValueType getType () const
 Get the internal value type. More...
 
bool shallSave () const
 Returns, whether this is a setting value, which shall be saved to the configuration file. More...
 
bool isHidden () const
 Returns, whether this setting value is an internal-only setting and should not be presented to and modified by the user. More...
 
bool isPath () const
 Returns, whether this setting value represents a file path and a corresponding validation is necessary. More...
 
bool isMutable () const
 Returns, whether this setting value is mutable by the user in the terminal. More...
 
bool isUiModifying () const
 Returns true, when a setting modifies the graphical user interface and therefore needs to refresh it. More...
 
size_t min () const
 Returns the minimal value of an unsigned int value type. More...
 
size_t max () const
 Returns the maximal value of an unsigned int value type. More...
 
bool & active ()
 Returns a reference to a boolean value type setting. More...
 
size_t & value ()
 Returns a reference to an unsigned int value type setting. More...
 
std::string & stringval ()
 Returns a reference to a std::string value type setting. More...
 
bool active () const
 Returns the value of a boolean value type setting. More...
 
size_t value () const
 Returns the value of an unsigned int value type setting. More...
 
std::string stringval () const
 Returns the value of a std::string value type setting. More...
 

Private Member Functions

void assign (bool value)
 Assign a new boolean value to the internal memory. More...
 
void assign (size_t value)
 Assign a new unsigned int value to the internal memory. More...
 
void assign (const std::string &value)
 Assign a new std::string value to the internal memory. More...
 
void clear ()
 Clear the internal memory (called by the destructor, for example). More...
 

Private Attributes

void * m_value
 
SettingsValueType m_type
 
int m_valueProperties
 
size_t m_min
 
size_t m_max
 

Detailed Description

This class represents a single abstract settings value implemented as void*. We're using asserts to avoid memory issues. Those won't trigger in release mode, of course. A setting value might either be a boolean, a unsigned int or a std::string.

Definition at line 192 of file settings.hpp.

Member Enumeration Documentation

◆ SettingsValueProperties

Additional setting value properties.

Enumerator
NONE 
SAVE 
HIDDEN 
PATH 
IMMUTABLE 
UIREFRESH 

Definition at line 209 of file settings.hpp.

◆ SettingsValueType

The type of the setting value.

Enumerator
TYPELESS 
BOOL 
UINT 
STRING 

Definition at line 198 of file settings.hpp.

Constructor & Destructor Documentation

◆ SettingsValue() [1/6]

SettingsValue::SettingsValue ( )
inline

Default constructor. Creates an empty and typeless setting value.

Definition at line 304 of file settings.hpp.

◆ SettingsValue() [2/6]

SettingsValue::SettingsValue ( bool  value,
int  properties = SettingsValue::SAVE 
)
inlineexplicit

Create a setting value from a boolean.

Parameters
valuebool
propertiesint

Definition at line 313 of file settings.hpp.

References assign(), m_valueProperties, and value().

Here is the call graph for this function:

◆ SettingsValue() [3/6]

SettingsValue::SettingsValue ( size_t  value,
size_t  _min,
size_t  _max,
int  properties = SettingsValue::SAVE 
)
inline

Create a setting value from an unsigned integer and define its minimal and maximal possible values.

Parameters
valuesize_t
_minsize_t
_maxsize_t
propertiesint

Definition at line 330 of file settings.hpp.

References assign(), m_max, m_min, m_valueProperties, and value().

Here is the call graph for this function:

◆ SettingsValue() [4/6]

SettingsValue::SettingsValue ( const char *  value,
int  properties = SettingsValue::SAVE 
)
inlineexplicit

Create a setting value from a const char*, represented as a std::string internally.

Parameters
valueconst char*
propertiesint

Definition at line 346 of file settings.hpp.

References assign(), m_valueProperties, and value().

Here is the call graph for this function:

◆ SettingsValue() [5/6]

SettingsValue::SettingsValue ( const std::string &  value,
int  properties = SettingsValue::SAVE 
)
inline

Create a setting value from a std::string.

Parameters
valueconst std::string&
propertiesint

Definition at line 360 of file settings.hpp.

References assign(), m_valueProperties, and value().

Here is the call graph for this function:

◆ ~SettingsValue()

SettingsValue::~SettingsValue ( )
inline

Destructor. Will free the allocated memory.

Definition at line 370 of file settings.hpp.

References clear().

Here is the call graph for this function:

◆ SettingsValue() [6/6]

SettingsValue::SettingsValue ( const SettingsValue value)
inline

Copy constructor. Creates a new instance and copies all contents. (Does not copy the pointers themselves, of course.)

Parameters
valueconst SettingsValue&

Definition at line 383 of file settings.hpp.

References assign(), BOOL, m_max, m_min, m_valueProperties, STRING, TYPELESS, UINT, and value().

Here is the call graph for this function:

Member Function Documentation

◆ active() [1/2]

◆ active() [2/2]

bool SettingsValue::active ( ) const
inline

Returns the value of a boolean value type setting.

Returns
bool

Definition at line 607 of file settings.hpp.

References BOOL, m_type, m_value, and TYPELESS.

◆ assign() [1/3]

void SettingsValue::assign ( bool  value)
inlineprivate

Assign a new boolean value to the internal memory.

Parameters
valuebool
Returns
void

Definition at line 234 of file settings.hpp.

References BOOL, m_type, m_value, and value().

Referenced by operator=(), and SettingsValue().

Here is the call graph for this function:

◆ assign() [2/3]

void SettingsValue::assign ( const std::string &  value)
inlineprivate

Assign a new std::string value to the internal memory.

Parameters
valueconst std::string&
Returns
void

Definition at line 264 of file settings.hpp.

References m_type, m_value, STRING, and value().

Here is the call graph for this function:

◆ assign() [3/3]

void SettingsValue::assign ( size_t  value)
inlineprivate

Assign a new unsigned int value to the internal memory.

Parameters
valuesize_t
Returns
void

Definition at line 249 of file settings.hpp.

References m_type, m_value, UINT, and value().

Here is the call graph for this function:

◆ clear()

void SettingsValue::clear ( )
inlineprivate

Clear the internal memory (called by the destructor, for example).

Returns
void

Definition at line 278 of file settings.hpp.

References BOOL, m_type, m_value, STRING, TYPELESS, and UINT.

Referenced by operator=(), and ~SettingsValue().

◆ getType()

SettingsValueType SettingsValue::getType ( ) const
inline

Get the internal value type.

Returns
SettingsValueType

Definition at line 447 of file settings.hpp.

References m_type.

◆ isHidden()

bool SettingsValue::isHidden ( ) const
inline

Returns, whether this setting value is an internal-only setting and should not be presented to and modified by the user.

Returns
bool

Definition at line 473 of file settings.hpp.

References HIDDEN, and m_valueProperties.

◆ isMutable()

bool SettingsValue::isMutable ( ) const
inline

Returns, whether this setting value is mutable by the user in the terminal.

Returns
bool

Definition at line 501 of file settings.hpp.

References HIDDEN, IMMUTABLE, and m_valueProperties.

◆ isPath()

bool SettingsValue::isPath ( ) const
inline

Returns, whether this setting value represents a file path and a corresponding validation is necessary.

Returns
bool

Definition at line 486 of file settings.hpp.

References m_type, m_valueProperties, PATH, and STRING.

◆ isUiModifying()

bool SettingsValue::isUiModifying ( ) const
inline

Returns true, when a setting modifies the graphical user interface and therefore needs to refresh it.

Returns
bool

Definition at line 514 of file settings.hpp.

References m_valueProperties, and UIREFRESH.

◆ max()

size_t SettingsValue::max ( ) const
inline

Returns the maximal value of an unsigned int value type.

Returns
size_t

Definition at line 541 of file settings.hpp.

References m_max, m_type, and UINT.

◆ min()

size_t SettingsValue::min ( ) const
inline

Returns the minimal value of an unsigned int value type.

Returns
size_t

Definition at line 526 of file settings.hpp.

References m_min, m_type, and UINT.

◆ operator=()

SettingsValue & SettingsValue::operator= ( const SettingsValue value)
inline

Assignment operator overload. Clears the contents of the assignee and takes the value and the type of the assigned value.

Parameters
valueconst SettingsValue&
Returns
SettingsValue&
Remarks
Does change the internal value type, if necessary.

Definition at line 416 of file settings.hpp.

References assign(), BOOL, clear(), m_max, m_min, m_valueProperties, STRING, TYPELESS, UINT, and value().

Here is the call graph for this function:

◆ shallSave()

bool SettingsValue::shallSave ( ) const
inline

Returns, whether this is a setting value, which shall be saved to the configuration file.

Returns
bool

Definition at line 460 of file settings.hpp.

References m_valueProperties, and SAVE.

◆ stringval() [1/2]

std::string & SettingsValue::stringval ( )
inline

◆ stringval() [2/2]

std::string SettingsValue::stringval ( ) const
inline

Returns the value of a std::string value type setting.

Returns
std::string

Definition at line 641 of file settings.hpp.

References m_type, m_value, STRING, and TYPELESS.

◆ value() [1/2]

◆ value() [2/2]

size_t SettingsValue::value ( ) const
inline

Returns the value of an unsigned int value type setting.

Returns
size_t

Definition at line 624 of file settings.hpp.

References m_type, m_value, TYPELESS, and UINT.

Member Data Documentation

◆ m_max

size_t SettingsValue::m_max
private

Definition at line 224 of file settings.hpp.

Referenced by max(), operator=(), and SettingsValue().

◆ m_min

size_t SettingsValue::m_min
private

Definition at line 223 of file settings.hpp.

Referenced by min(), operator=(), and SettingsValue().

◆ m_type

SettingsValueType SettingsValue::m_type
private

Definition at line 221 of file settings.hpp.

Referenced by active(), assign(), clear(), getType(), isPath(), max(), min(), stringval(), and value().

◆ m_value

void* SettingsValue::m_value
private

Definition at line 220 of file settings.hpp.

Referenced by active(), assign(), clear(), stringval(), and value().

◆ m_valueProperties

int SettingsValue::m_valueProperties
private

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