Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 40d2d95

Browse files
committed
完善 EventBase ;
1 parent 2814a41 commit 40d2d95

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

include/events/event_interface.hpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
#ifndef mirai_cpp_events_event_interface_hpp_H_
33
#define mirai_cpp_events_event_interface_hpp_H_
44
#include "mirai_event.hpp"
@@ -11,19 +11,40 @@ namespace Cyan
1111
public:
1212
EventBase() : bot_(nullptr) {}
1313

14+
EventBase(const EventBase& eb)
15+
{
16+
this->bot_ = eb.bot_;
17+
}
18+
19+
EventBase(EventBase&& eb) noexcept: bot_(nullptr)
20+
{
21+
std::swap(this->bot_, eb.bot_);
22+
}
23+
24+
EventBase& operator=(const EventBase& eb)
25+
{
26+
EventBase tmp(eb);
27+
std::swap(this->bot_, tmp.bot_);
28+
return *this;
29+
}
30+
31+
virtual ~EventBase() = default;
32+
1433
static MiraiEvent GetMiraiEvent()
1534
{
1635
return MiraiEvent::Default;
1736
}
37+
1838
virtual void SetMiraiBot(MiraiBot* bot)
1939
{
2040
this->bot_ = bot;
2141
}
42+
2243
virtual MiraiBot& GetMiraiBot()
2344
{
2445
return *bot_;
2546
}
26-
virtual ~EventBase() {}
47+
2748
protected:
2849
MiraiBot* bot_;
2950
};

0 commit comments

Comments
 (0)