Skip to content

Commit

Permalink
Use dependency ejection to remove json include from API
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Oct 15, 2024
1 parent 787774c commit fe6ebca
Show file tree
Hide file tree
Showing 7 changed files with 2,578 additions and 368 deletions.
447 changes: 217 additions & 230 deletions include/tgbot/Api.h

Large diffs are not rendered by default.

2,219 changes: 2,219 additions & 0 deletions include/tgbot/ApiImpl.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions include/tgbot/Bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TGBOT_API Bot {
* @return Object which can execute Telegram Bot API methods.
*/
inline const Api& getApi() const {
return _api;
return *_api;
}

/**
Expand All @@ -55,7 +55,7 @@ class TGBOT_API Bot {
static HttpClient &_getDefaultHttpClient();

const std::string _token;
const Api _api;
const std::shared_ptr<Api> _api;
std::unique_ptr<EventBroadcaster> _eventBroadcaster;
const EventHandler _eventHandler;
};
Expand Down
6 changes: 3 additions & 3 deletions include/tgbot/net/TgLongPoll.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TGBOT_TGLONGPOLL_H
#define TGBOT_TGLONGPOLL_H

#include "tgbot/Api.h"
#include "tgbot/ApiImpl.h"
#include "tgbot/export.h"

#include <cstdint>
Expand All @@ -22,7 +22,7 @@ class EventHandler;
class TGBOT_API TgLongPoll {

public:
TgLongPoll(const Api* api, const EventHandler* eventHandler, std::int32_t limit, std::int32_t timeout, std::shared_ptr<std::vector<std::string>> allowUpdates);
TgLongPoll(const ApiImpl* api, const EventHandler* eventHandler, std::int32_t limit, std::int32_t timeout, std::shared_ptr<std::vector<std::string>> allowUpdates);
TgLongPoll(const Bot& bot, std::int32_t limit = 100, std::int32_t timeout = 10, const std::shared_ptr<std::vector<std::string>>& allowUpdates = nullptr);

/**
Expand All @@ -31,7 +31,7 @@ class TGBOT_API TgLongPoll {
void start();

private:
const Api* _api;
const ApiImpl* _api;
const EventHandler* _eventHandler;
std::int32_t _lastUpdateId = 0;
std::int32_t _limit;
Expand Down
Loading

0 comments on commit fe6ebca

Please sign in to comment.