forked from carlcook/OrderManagerTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.h
More file actions
55 lines (48 loc) · 1.48 KB
/
types.h
File metadata and controls
55 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef TYPES_H
#define TYPES_H
// A server can insert orders, from the client's perspective
class IOrderServer
{
public:
virtual ~IOrderServer() = default;
virtual void InsertOrder(int volume, double price, int tag, bool side) = 0;
};
// Common arguments when inserting orders
struct InsertArgs
{
const int& mVolume;
const double& mPrice;
const bool& mSide;
};
// A component to check orders before sending them to the market
class IOrderExecutor
{
public:
virtual ~IOrderExecutor() = default;
virtual bool AttemptInsertOrder(const InsertArgs&, int tag) = 0;
};
// A component to handle responses from market modules
class IMarketModuleResponseHandler
{
public:
virtual ~IMarketModuleResponseHandler() = default;
virtual void OnOrderError(int tag) = 0;
};
// A market module sends orders to the market
class IMarketModule
{
public:
virtual ~IMarketModule() = default;
virtual IOrderServer& GetOrderServer() = 0;
virtual void Initialise(IMarketModuleResponseHandler*, IOrderExecutor*) = 0;
virtual void InsertOrder(int volume, double price, int tag, bool side) = 0;
};
// Implementation of the "key passing idiom", with friend access to templated types
class AccessKey {
private:
AccessKey() = default;
AccessKey(const AccessKey&) = default;
template<typename MarketModule> friend void SetupOrderHandlers(MarketModule*); // let handler setup function have access
template<typename InsertHandler> friend class OrderServer; // let server have access
};
#endif // TYPES_H