Remove LogEventBase.

This commit is contained in:
levlam 2021-07-05 05:12:04 +03:00
parent 4f328d14f8
commit 69c630115a
2 changed files with 17 additions and 27 deletions

View File

@ -136,12 +136,6 @@ int32 magic(EventT &event) {
return static_cast<int32>(event.get_type());
}
template <class EventT, class StorerT>
void store(const EventT &event, StorerT &storer) {
EventT::downcast_call(event.get_type(),
[&](auto *ptr) { static_cast<const std::decay_t<decltype(*ptr)> &>(event).store(storer); });
}
template <class DestT, class T>
Result<unique_ptr<DestT>> from_parser(T &&parser) {
auto version = parser.fetch_int();
@ -163,11 +157,6 @@ Result<unique_ptr<DestT>> from_parser(T &&parser) {
return Status::Error(PSLICE() << "Unknown SecretChatEvent type: " << format::as_hex(magic));
}
template <class DestT>
Result<unique_ptr<DestT>> from_buffer_slice(BufferSlice slice) {
return from_parser<DestT>(WithVersion<WithContext<TlBufferParser, Global *>>{&slice});
}
template <class T>
class StorerImpl final : public Storer {
public:
@ -199,18 +188,6 @@ class StorerImpl final : public Storer {
} // namespace detail
template <class ChildT>
class LogEventBase : public LogEvent {
public:
template <class StorerT>
void store(StorerT &storer) const {
detail::store(static_cast<const ChildT &>(*this), storer);
}
static Result<unique_ptr<ChildT>> from_buffer_slice(BufferSlice slice) {
return detail::from_buffer_slice<ChildT>(std::move(slice));
}
};
class LogEventParser final : public WithVersion<WithContext<TlParser, Global *>> {
public:
explicit LogEventParser(Slice data) : WithVersion<WithContext<TlParser, Global *>>(data) {

View File

@ -6,7 +6,11 @@
//
#pragma once
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/actor/PromiseFuture.h"
@ -15,15 +19,14 @@
#include "td/utils/format.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/tl_parsers.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include <type_traits>
namespace td {
namespace log_event {
class SecretChatEvent : public LogEventBase<SecretChatEvent> {
class SecretChatEvent : public LogEvent {
public:
// append only enum
enum class Type : int32 {
@ -41,6 +44,16 @@ class SecretChatEvent : public LogEventBase<SecretChatEvent> {
template <class F>
static void downcast_call(Type type, F &&f);
template <class StorerT>
void store(StorerT &storer) const {
downcast_call(get_type(),
[&](auto *ptr) { static_cast<const std::decay_t<decltype(*ptr)> *>(this)->store(storer); });
}
static Result<unique_ptr<SecretChatEvent>> from_buffer_slice(BufferSlice slice) {
return detail::from_parser<SecretChatEvent>(WithVersion<WithContext<TlBufferParser, Global *>>{&slice});
}
};
template <class ChildT>