Safir SDK Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PersistentDataState.h
Go to the documentation of this file.
1 #ifndef SAFIR_DOB_PERSISTENTDATASTATE_H_INCLUDED
2 #define SAFIR_DOB_PERSISTENTDATASTATE_H_INCLUDED
3 
8 
9 #ifdef _MSC_VER
10 #ifdef DOTS_GENERATED_CPP_EXPORTS
11 #define GENERATED_API __declspec(dllexport)
12 #else
13 #define GENERATED_API __declspec(dllimport)
14 #ifdef _DEBUG
15 #pragma comment( lib, "dots_generated-Safir-cppd.lib" )
16 #else
17 #pragma comment( lib, "dots_generated-Safir-cpp.lib" )
18 #endif
19 #endif
20 #endif
21 #ifdef __GNUC__
22 #define GENERATED_API
23 #endif
24 
28 namespace Safir
29 {
33 namespace Dob
34 {
35 
40  struct GENERATED_API PersistentDataState
41  {
43  {
44  Init = 0,
45  Started
46  };
47 
48 
49  static Safir::Dob::Typesystem::Int32 Size();
50  static Enumeration First();
51  static Enumeration Last();
52 
53  static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal();
54  static Safir::Dob::Typesystem::EnumerationValue LastOrdinal();
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 = -3043138054087511491LL;
60  static const Safir::Dob::Typesystem::TypeId Checksum = 5456639545010803425LL;
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  //Will throw IllegalValueException if value is not in first .. last
72  {
73  if (value < FirstOrdinal() || value > LastOrdinal())
74  {
75  throw Safir::Dob::Typesystem::IllegalValueException(L"The enumerated type Safir.Dob.PersistentDataState does not have such a value",__WFILE__,__LINE__);
76  }
77  m_bIsNull = false;
78  m_bIsChanged = true;
79  m_Value = value;
80  }
81 
83  {
84  if (IsNull())
85  {
86  throw Safir::Dob::Typesystem::NullException(L"Value is null",__WFILE__,__LINE__);
87  }
88  return m_Value;
89  }
90 
91  //Will throw ConfigurationErrorException if there is an enumeration mismatch
92  void SetVal(const Enumeration value)
93  {
94  CheckForMismatch();
95  SetOrdinal(value);
96  }
97 
98  //Will throw ConfigurationErrorException if there is an enumeration mismatch
100  {
101  CheckForMismatch();
102  return static_cast<Enumeration>(GetOrdinal());
103  }
104 
105  //compare an enumerationcontainer with a value, will return false if the container is null or the values are not equal
106  bool operator==(const Enumeration other) const
107  {CheckForMismatch(); return !IsNull() && m_Value == other;}
108 
109  bool operator != (const Enumeration other) const
110  {return !(*this == other);}
111  };
112 
114 
115  };
117  {return second == first;}
118 
120  {return !(first == second);}
121 
122 } // Dob
123 } // Safir
124 
125 #endif
126 
Enumeration ContainedType
Definition: PersistentDataState.h:69
virtual void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value)
Set the ordinal value of the enumeration container.
Definition: PersistentDataState.h:71
Enumeration
Definition: PersistentDataState.h:42
Enumeration GetVal() const
Definition: PersistentDataState.h:99
virtual Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const
Get the ordinal value of the enumeration container.
Definition: PersistentDataState.h:82
bool operator==(const Enumeration other) const
Definition: PersistentDataState.h:106
Definition: PersistentDataState.h:66
DotsC_TypeId TypeId
A unique type identifier.
Definition: Dob/Typesystem/Defs.h:221
static bool operator==(const CallbackId::Enumeration first, const CallbackId::EnumerationContainer second)
Definition: CallbackId.h:136
Base class for containers of enumeration values.
Definition: EnumerationContainerBase.h:50
#define __WFILE__
Definition: Exceptions.h:31
A parameter in the call was invalid.
Definition: Exceptions.h:254
void SetVal(const Enumeration value)
Definition: PersistentDataState.h:92
The different states of the persistence handling.
Definition: PersistentDataState.h:40
Thrown when an application attempts to get the value of a member that is null.
Definition: Exceptions.h:394
DotsC_EnumerationValue EnumerationValue
The ordinal value of an enumeration.
Definition: Dob/Typesystem/Defs.h:273
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition: PersistentDataState.h:113
STL container for arrays of DOB-containers.
Definition: ArrayContainer.h:58
DotsC_Int32 Int32
32 bit integer type.
Definition: Dob/Typesystem/Defs.h:69
static bool operator!=(const CallbackId::Enumeration first, const CallbackId::EnumerationContainer second)
Definition: CallbackId.h:139