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 #include <Safir/Utilities/Internal/VisibilityHelpers.h>
10 
11 #ifdef dots_generated_Safir_cpp_EXPORTS
12 # define DOTS_GENERATED_Safir_API SAFIR_HELPER_DLL_EXPORT
13 #else
14 # define DOTS_GENERATED_Safir_API SAFIR_HELPER_DLL_IMPORT
15 # define SAFIR_LIBRARY_NAME "dots_generated-Safir-cpp"
16 # include <Safir/Utilities/Internal/AutoLink.h>
17 #endif
18 #define DOTS_GENERATED_Safir_API_LOCAL SAFIR_HELPER_DLL_LOCAL
19 
23 namespace Safir
24 {
28 namespace Utilities
29 {
33 namespace ForEach
34 {
35 
41  {
43  {
44  Immediate = 0,
46  Full
47  };
48 
49 
50  static Safir::Dob::Typesystem::Int32 Size();
51  static Enumeration First();
52  static Enumeration Last();
53 
54  static Safir::Dob::Typesystem::EnumerationValue FirstOrdinal();
55  static Safir::Dob::Typesystem::EnumerationValue LastOrdinal();
56 
57  static std::wstring ToString(const Enumeration enumVal);
58  static Enumeration ToValue(const std::wstring & valueString);
59 
60  static const Safir::Dob::Typesystem::TypeId EnumerationTypeId = -3026580767491978545LL;
61  static const Safir::Dob::Typesystem::TypeId Checksum = 6361459790240301752LL;
62 
63  //Check that there is no enumeration mismatch
64  //throws an exception if there is - ConfigurationErrorException
65  static void CheckForMismatch(const Safir::Dob::Typesystem::TypeId checksum = Checksum);
66 
68  {
69  public:
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 
115 
116  };
117  static inline bool operator==(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
118  {return second == first;}
119 
120  static inline bool operator!=(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
121  {return !(first == second);}
122 
123 } // ForEach
124 } // Utilities
125 } // Safir
126 
127 #endif
128 
virtual void SetOrdinal(const Safir::Dob::Typesystem::EnumerationValue value)
Set the ordinal value of the enumeration container.
Definition: ResponseType.h:72
void SetVal(const Enumeration value)
Definition: ResponseType.h:93
static bool operator!=(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
Definition: ResponseType.h:120
virtual Safir::Dob::Typesystem::EnumerationValue GetOrdinal() const
Get the ordinal value of the enumeration container.
Definition: ResponseType.h:83
DotsC_TypeId TypeId
A unique type identifier.
Definition: Defs.h:219
#define DOTS_GENERATED_Safir_API
Definition: ResponseType.h:14
Enumeration
Definition: ResponseType.h:42
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:70
This enumeration has no summary.
Definition: ResponseType.h:40
Enumeration GetVal() const
Definition: ResponseType.h:100
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: Defs.h:271
Safir::Dob::Typesystem::ArrayContainer< EnumerationContainer > EnumerationContainerArray
Definition: ResponseType.h:114
STL container for arrays of DOB-containers.
Definition: ArrayContainer.h:58
DotsC_Int32 Int32
32 bit integer type.
Definition: Defs.h:67
static bool operator==(const ResponseType::Enumeration first, const ResponseType::EnumerationContainer second)
Definition: ResponseType.h:117
bool operator==(const Enumeration other) const
Definition: ResponseType.h:107