OnixS C++ SGX Titan OUCH Trading Handler  1.2.0
API documentation
HandlerImpl.Processing.cpp
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 */
22 
23 #include "ListenerHolder.h"
24 #include "ProtocolFormatting.h"
25 #include "HandlerImpl.h"
26 #include "AuditTrailDumper.h"
27 
28 
29 using namespace OnixS::SgxTitan::Trading::Ouch;
31 
32 
33 void HandlerImpl::processData(const void* dataPtr, UInt16 messageLength)
34 {
35  const IncomingMessage message(dataPtr, messageLength);
36  const InboundMessageTypes::Enum messageType = message.type();
37 
38  if (InboundMessageTypes::OrderAccepted == messageType)
39  {
40  OrderAccepted::validateSize(messageLength);
41  const OrderAccepted& msg = OrderAccepted(dataPtr, messageLength);
42 
43  log(ONIXS_LOG_DEBUG[this] << "Received " << msg);
44 
45  listenerHolder_->invoke(msg);
46  }
47  else if (InboundMessageTypes::OrderRejected == messageType)
48  {
49  OrderRejected::validateSize(messageLength);
50  const OrderRejected& msg = OrderRejected(dataPtr, messageLength);
51 
52  log(ONIXS_LOG_DEBUG[this] << "Received " << msg);
53 
54  listenerHolder_->invoke(msg);
55  }
56  else if (InboundMessageTypes::OrderReplaced == messageType)
57  {
58  OrderReplaced::validateSize(messageLength);
59  const OrderReplaced& msg = OrderReplaced(dataPtr, messageLength);
60 
61  log(ONIXS_LOG_DEBUG[this] << "Received " << msg);
62 
63  listenerHolder_->invoke(msg);
64  }
65  else if (InboundMessageTypes::OrderCancelled == messageType)
66  {
67  OrderCancelled::validateSize(messageLength);
68  const OrderCancelled& msg = OrderCancelled(dataPtr, messageLength);
69 
70  log(ONIXS_LOG_DEBUG[this] << "Received " << msg);
71 
72  listenerHolder_->invoke(msg);
73  }
74  else if (InboundMessageTypes::OrderExecuted == messageType)
75  {
76  OrderExecuted::validateSize(messageLength);
77  const OrderExecuted& msg = OrderExecuted(dataPtr, messageLength);
78 
79  log(ONIXS_LOG_DEBUG[this] << "Received " << msg);
80 
81  listenerHolder_->invoke(msg);
82  }
83  else
84  log(ONIXS_LOG_WARN[this] << "Received unknown message, type = " << static_cast<Binary1>(message.type()));
85 
86  if (auditTrailDumper_)
87  auditTrailDumper_->onInboundMessage(dataPtr, messageLength);
88 }
static void validateSize(MessageSize size)
Check the given size.
static void validateSize(MessageSize size)
Check the given size.
Definition: OrderExecuted.h:83
static void validateSize(MessageSize size)
Check the given size.
Definition: OrderRejected.h:56
static void validateSize(MessageSize size)
Check the given size.
static void validateSize(MessageSize size)
Check the given size.