Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
UnitConversionServer.h
Go to the documentation of this file.
1#pragma once
3#include <gii/global.h>
5#include <string>
6
7namespace sf
8{
9
16{
17 public:
22
27
36 virtual bool load(std::istream& is);
37
43 virtual bool save(std::ostream& os);
44
49 [[nodiscard]] bool isDirty() const;
50
55
59 void removeConversion(const std::string& key);
60
64 enum EUnitSystem : int
65 {
79 usImperial
80 };
81
87 virtual void setUnitSystem(int us);
88
92 [[nodiscard]] EUnitSystem getUnitSystem() const;
93
97 [[nodiscard]] IniProfile& getProfile();
98
104 static const char* getUnitSystemName(int us);
105
109 typedef std::pair<EUnitSystem, const char*> UnitSystemPair;
110
115 static const std::vector<UnitSystemPair>& getUnitSystemNames();
116
117 protected:
121 virtual bool handler(UnitConversionEvent& ev);
122
127
128 private:
132 EUnitSystem _unitSystem{usPassThrough};
133};
134
135}// namespace sf
Class for reading and writing ini-profiles.
Definition IniProfile.h:16
Implementation of a unit conversion server using an ini-file. This conversion class installs a handle...
Definition UnitConversionServer.h:16
virtual bool load(std::istream &is)
Loads the conversion settings.
UnitConversionServer()
Default constructor.
bool isDirty() const
Gets the dirty status of the configuration.
virtual void setUnitSystem(int us)
Sets the unit system to be applied.
virtual bool handler(UnitConversionEvent &ev)
Handler according the unit conversion function type.
EUnitSystem getUnitSystem() const
Gets the unit system being applied.
virtual ~UnitConversionServer()
Virtual destructor.
IniProfile _profile
Definition UnitConversionServer.h:126
static const char * getUnitSystemName(int us)
Gets the section name of the passed enumerate.
virtual bool save(std::ostream &os)
Saves the conversion settings.
IniProfile & getProfile()
Gets the internal storage profile.
EUnitSystem
Different unit conversion systems.
Definition UnitConversionServer.h:65
@ usMetric
Definition UnitConversionServer.h:74
@ usPassThrough
Definition UnitConversionServer.h:69
UnitConversionServer(const UnitConversionServer &)=delete
Copying this class is not possible.
void removeConversion(const std::string &key)
Removes a conversion entry in the profile.
void setConversion(UnitConversionEvent &ev)
Writes or overwrites a conversion entry in the profile.
static const std::vector< UnitSystemPair > & getUnitSystemNames()
std::pair< EUnitSystem, const char * > UnitSystemPair
Type to combine a system enumerate and name.
Definition UnitConversionServer.h:109
#define _GII_CLASS
Definition gii/global.h:38
Definition Application.h:10
Structure passed to handle unit conversions.
Definition UnitConversion.h:14