Safir SDK Core
Loading...
Searching...
No Matches
PersistentDataState.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 Init = 0,
39 Started
40 };
41
42
45 static Enumeration Last();
46
49
50 static std::wstring ToString(const Enumeration enumVal);
51 static Enumeration ToValue(const std::wstring & valueString);
52
53 static const Safir::Dob::Typesystem::TypeId EnumerationTypeId = -3043138054087511491LL;
54 static const Safir::Dob::Typesystem::TypeId Checksum = 5456639545010803425LL;
55
56 //Check that there is no enumeration mismatch
57 //throws an exception if there is - ConfigurationErrorException
58 static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum = Checksum);
59
61 {
62 public:
64
65 //Will throw IllegalValueException if value is not in first .. last
67 {
68 if (value < FirstOrdinal() || value > LastOrdinal())
69 {
70 throw Safir::Dob::Typesystem::IllegalValueException(L"The enumerated type Safir.Dob.PersistentDataState does not have such a value",__WFILE__,__LINE__);
71 }
72 m_bIsNull = false;
73 m_bIsChanged = true;
74 m_Value = value;
75 }
76
78 {
79 if (IsNull())
80 {
81 throw Safir::Dob::Typesystem::NullException(L"Value is null",__WFILE__,__LINE__);
82 }
83 return m_Value;
84 }
85
86 //Will throw ConfigurationErrorException if there is an enumeration mismatch
87 void SetVal(const Enumeration value)
88 {
89 CheckForMismatch();
90 SetOrdinal(value);
91 }
92
93 //Will throw ConfigurationErrorException if there is an enumeration mismatch
95 {
96 CheckForMismatch();
97 return static_cast<Enumeration>(GetOrdinal());
98 }
99
100 //compare an enumerationcontainer with a value, will return false if the container is null or the values are not equal
101 bool operator==(const Enumeration other) const
102 {CheckForMismatch(); return !IsNull() && m_Value == other;}
103
104 bool operator != (const Enumeration other) const
105 {return !(*this == other);}
106 };
107
110
111 };
113 {return second == first;}
114
116 {return !(first == second);}
117
118} // Dob
119} // Safir
120
121
#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 states of the persistence handling.
Definition PersistentDataState.h:35
static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal()
static Enumeration ToValue(const std::wstring &valueString)
static Safir::Dob::Typesystem::EnumerationValue LastOrdinal()
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition PersistentDataState.h:108
Enumeration
Definition PersistentDataState.h:37
static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum=Checksum)
static std::wstring ToString(const Enumeration enumVal)
Safir::Dob::Typesystem::EnumerationSequenceContainer< PersistentDataState > EnumerationSequenceContainer
Definition PersistentDataState.h:109
static Enumeration First()
static Enumeration Last()
static Safir::Dob::Typesystem::Int32 Size()
Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const override
Get the ordinal value of the enumeration container.
Definition PersistentDataState.h:77
void SetVal(const Enumeration value)
Definition PersistentDataState.h:87
Enumeration ContainedType
Definition PersistentDataState.h:63
Enumeration GetVal() const
Definition PersistentDataState.h:94
void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value) override
Set the ordinal value of the enumeration container.
Definition PersistentDataState.h:66
bool operator==(const Enumeration other) const
Definition PersistentDataState.h:101