Safir SDK Core
Loading...
Searching...
No Matches
Operation.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 Control
28{
29
33
35 {
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 = 3321252083896681848LL;
55 static const Safir::Dob::Typesystem::TypeId Checksum = -8728942464375629091LL;
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.Control.Operation 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 };
120 static inline bool operator==(const Operation::Enumeration first, const Operation::EnumerationContainer& second)
121 {return second == first;}
122
123 static inline bool operator!=(const Operation::Enumeration first, const Operation::EnumerationContainer& second)
124 {return !(first == second);}
125
126} // Control
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
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 Operation::Enumeration first, const Operation::EnumerationContainer &second)
Definition Operation.h:120
static bool operator!=(const Operation::Enumeration first, const Operation::EnumerationContainer &second)
Definition Operation.h:123
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
System or node oparations.
Definition Operation.h:35
static const Safir::Dob::Typesystem::TypeId EnumerationTypeId
Definition Operation.h:54
static Enumeration ToValue(const std::wstring &valueString)
static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal()
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition Operation.h:116
Safir::Dob::Typesystem::EnumerationSequenceContainer< Operation > EnumerationSequenceContainer
Definition Operation.h:117
static Enumeration Last()
static std::wstring ToString(const Enumeration enumVal)
Enumeration
Definition Operation.h:37
@ Stop
Definition Operation.h:38
@ Shutdown
Definition Operation.h:39
@ Reboot
Definition Operation.h:40
static Safir::Dob::Typesystem::EnumerationValue LastOrdinal()
static const Safir::Dob::Typesystem::TypeId Checksum
Definition Operation.h:55
static Safir::Dob::Typesystem::Int32 Size()
static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum=Checksum)
static Enumeration First()
void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value) override
Set the ordinal value of the enumeration container.
Definition Operation.h:67
Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const override
Get the ordinal value of the enumeration container.
Definition Operation.h:78
Enumeration GetValOrDefault(const Enumeration defaultVal) const
Definition Operation.h:102
Enumeration GetVal() const
Definition Operation.h:95
void SetVal(const Enumeration value)
Definition Operation.h:88
Enumeration ContainedType
Definition Operation.h:64
bool operator==(const Enumeration other) const
Definition Operation.h:109