Safir SDK Core
Loading...
Searching...
No Matches
MemoryLevel.h
Go to the documentation of this file.
1#pragma once
2
8#include <Safir/Utilities/Internal/VisibilityHelpers.h>
9
10#ifdef safir_generated_Core_cpp_EXPORTS
11# define SAFIR_GENERATED_Core_API SAFIR_HELPER_DLL_EXPORT
12#else
13# define SAFIR_GENERATED_Core_API SAFIR_HELPER_DLL_IMPORT
14# define SAFIR_LIBRARY_NAME "safir_generated-Core-cpp"
15# include <Safir/Utilities/Internal/AutoLink.h>
16#endif
17#define SAFIR_GENERATED_Core_API_LOCAL SAFIR_HELPER_DLL_LOCAL
18
22namespace Safir
23{
27namespace Dob
28{
29
35 {
37 {
38 Normal = 0,
43 Full
44 };
45
46
49 static Enumeration Last();
50
53
54 static std::wstring ToString(const Enumeration enumVal);
55 static Enumeration ToValue(const std::wstring & valueString);
56
57 static const Safir::Dob::Typesystem::TypeId EnumerationTypeId = 23384642346640568LL;
58 static const Safir::Dob::Typesystem::TypeId Checksum = -8466974638562903825LL;
59
60 //Check that there is no enumeration mismatch
61 //throws an exception if there is - ConfigurationErrorException
62 static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum = Checksum);
63
65 {
66 public:
68
69 //Will throw IllegalValueException if value is not in first .. last
71 {
72 if (value < FirstOrdinal() || value > LastOrdinal())
73 {
74 throw Safir::Dob::Typesystem::IllegalValueException(L"The enumerated type Safir.Dob.MemoryLevel does not have such a value",__WFILE__,__LINE__);
75 }
76 m_bIsNull = false;
77 m_bIsChanged = true;
78 m_Value = value;
79 }
80
82 {
83 if (IsNull())
84 {
85 throw Safir::Dob::Typesystem::NullException(L"Value is null",__WFILE__,__LINE__);
86 }
87 return m_Value;
88 }
89
90 //Will throw ConfigurationErrorException if there is an enumeration mismatch
91 void SetVal(const Enumeration value)
92 {
93 CheckForMismatch();
94 SetOrdinal(value);
95 }
96
97 //Will throw ConfigurationErrorException if there is an enumeration mismatch
99 {
100 CheckForMismatch();
101 return static_cast<Enumeration>(GetOrdinal());
102 }
103
104 //compare an enumerationcontainer with a value, will return false if the container is null or the values are not equal
105 bool operator==(const Enumeration other) const
106 {CheckForMismatch(); return !IsNull() && m_Value == other;}
107
108 bool operator != (const Enumeration other) const
109 {return !(*this == other);}
110 };
111
114
115 };
116 static inline bool operator==(const MemoryLevel::Enumeration first, const MemoryLevel::EnumerationContainer& second)
117 {return second == first;}
118
119 static inline bool operator!=(const MemoryLevel::Enumeration first, const MemoryLevel::EnumerationContainer& second)
120 {return !(first == second);}
121
122} // Dob
123} // Safir
124
125
#define __WFILE__
Definition Exceptions.h:31
#define SAFIR_GENERATED_Core_API
Definition BackdoorCommand.h:18
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
static bool operator==(const CallbackId::Enumeration first, const CallbackId::EnumerationContainer &second)
Definition CallbackId.h:132
static bool operator!=(const CallbackId::Enumeration first, const CallbackId::EnumerationContainer &second)
Definition CallbackId.h:135
DotsC_EnumerationValue EnumerationValue
The ordinal value of an enumeration.
Definition Defs.h:270
DotsC_Int32 Int32
32 bit integer type.
Definition Defs.h:66
DotsC_TypeId TypeId
A unique type identifier.
Definition Defs.h:218
STL container for arrays of DOB-containers.
Definition ArrayContainer.h:59
Base class for containers of enumeration values.
Definition EnumerationContainerBase.h:51
A parameter in the call was invalid.
Definition Exceptions.h:264
Thrown when an application attempts to get the value of a member that is null.
Definition Exceptions.h:396
Container for sequences of enumeration values.
Definition SequenceContainer.h:362
The different memory levels that makes the Dob go into various degraded modes.
Definition MemoryLevel.h:35
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition MemoryLevel.h:112
static Enumeration First()
static Enumeration ToValue(const std::wstring &valueString)
Safir::Dob::Typesystem::EnumerationSequenceContainer< MemoryLevel > EnumerationSequenceContainer
Definition MemoryLevel.h:113
static std::wstring ToString(const Enumeration enumVal)
static Safir::Dob::Typesystem::EnumerationValue LastOrdinal()
Enumeration
Definition MemoryLevel.h:37
@ Warning
Definition MemoryLevel.h:39
@ VeryLow
Definition MemoryLevel.h:41
@ ExtremelyLow
Definition MemoryLevel.h:42
@ Low
Definition MemoryLevel.h:40
static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal()
static Enumeration Last()
static Safir::Dob::Typesystem::Int32 Size()
static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum=Checksum)
Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const override
Get the ordinal value of the enumeration container.
Definition MemoryLevel.h:81
void SetVal(const Enumeration value)
Definition MemoryLevel.h:91
void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value) override
Set the ordinal value of the enumeration container.
Definition MemoryLevel.h:70
bool operator==(const Enumeration other) const
Definition MemoryLevel.h:105
Enumeration GetVal() const
Definition MemoryLevel.h:98
Enumeration ContainedType
Definition MemoryLevel.h:67