OnixS C++ SGX Titan OUCH Trading Handler  1.2.0
API documentation
ListenerHolder.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 #pragma once
20 
21 #include <logging/LogFacility.h>
22 
23 #include <OnixS/HandlerCore/HandlerLogger.h>
24 
28 
29 
30 namespace OnixS {
31 
32 namespace HandlerCore {
33 namespace Common {
34 
35 class HandlerLogger;
36 
37 }}
38 
39 namespace SgxTitan {
40 namespace Trading {
41 namespace Ouch {
42 
43 class ErrorListener;
44 class WarningListener;
45 class HandlerStateListener;
46 class MessageListener;
47 class SessionListener;
48 
49 ONIXS_SGXTITAN_OUCH_API_DECL(struct, OrderAccepted);
50 ONIXS_SGXTITAN_OUCH_API_DECL(struct, OrderRejected);
51 ONIXS_SGXTITAN_OUCH_API_DECL(struct, OrderReplaced);
52 ONIXS_SGXTITAN_OUCH_API_DECL(struct, OrderCancelled);
53 ONIXS_SGXTITAN_OUCH_API_DECL(struct, OrderExecuted);
54 
55 namespace Implementation {
56 
57 class ListenerHolder : public Logging::LogFacility
58 {
59  typedef OnixS::Logging::LogFacility base;
60 
61 public:
62  ListenerHolder (const Logging::LogFacility* parent, OnixS::HandlerCore::Common::HandlerLogger& logger);
63 
64  /*
65  Assign listeners
66  */
67 
68  void set (ErrorListener* listener)
69  {
70  errorListener_ = listener;
71  }
72 
73  void set (WarningListener* listener)
74  {
75  warningListener_ = listener;
76  }
77 
78  void set (HandlerStateListener* listener)
79  {
80  handlerStateListener_ = listener;
81  }
82 
83  void set (SessionListener* listener)
84  {
85  sessionListener_ = listener;
86  }
87 
88  void set (MessageListener* listener)
89  {
90  messageListener_ = listener;
91  }
92 
93  /*
94  User callback's
95  */
96 
97  void invokeError (ErrorCode::Enum code, const std::string& description);
98  void invokeWarning (const std::string& description);
99  void invokeStateChanged (HandlerState::Enum newState);
100  void invokeReceivedBytes(const char* bytes, size_t size);
101  //void invokeHeartbeat(const Heartbeat& msg, const MessageInfo& msgInfo);
102 
103  void invokeReplayCompleted();
104 
105 
106  void invoke(const OrderAccepted&);
107  void invoke(const OrderRejected&);
108  void invoke(const OrderReplaced&);
109  void invoke(const OrderCancelled&);
110  void invoke(const OrderExecuted&);
111 
112  template<typename TMsg>
113  void log (const TMsg & msg) { logger_.log (msg); }
114 
115 private:
116  OnixS::HandlerCore::Common::HandlerLogger& logger_;
117 
118  ErrorListener* errorListener_;
119  WarningListener* warningListener_;
120  HandlerStateListener* handlerStateListener_;
121 
122  SessionListener* sessionListener_;
123  MessageListener* messageListener_;
124 };
125 
126 typedef boost::scoped_ptr<ListenerHolder> ListenerHolderPtr;
127 
128 }
129 
130 }}}}
Incoming (CFE to TPH) message listener.
Enum
Defines the state that the handler is in.
#define ONIXS_SGXTITAN_OUCH_API_DECL(typeKind, typeName)
Definition: ABI.h:30
boost::scoped_ptr< ListenerHolder > ListenerHolderPtr
Enum
Known (selected) error codes.
Definition: ErrorListener.h:33