Safir SDK Core
Loading...
Searching...
No Matches
ResponseType.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 Utilities
28{
32namespace ForEach
33{
34
40 {
42 {
43 Immediate = 0,
45 Full
46 };
47
48
51 static Enumeration Last();
52
55
56 static std::wstring ToString(const Enumeration enumVal);
57 static Enumeration ToValue(const std::wstring & valueString);
58
59 static const Safir::Dob::Typesystem::TypeId EnumerationTypeId = -3026580767491978545LL;
60 static const Safir::Dob::Typesystem::TypeId Checksum = 6361459790240301752LL;
61
62 //Check that there is no enumeration mismatch
63 //throws an exception if there is - ConfigurationErrorException
64 static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum = Checksum);
65
67 {
68 public:
70
71 //Will throw IllegalValueException if value is not in first .. last
73 {
74 if (value < FirstOrdinal() || value > LastOrdinal())
75 {
76 throw Safir::Dob::Typesystem::IllegalValueException(L"The enumerated type Safir.Utilities.ForEach.ResponseType does not have such a value",__WFILE__,__LINE__);
77 }
78 m_bIsNull = false;
79 m_bIsChanged = true;
80 m_Value = value;
81 }
82
84 {
85 if (IsNull())
86 {
87 throw Safir::Dob::Typesystem::NullException(L"Value is null",__WFILE__,__LINE__);
88 }
89 return m_Value;
90 }
91
92 //Will throw ConfigurationErrorException if there is an enumeration mismatch
93 void SetVal(const Enumeration value)
94 {
95 CheckForMismatch();
96 SetOrdinal(value);
97 }
98
99 //Will throw ConfigurationErrorException if there is an enumeration mismatch
101 {
102 CheckForMismatch();
103 return static_cast<Enumeration>(GetOrdinal());
104 }
105
106 //compare an enumerationcontainer with a value, will return false if the container is null or the values are not equal
107 bool operator==(const Enumeration other) const
108 {CheckForMismatch(); return !IsNull() && m_Value == other;}
109
110 bool operator != (const Enumeration other) const
111 {return !(*this == other);}
112 };
113
116
117 };
118 static inline bool operator==(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer& second)
119 {return second == first;}
120
121 static inline bool operator!=(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer& second)
122 {return !(first == second);}
123
124} // ForEach
125} // Utilities
126} // Safir
127
128
#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
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
static bool operator==(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer &second)
Definition ResponseType.h:118
static bool operator!=(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer &second)
Definition ResponseType.h:121
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
This enumeration has no summary.
Definition ResponseType.h:40
static std::wstring ToString(const Enumeration enumVal)
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition ResponseType.h:114
static Safir::Dob::Typesystem::EnumerationValue LastOrdinal()
Enumeration
Definition ResponseType.h:42
@ Brief
Definition ResponseType.h:44
static Enumeration ToValue(const std::wstring &valueString)
static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal()
Safir::Dob::Typesystem::EnumerationSequenceContainer< ResponseType > EnumerationSequenceContainer
Definition ResponseType.h:115
static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum=Checksum)
static Safir::Dob::Typesystem::Int32 Size()
void SetVal(const Enumeration value)
Definition ResponseType.h:93
Enumeration GetVal() const
Definition ResponseType.h:100
Enumeration ContainedType
Definition ResponseType.h:69
void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value) override
Set the ordinal value of the enumeration container.
Definition ResponseType.h:72
Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const override
Get the ordinal value of the enumeration container.
Definition ResponseType.h:83
bool operator==(const Enumeration other) const
Definition ResponseType.h:107