Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::UnitConversionServer Class Reference

Implementation of a unit conversion server using an ini-file. This conversion class installs a handler using setUnitConversionHandler() using a UnitConversionServerClosure type of function. More...

#include <UnitConversionServer.h>

Inheritance diagram for sf::UnitConversionServer:
[legend]
Collaboration diagram for sf::UnitConversionServer:
[legend]

Public Types

enum  EUnitSystem : int { usPassThrough , usMetric , usImperial }
 Different unit conversion systems. More...
typedef std::pair< EUnitSystem, const char * > UnitSystemPair
 Type to combine a system enumerate and name.

Public Member Functions

 UnitConversionServer ()
 Default constructor.
 UnitConversionServer (const UnitConversionServer &)=delete
 Copying this class is not possible.
virtual ~UnitConversionServer ()
 Virtual destructor.
virtual bool load (std::istream &is)
 Loads the conversion settings.
virtual bool save (std::ostream &os)
 Saves the conversion settings.
bool isDirty () const
 Gets the dirty status of the configuration.
void setConversion (UnitConversionEvent &ev)
 Writes or overwrites a conversion entry in the profile.
void removeConversion (const std::string &key)
 Removes a conversion entry in the profile.
virtual void setUnitSystem (int us)
 Sets the unit system to be applied.
EUnitSystem getUnitSystem () const
 Gets the unit system being applied.
IniProfile & getProfile ()
 Gets the internal storage profile.

Static Public Member Functions

static const char * getUnitSystemName (int us)
 Gets the section name of the passed enumerate.
static const std::vector< UnitSystemPair > & getUnitSystemNames ()

Protected Member Functions

virtual bool handler (UnitConversionEvent &ev)
 Handler according the unit conversion function type.

Protected Attributes

IniProfile _profile

Detailed Description

Implementation of a unit conversion server using an ini-file. This conversion class installs a handler using setUnitConversionHandler() using a UnitConversionServerClosure type of function.

Member Typedef Documentation

◆ UnitSystemPair

typedef std::pair<EUnitSystem, const char*> sf::UnitConversionServer::UnitSystemPair

Type to combine a system enumerate and name.

Member Enumeration Documentation

◆ EUnitSystem

Different unit conversion systems.

Enumerator
usPassThrough 

No conversion use as is which should be SI-units.

usMetric 

Conversion in the metric system depending on precision. Radians become degrees and 'm/s' can become 'km/h'.

usImperial 

Conversion to the imperial system depending on precision. Celsius becomes Fahrenheit and 'm/s' become 'mph'.

Constructor & Destructor Documentation

◆ UnitConversionServer() [1/2]

sf::UnitConversionServer::UnitConversionServer ( )

Default constructor.

◆ UnitConversionServer() [2/2]

sf::UnitConversionServer::UnitConversionServer ( const UnitConversionServer & )
delete

Copying this class is not possible.

◆ ~UnitConversionServer()

virtual sf::UnitConversionServer::~UnitConversionServer ( )
virtual

Virtual destructor.

Member Function Documentation

◆ getProfile()

IniProfile & sf::UnitConversionServer::getProfile ( )
nodiscard

Gets the internal storage profile.

◆ getUnitSystem()

EUnitSystem sf::UnitConversionServer::getUnitSystem ( ) const
nodiscard

Gets the unit system being applied.

◆ getUnitSystemName()

const char * sf::UnitConversionServer::getUnitSystemName ( int us)
static

Gets the section name of the passed enumerate.

Parameters
usunit system enumerate.
Returns
Name of the system.

◆ getUnitSystemNames()

const std::vector< UnitSystemPair > & sf::UnitConversionServer::getUnitSystemNames ( )
static

Gets all the system unit entries as a pair in a vector.

Returns

◆ handler()

virtual bool sf::UnitConversionServer::handler ( UnitConversionEvent & ev)
protectedvirtual

Handler according the unit conversion function type.

Reimplemented in sf::UnitConversionServerEx.

◆ isDirty()

bool sf::UnitConversionServer::isDirty ( ) const
nodiscard

Gets the dirty status of the configuration.

Returns
True when the config has been changed.

◆ load()

virtual bool sf::UnitConversionServer::load ( std::istream & is)
virtual

Loads the conversion settings.

Parameters
isInput stream.

Reimplemented in sf::UnitConversionServerEx.

◆ removeConversion()

void sf::UnitConversionServer::removeConversion ( const std::string & key)

Removes a conversion entry in the profile.

◆ save()

virtual bool sf::UnitConversionServer::save ( std::ostream & os)
virtual

Saves the conversion settings.

Parameters
osOutput stream.

Reimplemented in sf::UnitConversionServerEx.

◆ setConversion()

void sf::UnitConversionServer::setConversion ( UnitConversionEvent & ev)

Writes or overwrites a conversion entry in the profile.

◆ setUnitSystem()

virtual void sf::UnitConversionServer::setUnitSystem ( int us)
virtual

Sets the unit system to be applied.

Parameters
usunit system vale EUnitSystem.

Reimplemented in sf::UnitConversionServerEx.

Member Data Documentation

◆ _profile

IniProfile sf::UnitConversionServer::_profile
protected

Ini profile keeping all conversion information.


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