OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.0.3
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 
25 
45 
46 #include <OnixS/FIX/Core/Messaging.h>
47 #include <OnixS/FIX/Core/Messaging/Exception.h>
48 
49 namespace OnixS {
50 namespace Eurex {
51 namespace MarketData {
52 
54 {
55 public:
56 
57  static
58  const OnixS::FIX::Core::Messaging::FieldValue&
59  getCore(const FieldValueRef& value)
60  {
61  BOOST_ASSERT(value.impl_ != NULL);
62  return *static_cast<const OnixS::FIX::Core::Messaging::FieldValue*>(value.impl_);
63  }
64 
65  static
66  const OnixS::FIX::Core::Messaging::FieldSet&
67  getCore(const FieldSet& fieldSet)
68  {
69  BOOST_ASSERT(fieldSet.impl_ != NULL);
70  return *static_cast<const OnixS::FIX::Core::Messaging::FieldSet*>(fieldSet.impl_);
71  }
72 
73  static
74  OnixS::FIX::Core::Messaging::FieldSet&
75  getCore(FieldSet& fieldSet)
76  {
77  BOOST_ASSERT(fieldSet.impl_ != NULL);
78  return *static_cast<OnixS::FIX::Core::Messaging::FieldSet*>(fieldSet.impl_);
79  }
80 
81  static
82  const OnixS::FIX::Core::Messaging::Message&
83  getCore(const Message& message)
84  {
85  return *message.message_;
86  }
87 
88  static
89  OnixS::FIX::Core::Messaging::Message&
90  getCore(Message& message)
91  {
92  return *message.message_;
93  }
94 
95  static
96  const OnixS::FIX::Core::Messaging::RepeatingGroup&
97  getCore(const Group& group)
98  {
99  BOOST_ASSERT(group.impl_ != NULL);
100  return *static_cast<const OnixS::FIX::Core::Messaging::RepeatingGroup*>(group.impl_);
101  }
102 
103  static
104  OnixS::FIX::Core::Messaging::RepeatingGroup&
105  getCore(Group& group)
106  {
107  BOOST_ASSERT(group.impl_ != NULL);
108  return *static_cast<OnixS::FIX::Core::Messaging::RepeatingGroup*>(group.impl_);
109  }
110 
111  static
114  const FieldSet& fieldSet,
115  Tag tag)
116  {
117  return FieldValueRef(fieldSet.container_, &(getCore(fieldSet)[tag]));
118  }
119 
120  static
121  Group
123  const FieldSet& fieldSet,
124  OnixS::FIX::Core::Messaging::RepeatingGroup& group)
125  {
126  return Group(fieldSet.container_, &group);
127  }
128 
129  static
130  Group
132  const FieldSet& fieldSet,
133  Tag tag)
134  {
135  return constructGroup(
136  fieldSet,
138  CompliantAccessor::getRepeatingGroup(
139  getCore(const_cast<FieldSet&>(fieldSet)),
140  tag));
141  }
142 
143  static Group constructOptionalGroup(const FieldSet& fieldSet, Tag tag)
144  {
145  const OnixS::FIX::Core::Messaging::FieldSet& coreFieldSet = getCore(fieldSet);
146  const OnixS::FIX::Core::Messaging::FieldSetStructure& coreFieldSetStructure = coreFieldSet.structure();
147  const OnixS::FIX::Core::Messaging::FieldIndex groupIndex = coreFieldSetStructure.find(tag);
148  const OnixS::FIX::Core::Messaging::FieldIndex outOfRange = OnixS::FIX::Core::Messaging::FieldIndexTraits::OutOfRange;
149 
150  if (outOfRange == groupIndex ||
151  NULL == coreFieldSetStructure[groupIndex].repeatingGroup())
152  {
153  throw OnixS::FIX::Core::Messaging::CompliantAccessException(
154  coreFieldSet,
155  tag,
156  OnixS::FIX::Core::Messaging::CompliantAccessIssues::UndefinedRepeatingGroup);
157  }
158 
159  const OnixS::FIX::Core::Messaging::FieldValue& fieldValue = coreFieldSet.indexed()[groupIndex];
160  const OnixS::FIX::Core::Messaging::RepeatingGroup* repeatingGroup;
161 
162  if (fieldValue.convertTo(repeatingGroup))
163  return Group(fieldSet.container_, const_cast<OnixS::FIX::Core::Messaging::RepeatingGroup*>(repeatingGroup));
164 
165  if (OnixS::FIX::Core::Messaging::FieldValueTraits::isNull(fieldValue))
166  return Group(fieldSet.container_, NULL);
167 
168  throw OnixS::FIX::Core::Messaging::BadCastException(
169  coreFieldSet,
170  tag,
171  fieldValue,
172  OnixS::FIX::Core::Messaging::DataTypes::RepeatingGroup);
173 
174  }
175 
176  static
179  const Message& container,
181  RepeatingGroupInstance& instance)
182  {
183  return GroupInstance(
184  &container, &instance);
185  }
186 };
187 
188 
189 
190 #define DECLARE_MESSAGE_WRAPPER_CLASS(MessageName) \
191  class MessageName##Wrapper : public MessageName {\
192 public: \
193  MessageName##Wrapper(const OnixS::FIX::Core::Messaging::Message& message) \
194  : MessageName(static_cast<const void*>(&message)) {}\
195  ~MessageName##Wrapper(){}\
196 private: \
197  MessageName##Wrapper(const MessageName##Wrapper&); \
198  MessageName##Wrapper& operator =(const MessageName##Wrapper&); \
199 }; \
200 
220 
221 }}}
222 
223 
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: Group.h:25
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)