OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ValueFormatSetter.h
Go to the documentation of this file.
1#pragma once
2#include <string>
5
6
7class __declspec(dllexport)ValueFormatSetter
8{
9public:
10 void setValueFormatRealOnly(QuantityDescription& quantityDescription,std::string _unit)
11 {
12 quantityDescription.clearValueDescriptions();
13 quantityDescription.addValueDescription(m_realValueName, ot::TypeNames::getDoubleTypeName(), _unit);
14 POST(quantityDescription.getMetadataQuantity().valueDescriptions.size() == 1);
15 }
16
17 void setValueFormatImaginaryOnly(QuantityDescription& quantityDescription, std::string _unit)
18 {
19 quantityDescription.clearValueDescriptions();
20 quantityDescription.addValueDescription(m_imagValueName, ot::TypeNames::getDoubleTypeName(), _unit);
21 POST(quantityDescription.getMetadataQuantity().valueDescriptions.size() == 1);
22 }
23
24 void setValueFormatRealImaginary(QuantityDescription& quantityDescription, std::string _unit)
25 {
26 quantityDescription.clearValueDescriptions();
27 //Don't change order of addValueDescription!
28 quantityDescription.addValueDescription(m_realValueName, ot::TypeNames::getDoubleTypeName(), _unit);
29 quantityDescription.addValueDescription(m_imagValueName, ot::TypeNames::getDoubleTypeName(), _unit);
30 POST(quantityDescription.getMetadataQuantity().valueDescriptions.size() == 2);
31 }
32
33 void setValueFormatDecibelPhase(QuantityDescription& quantityDescription)
34 {
35 quantityDescription.clearValueDescriptions();
36 //Don't change order of addValueDescription!
37 quantityDescription.addValueDescription(m_decibelValueName, ot::TypeNames::getDoubleTypeName(), m_decibleUnitName);
38 quantityDescription.addValueDescription(m_phaseValueName, ot::TypeNames::getDoubleTypeName(), m_phaseUnitName);
39 POST(quantityDescription.getMetadataQuantity().valueDescriptions.size() == 2);
40 }
41
42 void setValueFormatMagnitudePhase(QuantityDescription& quantityDescription)
43 {
44 quantityDescription.clearValueDescriptions();
45 //Don't change order of addValueDescription!
46 quantityDescription.addValueDescription(m_magnitudeValueName, ot::TypeNames::getDoubleTypeName(), "");
47 quantityDescription.addValueDescription(m_phaseValueName, ot::TypeNames::getDoubleTypeName(), m_phaseUnitName);
48 POST(quantityDescription.getMetadataQuantity().valueDescriptions.size() == 2);
49 }
50
51private:
52
53 bool invariant() { return true; }
54 const std::string m_realValueName = "Real";
55 const std::string m_imagValueName = "Imaginary";
56 const std::string m_phaseValueName = "Phase";
57 const std::string m_magnitudeValueName = "Magnitude";
58 const std::string m_decibelValueName = "Decibel";
59
60 const std::string m_decibleUnitName = "dB";
61 const std::string m_phaseUnitName = "Deg";
62};
#define POST(condition)
Definition DefensiveProgramming.h:20
static std::string getDoubleTypeName()
Definition TypeNames.h:24