Safir SDK Core
Loading...
Searching...
No Matches
PersistenceBackend.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
33
35 {
37 {
38 None = 0,
41 };
42
43
46 static Enumeration Last();
47
50
51 static std::wstring ToString(const Enumeration enumVal);
52 static Enumeration ToValue(const std::wstring & valueString);
53
54 static const Safir::Dob::Typesystem::TypeId EnumerationTypeId = 4878269954615058785LL;
55 static const Safir::Dob::Typesystem::TypeId Checksum = 8917522224469727486LL;
56
57 //Check that there is no enumeration mismatch
58 //throws an exception if there is - ConfigurationErrorException
60
62 {
63 public:
65
66 //Will throw IllegalValueException if value is not in first .. last
68 {
69 if (value < FirstOrdinal() || value > LastOrdinal())
70 {
71 throw Safir::Dob::Typesystem::IllegalValueException(L"The enumerated type Safir.Dob.PersistenceBackend does not have such a value",__WFILE__,__LINE__);
72 }
73 m_bIsNull = false;
74 m_bIsChanged = true;
75 m_Value = value;
76 }
77
79 {
80 if (IsNull())
81 {
82 throw Safir::Dob::Typesystem::NullException(L"Value is null",__WFILE__,__LINE__);
83 }
84 return m_Value;
85 }
86
87 //Will throw ConfigurationErrorException if there is an enumeration mismatch
88 void SetVal(const Enumeration value)
89 {
91 SetOrdinal(value);
92 }
93
94 //Will throw ConfigurationErrorException if there is an enumeration mismatch
96 {
98 return static_cast<Enumeration>(GetOrdinal());
99 }
100
101 //Will get the value if container is not null, else the supplied default value is returned.
103 {
105 return IsNull() ? defaultVal : static_cast<Enumeration>(GetOrdinal());
106 }
107
108 //compare an enumerationcontainer with a value, will return false if the container is null or the values are not equal
109 bool operator==(const Enumeration other) const
110 {CheckForMismatch(); return !IsNull() && m_Value == other;}
111
112 bool operator != (const Enumeration other) const
113 {return !(*this == other);}
114 };
115
118
119 };
121 {return second == first;}
122
124 {return !(first == second);}
125
126} // Dob
127} // Safir
128
129
#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:139
static bool operator!=(const CallbackId::Enumeration first, const CallbackId::EnumerationContainer &second)
Definition CallbackId.h:142
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
bool m_bIsChanged
The variable containing the change flag.
Definition ContainerBase.h:134
Base class for containers of enumeration values.
Definition EnumerationContainerBase.h:51
bool IsNull() const override
Is the container set to null?
Definition EnumerationContainerBase.h:82
bool m_bIsNull
The null flag for the enumeration container.
Definition EnumerationContainerBase.h:126
EnumerationValue m_Value
The value of the enumeration container.
Definition EnumerationContainerBase.h:132
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:366
Enumerates the different backends that DOPE can use for persistence.
Definition PersistenceBackend.h:35
static Safir::Dob::Typesystem::Int32 Size()
static const Safir::Dob::Typesystem::TypeId EnumerationTypeId
Definition PersistenceBackend.h:54
static Safir::Dob::Typesystem::EnumerationValue LastOrdinal()
static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum=Checksum)
static std::wstring ToString(const Enumeration enumVal)
static const Safir::Dob::Typesystem::TypeId Checksum
Definition PersistenceBackend.h:55
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition PersistenceBackend.h:116
static Enumeration First()
Enumeration
Definition PersistenceBackend.h:37
@ None
Definition PersistenceBackend.h:38
@ File
Definition PersistenceBackend.h:39
@ Odbc
Definition PersistenceBackend.h:40
Safir::Dob::Typesystem::EnumerationSequenceContainer< PersistenceBackend > EnumerationSequenceContainer
Definition PersistenceBackend.h:117
static Enumeration Last()
static Enumeration ToValue(const std::wstring &valueString)
static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal()
bool operator==(const Enumeration other) const
Definition PersistenceBackend.h:109
void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value) override
Set the ordinal value of the enumeration container.
Definition PersistenceBackend.h:67
Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const override
Get the ordinal value of the enumeration container.
Definition PersistenceBackend.h:78
Enumeration GetValOrDefault(const Enumeration defaultVal) const
Definition PersistenceBackend.h:102
Enumeration GetVal() const
Definition PersistenceBackend.h:95
void SetVal(const Enumeration value)
Definition PersistenceBackend.h:88
Enumeration ContainedType
Definition PersistenceBackend.h:64