Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::Setting< std::atomic< T > > Class Template Reference

Specialize for std::atomic types. More...

#include "setting.h"

Inheritance diagram for ion::base::Setting< std::atomic< T > >:
Collaboration diagram for ion::base::Setting< std::atomic< T > >:

Public Types

typedef std::function< void(SettingBase
*setting)> 
Listener
 A function that is called when the value changes. More...
 

Public Member Functions

 Setting (const std::string &name, const T &value, const std::string &doc_string)
 Creates a new setting with the passed name, initial value, and documentation string. More...
 
 Setting (const SettingGroup *group, const std::string &name, const T &value, const std::string &doc_string)
 Same as above, but places the setting in the passed group. More...
 
 Setting (const std::string &name, const T &value)
 Convenience constructor that does not require a documentation string. More...
 
 Setting (const SettingGroup *group, const std::string &name, const T &value)
 Same as above, but places the setting in the passed group. More...
 
 ~Setting () override
 
const std::string ToString () const override
 Returns a string version of this setting. More...
 
bool FromString (const std::string &str) override
 Parses the passed string to set the value of this and returns whether the parsing was successful. More...
 
std::atomic< T > * GetMutableValue ()
 Direct value mutators. More...
 
const std::atomic< T > & GetValue () const
 
void SetValue (const T &value)
 
 operator T () const
 
void operator= (const T &value)
 
bool operator== (const T &value) const
 Equality testers. More...
 
const std::string & GetName () const
 Returns the name associated with this. More...
 
const std::string & GetDocString () const
 Returns the documentation string associated with this. More...
 
void SetTypeDescriptor (const std::string &desc)
 Sets/returns a string containing information about the Setting's type. More...
 
const std::string & GetTypeDescriptor () const
 
void RegisterListener (const std::string &key, const Listener &listener)
 Adds a function that will be called when this setting's value changes. More...
 
void EnableListener (const std::string &key, bool enable)
 Enables or disables the listener identified by key, if one exists. More...
 
void UnregisterListener (const std::string &key)
 Removes the listener identified by key, if one exists. More...
 
void NotifyListeners ()
 Notify listeners that this setting has changed. More...
 

Friends

bool operator== (const T &value, const Setting< std::atomic< T > > &setting)
 

Detailed Description

template<typename T>
class ion::base::Setting< std::atomic< T > >

Specialize for std::atomic types.

Definition at line 227 of file setting.h.

Member Typedef Documentation

typedef std::function<void(SettingBase* setting)> ion::base::SettingBase::Listener
inherited

A function that is called when the value changes.

Definition at line 46 of file setting.h.

Constructor & Destructor Documentation

template<typename T >
ion::base::Setting< std::atomic< T > >::Setting ( const std::string &  name,
const T value,
const std::string &  doc_string 
)
inline

Creates a new setting with the passed name, initial value, and documentation string.

Definition at line 231 of file setting.h.

References ion::base::SetTypeDescriptorForType().

template<typename T >
ion::base::Setting< std::atomic< T > >::Setting ( const SettingGroup group,
const std::string &  name,
const T value,
const std::string &  doc_string 
)
inline

Same as above, but places the setting in the passed group.

Definition at line 238 of file setting.h.

References ion::base::SetTypeDescriptorForType().

template<typename T >
ion::base::Setting< std::atomic< T > >::Setting ( const std::string &  name,
const T value 
)
inline

Convenience constructor that does not require a documentation string.

Definition at line 246 of file setting.h.

References ion::base::SetTypeDescriptorForType().

template<typename T >
ion::base::Setting< std::atomic< T > >::Setting ( const SettingGroup group,
const std::string &  name,
const T value 
)
inline

Same as above, but places the setting in the passed group.

Definition at line 252 of file setting.h.

References ion::base::SetTypeDescriptorForType().

template<typename T >
ion::base::Setting< std::atomic< T > >::~Setting ( )
inlineoverride

Definition at line 258 of file setting.h.

Member Function Documentation

void ion::base::SettingBase::EnableListener ( const std::string &  key,
bool  enable 
)
inherited

Enables or disables the listener identified by key, if one exists.

Definition at line 40 of file setting.cc.

template<typename T >
bool ion::base::Setting< std::atomic< T > >::FromString ( const std::string &  str)
inlineoverridevirtual

Parses the passed string to set the value of this and returns whether the parsing was successful.

If the parsing does not succeed then nothing should change in this.

Implements ion::base::SettingBase.

Definition at line 264 of file setting.h.

References ion::base::Setting< T >::SetValue(), ion::base::StringToValue(), and value.

const std::string& ion::base::SettingBase::GetDocString ( ) const
inlineinherited

Returns the documentation string associated with this.

Definition at line 59 of file setting.h.

template<typename T >
std::atomic<T>* ion::base::Setting< std::atomic< T > >::GetMutableValue ( )
inline

Direct value mutators.

Definition at line 275 of file setting.h.

const std::string& ion::base::SettingBase::GetName ( ) const
inlineinherited

Returns the name associated with this.

Definition at line 56 of file setting.h.

const std::string& ion::base::SettingBase::GetTypeDescriptor ( ) const
inlineinherited

Definition at line 66 of file setting.h.

template<typename T >
const std::atomic<T>& ion::base::Setting< std::atomic< T > >::GetValue ( ) const
inline

Definition at line 276 of file setting.h.

void ion::base::SettingBase::NotifyListeners ( )
inherited

Notify listeners that this setting has changed.

Definition at line 50 of file setting.cc.

Referenced by ion::base::Setting< bool >::operator=(), operator=(), ion::base::Setting< bool >::SetValue(), and SetValue().

template<typename T >
ion::base::Setting< std::atomic< T > >::operator T ( ) const
inline

Definition at line 281 of file setting.h.

template<typename T >
void ion::base::Setting< std::atomic< T > >::operator= ( const T value)
inline

Definition at line 282 of file setting.h.

References ion::base::SettingBase::NotifyListeners(), and value.

template<typename T >
bool ion::base::Setting< std::atomic< T > >::operator== ( const T value) const
inline

Equality testers.

Definition at line 288 of file setting.h.

References value.

void ion::base::SettingBase::RegisterListener ( const std::string &  key,
const Listener listener 
)
inherited

Adds a function that will be called when this setting's value changes.

The function is identified by the passed key. The same key must be used to remove the listener.

Definition at line 35 of file setting.cc.

void ion::base::SettingBase::SetTypeDescriptor ( const std::string &  desc)
inlineinherited

Sets/returns a string containing information about the Setting's type.

This string can be used, for example, in an interactive program to present a specialized interface for displaying or modifying the settings. See the remote::SettingHandler documentation for examples.

Definition at line 65 of file setting.h.

Referenced by ion::base::SetTypeDescriptorForType().

template<typename T >
void ion::base::Setting< std::atomic< T > >::SetValue ( const T value)
inline

Definition at line 277 of file setting.h.

References ion::base::SettingBase::NotifyListeners(), and value.

template<typename T >
const std::string ion::base::Setting< std::atomic< T > >::ToString ( ) const
inlineoverridevirtual

Returns a string version of this setting.

The same string may be passed to FromString to reconstruct an identical setting.

Implements ion::base::SettingBase.

Definition at line 260 of file setting.h.

References ion::base::ValueToString().

void ion::base::SettingBase::UnregisterListener ( const std::string &  key)
inherited

Removes the listener identified by key, if one exists.

Definition at line 46 of file setting.cc.

Friends And Related Function Documentation

template<typename T >
bool operator== ( const T value,
const Setting< std::atomic< T > > &  setting 
)
friend

Definition at line 289 of file setting.h.


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