OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
Message.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
22 #include <ostream>
23 #include <string>
24 
28 
29 
30 namespace OnixS
31 {
32  class AccumulatingAllocator;
33 
34  namespace FIX
35  {
36  namespace Core
37  {
38  namespace Messaging
39  {
40  class Message;
41  }
42  }
43  }
44 
45  namespace Eurex
46  {
47  namespace MarketData
48  {
49 
50  /// Encapsulates operations over a FIX Message.
51  ///
52  /// Message supports 'unconstructed' state which can be
53  /// treated as pointer in null state. However, in contrast to
54  /// OnixS::FIX::Group and OnixS::FIX::GroupInstance classes it
55  /// does NOT represent light-weight wrapper over internal structures.
56  /// In fact, it holds all the data which is fully copied on assignment
57  /// or copy construction and disposed at instance destruction.
58  ///
59  /// FIX field related operations now available via OnixS::FIX::FieldSet
60  /// class from which OnixS::FIX::Message class is now derived.
61  class
62  ONIXS_EUREX_EMDI_API
63  Message : public FieldSet
64  {
65  public:
66  /// Initializes instance as deep copy of other one.
67  ///
68  /// @param other Message to be copied from.
69  Message (const Message& other);
70 
71  /// Disposes all internal data structures.
72  ///
73  /// @warning Once instance is destructed, all instances of
74  /// OnixS::FIX::Group and OnixS::FIX::GroupInstance classes
75  /// obtained from this instance must not be used any more.
76  ~Message();
77 
78  /// Returns the message type (MsgType(35) field value).
79  FieldValueRef type() const;
80 
81  /// Returns the message sequence number
82  /// (the MsgSeqNum (tag=34) field value).
83  SequenceNumber seqNum() const;
84 
85  /// Returns the assigned value used to identify
86  /// firm sending message (SenderCompID (49) field value).
87  FieldValueRef senderCompId() const;
88 
89  /// Compares two messages. Comparison is performed
90  /// using 'tag=value' message presentations.
91  bool operator == (const Message&) const;
92 
93  /// Compares two messages. Comparison is performed
94  /// using 'tag=value' message presentations.
95  bool operator != (const Message&) const;
96 
97  /// Returns the string representation of the message using
98  /// the given delimiter and additional control flags.
99  ///
100  /// @param delimiter Defines field delimiter to be used.
101  /// @param flags Affect how message presentation looks like.
102  std::string
103  toString (
104  char delimiter = 0x1,
105  MessageStringingFlags flags =
106  MessageStringingFlag::IncludeFieldTagNumber) const;
107 
108  /// Returns the string representation of the message with field names using
109  /// 0x1 delimiter.
110  std::string
112  {
113  return toString (0x1, MessageStringingFlag::IncludeFieldName);
114  }
115 
116  /// Appends string representation of the message using
117  /// the given delimiter and additional control flags.
118  ///
119  /// @param str String to which presentation is appended.
120  /// @param delimiter Defines field delimiter to be used.
121  /// @param flags Affect how message presentation looks like.
122  void
123  toString (
124  std::string& str,
125  char delimiter = 0x1,
126  MessageStringingFlags flags =
127  MessageStringingFlag::IncludeFieldTagNumber) const;
128 
129 
130 
131  // Reassigns message as copy of other one.
132  Message& operator = (const Message&);
133 
134  private:
135  friend class MessageOperator;
136 
137  friend class ProductSnapshot;
138  friend class InstrumentSnapshot;
139  friend class InstrumentIncremental;
140  friend class VarianceFuturesStatus;
143 
144  friend class DepthSnapshot;
145  friend class DepthIncremental;
146  friend class ProductStateChange;
148  friend class InstrumentStateChange;
149  friend class QuoteRequest;
150  friend class CrossRequest;
153 
154  friend class OpenInterest;
155  friend class Settlement;
156  friend class ExchangeTrade;
157 
158  friend class TopOfBookImplied;
159 
160  Message (const void*);
161 
162  private:
163  AccumulatingAllocator* allocator_;
164  FIX::Core::Messaging::Message* message_;
165 
166  unsigned char impl_[6 * sizeof (size_t)];
167  unsigned char allocatorImpl_[4 * sizeof (size_t)];
168 
169  void construct();
170  void destruct();
171  };
172 
173  inline
174  std::string
175  Message::toString (
176  char delimiter,
177  MessageStringingFlags flags) const
178  {
179  std::string str;
180 
181  toString (str, delimiter, flags);
182 
183  return str;
184  }
185 
186  // Outputs message into standard stream.
187  ONIXS_EUREX_EMDI_API
188  std::ostream&
189  operator << (
190  std::ostream& os,
191  const Message& message);
192  }
193  }
194 }
195 
unsigned int SequenceNumber
Alias for sequence numbers.
bool operator==(const FieldValueRef &ref, const std::string &str)
ONIXS_EUREX_EMDI_API std::ostream & operator<<(std::ostream &os, const Message &message)
Definition: Message.cpp:263
unsigned MessageStringingFlags
Collection of message stringing flags.
Definition: Defines.h:30
bool operator!=(const FieldValueRef &ref, const std::string &str)
std::string toStringWithFieldNames() const
Definition: Message.h:111