Move SecretChatLogEventBase to SecretChatEvent.h.

GitOrigin-RevId: f660d722323297f70dd21e6d4c927936188e7d03
This commit is contained in:
levlam 2019-02-22 18:33:14 +03:00
parent 168add9006
commit 720df7ff12
2 changed files with 17 additions and 16 deletions

View File

@ -185,6 +185,7 @@ class StorerImpl : public Storer {
private:
const T &event_;
};
} // namespace detail
template <class ChildT>
@ -199,18 +200,6 @@ class LogEventBase : public LogEvent {
}
};
template <class ChildT, class ParentT>
class LogEventHelper : public ParentT {
public:
typename ParentT::Type get_type() const override {
return ChildT::type;
}
constexpr int32 magic() const {
return static_cast<int32>(get_type());
}
};
class LogEventParser : public WithVersion<WithContext<TlParser, Global *>> {
public:
explicit LogEventParser(Slice data) : WithVersion<WithContext<TlParser, Global *>>(data) {

View File

@ -46,6 +46,18 @@ class SecretChatEvent : public LogEventBase<SecretChatEvent> {
static void downcast_call(Type type, F &&f);
};
template <class ChildT>
class SecretChatLogEventBase : public SecretChatEvent {
public:
typename SecretChatEvent::Type get_type() const override {
return ChildT::type;
}
constexpr int32 magic() const {
return static_cast<int32>(get_type());
}
};
// Internal structure
// inputEncryptedFileEmpty#1837c364 = InputEncryptedFile;
@ -191,7 +203,7 @@ inline StringBuilder &operator<<(StringBuilder &sb, const EncryptedFileLocation
// LogEvents
// TODO: Qts and SeqNoState could be just Logevents that are updated during regenerate
class InboundSecretMessage : public LogEventHelper<InboundSecretMessage, SecretChatEvent> {
class InboundSecretMessage : public SecretChatLogEventBase<InboundSecretMessage> {
public:
static constexpr Type type = SecretChatEvent::Type::InboundSecretMessage;
int32 qts = 0;
@ -289,7 +301,7 @@ class InboundSecretMessage : public LogEventHelper<InboundSecretMessage, SecretC
}
};
class OutboundSecretMessage : public LogEventHelper<OutboundSecretMessage, SecretChatEvent> {
class OutboundSecretMessage : public SecretChatLogEventBase<OutboundSecretMessage> {
public:
static constexpr Type type = SecretChatEvent::Type::OutboundSecretMessage;
@ -390,7 +402,7 @@ class OutboundSecretMessage : public LogEventHelper<OutboundSecretMessage, Secre
}
};
class CloseSecretChat : public LogEventHelper<CloseSecretChat, SecretChatEvent> {
class CloseSecretChat : public SecretChatLogEventBase<CloseSecretChat> {
public:
static constexpr Type type = SecretChatEvent::Type::CloseSecretChat;
int32 chat_id = 0;
@ -412,7 +424,7 @@ class CloseSecretChat : public LogEventHelper<CloseSecretChat, SecretChatEvent>
}
};
class CreateSecretChat : public LogEventHelper<CreateSecretChat, SecretChatEvent> {
class CreateSecretChat : public SecretChatLogEventBase<CreateSecretChat> {
public:
static constexpr Type type = SecretChatEvent::Type::CreateSecretChat;
int32 random_id = 0;