Safir SDK Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResponseType.h
Go to the documentation of this file.
1 #ifndef SAFIR_UTILITIES_FOREACH_RESPONSETYPE_H_INCLUDED
2 #define SAFIR_UTILITIES_FOREACH_RESPONSETYPE_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 Utilities
34 {
38 namespace ForEach
39 {
40 
45  struct GENERATED_API ResponseType
46  {
48  {
49  Immediate = 0,
51  Full
52  };
53 
54 
55  static Safir::Dob::Typesystem::Int32 Size();
56  static Enumeration First();
57  static Enumeration Last();
58 
59  static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal();
60  static Safir::Dob::Typesystem::EnumerationValue LastOrdinal();
61 
62  static std::wstring ToString(const Enumeration enumVal);
63  static Enumeration ToValue(const std::wstring & valueString);
64 
65  static const Safir::Dob::Typesystem::TypeId EnumerationTypeId = -3026580767491978545LL;
66  static const Safir::Dob::Typesystem::TypeId Checksum = 6361459790240301752LL;
67 
68  //Check that there is no enumeration mismatch
69  //throws an exception if there is - ConfigurationErrorException
70  static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum = Checksum);
71 
73  {
74  public:
76  //Will throw IllegalValueException if value is not in first .. last
78  {
79  if (value < FirstOrdinal() || value > LastOrdinal())
80  {
81  throw Safir::Dob::Typesystem::IllegalValueException(L"The enumerated type Safir.Utilities.ForEach.ResponseType does not have such a value",__WFILE__,__LINE__);
82  }
83  m_bIsNull = false;
84  m_bIsChanged = true;
85  m_Value = value;
86  }
87 
89  {
90  if (IsNull())
91  {
92  throw Safir::Dob::Typesystem::NullException(L"Value is null",__WFILE__,__LINE__);
93  }
94  return m_Value;
95  }
96 
97  //Will throw ConfigurationErrorException if there is an enumeration mismatch
98  void SetVal(const Enumeration value)
99  {
100  CheckForMismatch();
101  SetOrdinal(value);
102  }
103 
104  //Will throw ConfigurationErrorException if there is an enumeration mismatch
106  {
107  CheckForMismatch();
108  return static_cast<Enumeration>(GetOrdinal());
109  }
110 
111  //compare an enumerationcontainer with a value, will return false if the container is null or the values are not equal
112  bool operator==(const Enumeration other) const
113  {CheckForMismatch(); return !IsNull() && m_Value == other;}
114 
115  bool operator != (const Enumeration other) const
116  {return !(*this == other);}
117  };
118 
120 
121  };
122  static inline bool operator==(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
123  {return second == first;}
124 
125  static inline bool operator!=(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
126  {return !(first == second);}
127 
128 } // ForEach
129 } // Utilities
130 } // Safir
131 
132 #endif
133 
virtual void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value)
Set the ordinal value of the enumeration container.
Definition: ResponseType.h:77
void SetVal(const Enumeration value)
Definition: ResponseType.h:98
static bool operator!=(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
Definition: ResponseType.h:125
virtual Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const
Get the ordinal value of the enumeration container.
Definition: ResponseType.h:88
DotsC_TypeId TypeId
A unique type identifier.
Definition: Dob/Typesystem/Defs.h:221
Enumeration
Definition: ResponseType.h:47
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
Enumeration ContainedType
Definition: ResponseType.h:75
This enumeration has no summary.
Definition: ResponseType.h:45
Enumeration GetVal() const
Definition: ResponseType.h:105
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: ResponseType.h:119
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 ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
Definition: ResponseType.h:122
bool operator==(const Enumeration other) const
Definition: ResponseType.h:112