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