OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
MessageOperator.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
4 // and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable ONIXS Software
7 // Services Agreement (the Agreement) and Customer end user license agreements granting
8 // a non-assignable, non-transferable and non-exclusive license to use the software
9 // for it's own data processing purposes under the terms defined in the Agreement.
10 //
11 // Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
12 // of this source code or associated reference material to any other location for further reproduction
13 // or redistribution, and any amendments to this copyright notice, are expressly prohibited.
14 //
15 // Any reproduction or redistribution for sale or hiring of the Software not in accordance with
16 // the terms of the Agreement is a violation of copyright law.
17 //
18 
19 #pragma once
20 
21 #include <OnixS/HandlerCore/Compiler.h>
22 
27 
47 
48 #include <OnixS/FIX/Core/Messaging.h>
49 #include <OnixS/FIX/Core/Messaging/Exception.h>
50 
51 namespace OnixS {
52 namespace Eurex {
53 namespace MarketData {
54 
56 {
57 public:
58 
59  static
60  const OnixS::FIX::Core::Messaging::FieldValue&
61  getCore(const FieldValueRef& value)
62  {
63  BOOST_ASSERT(value.impl_ != nullptr);
64  return *static_cast<const OnixS::FIX::Core::Messaging::FieldValue*>(value.impl_);
65  }
66 
67  static
68  const OnixS::FIX::Core::Messaging::FieldSet&
69  getCore(const FieldSet& fieldSet)
70  {
71  BOOST_ASSERT(fieldSet.impl_ != nullptr);
72  return *static_cast<const OnixS::FIX::Core::Messaging::FieldSet*>(fieldSet.impl_);
73  }
74 
75  static
76  OnixS::FIX::Core::Messaging::FieldSet&
77  getCore(FieldSet& fieldSet)
78  {
79  BOOST_ASSERT(fieldSet.impl_ != nullptr);
80  return *static_cast<OnixS::FIX::Core::Messaging::FieldSet*>(fieldSet.impl_);
81  }
82 
83  static
84  const OnixS::FIX::Core::Messaging::Message&
85  getCore(const Message& message)
86  {
87  return *message.message_;
88  }
89 
90  static
91  OnixS::FIX::Core::Messaging::Message&
92  getCore(Message& message)
93  {
94  return *message.message_;
95  }
96 
97  static
98  const OnixS::FIX::Core::Messaging::RepeatingGroup&
99  getCore(const Group& group)
100  {
101  BOOST_ASSERT(group.impl_ != nullptr);
102  return *static_cast<const OnixS::FIX::Core::Messaging::RepeatingGroup*>(group.impl_);
103  }
104 
105  static
106  OnixS::FIX::Core::Messaging::RepeatingGroup&
107  getCore(Group& group)
108  {
109  BOOST_ASSERT(group.impl_ != nullptr);
110  return *static_cast<OnixS::FIX::Core::Messaging::RepeatingGroup*>(group.impl_);
111  }
112 
113  static
116  const FieldSet& fieldSet,
117  Tag tag)
118  {
119  return FieldValueRef(fieldSet.container_, &(getCore(fieldSet)[tag]));
120  }
121 
122  static
123  Group
125  const FieldSet& fieldSet,
126  OnixS::FIX::Core::Messaging::RepeatingGroup& group)
127  {
128  return Group(fieldSet.container_, &group);
129  }
130 
131  static
132  Group
134  const FieldSet& fieldSet,
135  Tag tag)
136  {
137  return constructGroup(
138  fieldSet,
140  CompliantAccessor::getRepeatingGroup(
141  getCore(const_cast<FieldSet&>(fieldSet)),
142  tag));
143  }
144 
145  static Group constructOptionalGroup(const FieldSet& fieldSet, Tag tag)
146  {
147  const OnixS::FIX::Core::Messaging::FieldSet& coreFieldSet = getCore(fieldSet);
148  const OnixS::FIX::Core::Messaging::FieldSetStructure& coreFieldSetStructure = coreFieldSet.structure();
149  const OnixS::FIX::Core::Messaging::FieldIndex groupIndex = coreFieldSetStructure.find(tag);
150  const OnixS::FIX::Core::Messaging::FieldIndex outOfRange = OnixS::FIX::Core::Messaging::FieldIndexTraits::OutOfRange;
151 
152  if (outOfRange == groupIndex ||
153  nullptr == coreFieldSetStructure[groupIndex].repeatingGroup())
154  {
155  throw OnixS::FIX::Core::Messaging::CompliantAccessException(
156  coreFieldSet,
157  tag,
158  OnixS::FIX::Core::Messaging::CompliantAccessIssues::UndefinedRepeatingGroup);
159  }
160 
161  const OnixS::FIX::Core::Messaging::FieldValue& fieldValue = coreFieldSet.indexed()[groupIndex];
162  const OnixS::FIX::Core::Messaging::RepeatingGroup* repeatingGroup;
163 
164  if (fieldValue.convertTo(repeatingGroup))
165  return Group(fieldSet.container_, const_cast<OnixS::FIX::Core::Messaging::RepeatingGroup*>(repeatingGroup));
166 
167  if (OnixS::FIX::Core::Messaging::FieldValueTraits::isNull(fieldValue))
168  return Group(fieldSet.container_, nullptr);
169 
170  throw OnixS::FIX::Core::Messaging::BadCastException(
171  coreFieldSet,
172  tag,
173  fieldValue,
174  OnixS::FIX::Core::Messaging::DataTypes::RepeatingGroup);
175 
176  }
177 
178  static
181  const Message& container,
183  RepeatingGroupInstance& instance)
184  {
185  return GroupInstance(
186  &container, &instance);
187  }
188 };
189 
190 
191 
192 #define DECLARE_MESSAGE_WRAPPER_CLASS(MessageName) \
193  class MessageName##Wrapper : public MessageName {\
194 public: \
195  explicit MessageName##Wrapper(const OnixS::FIX::Core::Messaging::Message& message) \
196  : MessageName(static_cast<const void*>(&message)) {}\
197  ~MessageName##Wrapper(){}\
198 private: \
199  MessageName##Wrapper(const MessageName##Wrapper&); \
200  MessageName##Wrapper& operator =(const MessageName##Wrapper&); \
201 }; \
202 
222 
223 }}}
224 
225 
static OnixS::FIX::Core::Messaging::RepeatingGroup & getCore(Group &group)
static Group constructGroup(const FieldSet &fieldSet, Tag tag)
unsigned Tag
Alias for tag numbers.
Definition: Tag.h:29
Definition: Defines.h:30
static Group constructGroup(const FieldSet &fieldSet, OnixS::FIX::Core::Messaging::RepeatingGroup &group)
static const OnixS::FIX::Core::Messaging::RepeatingGroup & getCore(const Group &group)
static OnixS::FIX::Core::Messaging::Message & getCore(Message &message)
#define DECLARE_MESSAGE_WRAPPER_CLASS(MessageName)
static GroupInstance constructGroupInstance(const Message &container, OnixS::FIX::Core::Messaging::RepeatingGroupInstance &instance)
static Group constructOptionalGroup(const FieldSet &fieldSet, Tag tag)
static const OnixS::FIX::Core::Messaging::FieldSet & getCore(const FieldSet &fieldSet)
static const OnixS::FIX::Core::Messaging::FieldValue & getCore(const FieldValueRef &value)
static OnixS::FIX::Core::Messaging::FieldSet & getCore(FieldSet &fieldSet)
static FieldValueRef constructField(const FieldSet &fieldSet, Tag tag)
static const OnixS::FIX::Core::Messaging::Message & getCore(const Message &message)