unit_converter.h
Go to the documentation of this file.
1 //======================================================================
28 //======================================================================
29 
30 //----------------------------------------------------------------------
31 // System Includes - include with <>
32 //----------------------------------------------------------------------
33 
34 #include <vector>
35 
36 //----------------------------------------------------------------------
37 // Project Includes - include with ""
38 //----------------------------------------------------------------------
39 
40 #include "simplevector.h"
41 #include "sdhlibrary_settings.h"
42 
43 //----------------------------------------------------------------------
44 // Defines, enums, unions, structs,
45 //----------------------------------------------------------------------
46 
48 
49 
50 //----------------------------------------------------------------------
51 // Global variables
52 //----------------------------------------------------------------------
53 
54 
55 //----------------------------------------------------------------------
56 // Function declarations
57 //----------------------------------------------------------------------
58 
59 
60 //----------------------------------------------------------------------
61 // Class declarations
62 //----------------------------------------------------------------------
63 
64 
75 class VCC_EXPORT cUnitConverter
76 {
77 public:
96  cUnitConverter( char const* _kind, char const* _name, char const* _symbol, double _factor = 1.0, double _offset = 0.0, int _decimal_places=1 );
97 
98  //----------------------------------------------------------------------
103  double ToExternal( double internal ) const;
104 
105  //----------------------------------------------------------------------
114  cSimpleVector ToExternal( cSimpleVector& internal ) const;
115 
116 
117  //----------------------------------------------------------------------
124  std::vector<double> ToExternal( std::vector<double> const& internal ) const;
125 
126 
127  //----------------------------------------------------------------------
132  double ToInternal( double external ) const;
133 
134  //----------------------------------------------------------------------
143  cSimpleVector ToInternal( cSimpleVector& external ) const;
144 
145 
146  //----------------------------------------------------------------------
153  std::vector<double> ToInternal( std::vector<double> const& external ) const;
154 
155  //----------------------------------------------------------------------
157  char const* GetKind( void ) const;
158 
159  //----------------------------------------------------------------------
161  char const* GetName( void ) const;
162 
163  //----------------------------------------------------------------------
165  char const* GetSymbol( void ) const;
166 
167  //----------------------------------------------------------------------
168 
170  double GetFactor( void ) const;
171 
172  //----------------------------------------------------------------------
174  double GetOffset( void ) const;
175 
176  //----------------------------------------------------------------------
178  int GetDecimalPlaces( void ) const;
179 
180 
181 protected:
183  char const* kind;
184 
186  char const* name;
187 
189  char const* symbol;
190 
192  double factor;
193 
195  double offset;
196 
199 
200 }; // cUnitConverter
201 //======================================================================
202 
203 
205 extern cUnitConverter const uc_identity;
206 
207 //----------------------------------------------------------------------
209 typedef double (cUnitConverter::*pDoubleUnitConverterFunction) ( double ) const;
210 
211 
213 //typedef std::vector<double> (cUnitConverter::*pDoubleVectorUnitConverterFunction) ( std::vector<double> ) const;
214 
215 
216 //
217 //#####################################################################
218 
220 
221 
222 //======================================================================
223 /*
224  Here are some settings for the emacs/xemacs editor (and can be safely ignored):
225  (e.g. to explicitely set C++ mode for *.h header files)
226 
227  Local Variables:
228  mode:C++
229  mode:ELSE
230  End:
231 */
232 //======================================================================
cUnitConverter::symbol
char const * symbol
the symbol of the external unit (something like "deg" or "ms")
Definition: unit_converter.h:189
NAMESPACE_SDH_END
#define NAMESPACE_SDH_END
Definition: sdhlibrary_settings.h:80
cUnitConverter::decimal_places
int decimal_places
A usefull number of decimal places for printing values in the external unit system.
Definition: unit_converter.h:198
pDoubleUnitConverterFunction
double(cUnitConverter::* pDoubleUnitConverterFunction)(double) const
Type of a pointer to a function like 'double SDH::cUnitConverter::ToExternal( double ) const' or 'dou...
Definition: unit_converter.h:209
cSimpleVector
A simple vector implementation.
Definition: simplevector.h:91
cUnitConverter::kind
char const * kind
the kind of unit to be converted (something like "angle" or "time")
Definition: unit_converter.h:183
uc_identity
const cUnitConverter uc_identity
Identity converter (internal = external)
simplevector.h
Interface of class #SDH::cSimpleVector.
NAMESPACE_SDH_START
#define NAMESPACE_SDH_START
Definition: sdhlibrary_settings.h:79
cUnitConverter::offset
double offset
the conversion offset from internal to external units
Definition: unit_converter.h:195
sdhlibrary_settings.h
This file contains settings to make the SDHLibrary compile on differen systems:
cUnitConverter::name
char const * name
the name of the external unit (something like "degrees" or "milliseconds")
Definition: unit_converter.h:186
cUnitConverter::factor
double factor
the conversion factor from internal to external units
Definition: unit_converter.h:192
cUnitConverter
Unit conversion class to convert values between physical unit systems.
Definition: unit_converter.h:75


sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Wed Mar 2 2022 01:00:58