22#include " aos/best_ask/best_ask.h"
33#include " aos/best_bid/best_bid.h"
44#include " aos/trading_pair/trading_pair.h"
5+
56namespace aoe {
67namespace binance {
7- namespace spot {
8- namespace main_net {
8+
9+ // Общий базовый интерфейс инфраструктуры
910class InfrastructureInterface {
1011 public:
1112 virtual ~InfrastructureInterface () = default ;
1213 virtual void Register (aos::TradingPair trading_pair) = 0;
14+ virtual void StartAsync () = 0;
15+ virtual void StopAsync () = 0;
1316};
1417
18+ // Шаблонный интерфейс уведомлений по изменению best bid/ask
1519template <typename Price, typename Qty>
1620class InfrastructureNotifierOnBestBidChangeInterface {
1721 public:
1822 virtual ~InfrastructureNotifierOnBestBidChangeInterface () = default ;
19- /* *
20- * @brief Sets a callback to be invoked on best bid changes for a trading
21- * pair.
22- *
23- * If a context exists for the specified trading pair, the callback will be
24- * registered and the method returns true. Otherwise, no callback is
25- * registered and the method returns false.
26- *
27- * @param cb The callback function to be called when the best bid changes.
28- * It receives the trading pair and the updated best bid as
29- * arguments.
30- * @return true if the context for the trading pair exists and the callback
31- * was set; false otherwise.
32- */
3323 virtual bool SetCallbackOnBestBidChange (
3424 aos::TradingPair trading_pair,
3525 std::function<void (aos::BestBid<Price, Qty>& new_bid)> cb) = 0;
@@ -39,97 +29,58 @@ template <typename Price, typename Qty>
3929class InfrastructureNotifierOnBestAskChangeInterface {
4030 public:
4131 virtual ~InfrastructureNotifierOnBestAskChangeInterface () = default ;
42- /* *
43- * @brief Sets a callback to be invoked on best ask changes for a trading
44- * pair.
45- *
46- * If a context exists for the specified trading pair, the callback will be
47- * registered and the method returns true. Otherwise, no callback is
48- * registered and the method returns false.
49- *
50- * @param cb The callback function to be called when the best ask changes.
51- * It receives the trading pair and the updated best ask as
52- * arguments.
53- * @return true if the context for the trading pair exists and the callback
54- * was set; false otherwise.
55- */
5632 virtual bool SetCallbackOnBestAskChange (
5733 aos::TradingPair trading_pair,
5834 std::function<void (aos::BestAsk<Price, Qty>& new_ask)> cb) = 0;
5935};
6036
61- template <typename Price, typename Qty>
62- class InfrastructureNotifierInterface
63- : public InfrastructureNotifierOnBestBidChangeInterface<Price, Qty>,
64- public InfrastructureNotifierOnBestAskChangeInterface<Price, Qty> {
65- public:
66- ~InfrastructureNotifierInterface () override = default ;
67- };
68- }; // namespace main_net
69- }; // namespace spot
70-
71- namespace futures {
72- namespace main_net {
73- class InfrastructureInterface {
74- public:
75- virtual ~InfrastructureInterface () = default ;
76- virtual void Register (aos::TradingPair trading_pair) = 0;
77- };
78-
79- template <typename Price, typename Qty>
80- class InfrastructureNotifierOnBestBidChangeInterface {
37+ template <typename Price>
38+ class InfrastructureNotifierOnBestBidPriceChangeInterface {
8139 public:
82- virtual ~InfrastructureNotifierOnBestBidChangeInterface () = default ;
83- /* *
84- * @brief Sets a callback to be invoked on best bid changes for a trading
85- * pair.
86- *
87- * If a context exists for the specified trading pair, the callback will be
88- * registered and the method returns true. Otherwise, no callback is
89- * registered and the method returns false.
90- *
91- * @param cb The callback function to be called when the best bid changes.
92- * It receives the trading pair and the updated best bid as
93- * arguments.
94- * @return true if the context for the trading pair exists and the callback
95- * was set; false otherwise.
96- */
97- virtual bool SetCallbackOnBestBidChange (
40+ virtual ~InfrastructureNotifierOnBestBidPriceChangeInterface () = default ;
41+ virtual bool SetCallbackOnBestBidPriceChange (
9842 aos::TradingPair trading_pair,
99- std::function<void (aos::BestBid< Price, Qty>& new_bid )> cb) = 0;
43+ std::function<void (Price& new_bid_price )> cb) = 0;
10044};
10145
102- template <typename Price, typename Qty >
103- class InfrastructureNotifierOnBestAskChangeInterface {
46+ template <typename Price>
47+ class InfrastructureNotifierOnBestAskPriceChangeInterface {
10448 public:
105- virtual ~InfrastructureNotifierOnBestAskChangeInterface () = default ;
106- /* *
107- * @brief Sets a callback to be invoked on best ask changes for a trading
108- * pair.
109- *
110- * If a context exists for the specified trading pair, the callback will be
111- * registered and the method returns true. Otherwise, no callback is
112- * registered and the method returns false.
113- *
114- * @param cb The callback function to be called when the best ask changes.
115- * It receives the trading pair and the updated best ask as
116- * arguments.
117- * @return true if the context for the trading pair exists and the callback
118- * was set; false otherwise.
119- */
120- virtual bool SetCallbackOnBestAskChange (
49+ virtual ~InfrastructureNotifierOnBestAskPriceChangeInterface () = default ;
50+ virtual bool SetCallbackOnBestAskPriceChange (
12151 aos::TradingPair trading_pair,
122- std::function<void (aos::BestAsk< Price, Qty>& new_ask )> cb) = 0;
52+ std::function<void (Price& new_ask_price )> cb) = 0;
12353};
12454
55+ // Объединённый интерфейс уведомлений
12556template <typename Price, typename Qty>
12657class InfrastructureNotifierInterface
12758 : public InfrastructureNotifierOnBestBidChangeInterface<Price, Qty>,
128- public InfrastructureNotifierOnBestAskChangeInterface<Price, Qty> {
59+ public InfrastructureNotifierOnBestAskChangeInterface<Price, Qty>,
60+ public InfrastructureNotifierOnBestBidPriceChangeInterface<Price>,
61+ public InfrastructureNotifierOnBestAskPriceChangeInterface<Price> {
12962 public:
13063 ~InfrastructureNotifierInterface () override = default ;
13164};
132- }; // namespace main_net
133- }; // namespace futures
134- }; // namespace binance
135- }; // namespace aoe
65+
66+ // Пространство имён для Spot и Futures с alias-ами
67+ namespace spot {
68+ namespace main_net {
69+ using Infrastructure = InfrastructureInterface;
70+ template <typename Price, typename Qty>
71+ using InfrastructureNotifierInterface =
72+ InfrastructureNotifierInterface<Price, Qty>;
73+ } // namespace main_net
74+ } // namespace spot
75+
76+ namespace futures {
77+ namespace main_net {
78+ using Infrastructure = InfrastructureInterface;
79+ template <typename Price, typename Qty>
80+ using InfrastructureNotifierInterface =
81+ InfrastructureNotifierInterface<Price, Qty>;
82+ } // namespace main_net
83+ } // namespace futures
84+
85+ } // namespace binance
86+ } // namespace aoe
0 commit comments