Skip to content

Commit

Permalink
Remove event_subscriber declaration from event_bus.h
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade committed Aug 3, 2020
1 parent f59bee0 commit 308e02d
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 20 deletions.
9 changes: 8 additions & 1 deletion src/achievement.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@
#include <unordered_set>
#include <vector>

#include "event_bus.h"
#include "calendar.h"
#include "cata_variant.h"
#include "enum_traits.h"
#include "event_subscriber.h"
#include "optional.h"
#include "string_id.h"
#include "translations.h"

class JsonObject;
struct achievement_requirement;
class achievements_tracker;
namespace cata
{
class event;
} // namespace cata
class requirement_watcher;
class stats_tracker;

Expand Down
2 changes: 2 additions & 0 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "computer_session.h"
#include "debug.h"
#include "enums.h"
#include "event.h"
#include "event_bus.h"
#include "game.h"
#include "gates.h"
#include "iexamine.h"
Expand Down
2 changes: 2 additions & 0 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "dialogue_chatbin.h"
#include "enum_conversions.h"
#include "enums.h"
#include "event.h"
#include "event_bus.h"
#include "faction.h"
#include "filesystem.h"
#include "game.h"
Expand Down
17 changes: 1 addition & 16 deletions src/event_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,7 @@

#include "event.h"

class event_bus;

class event_subscriber
{
public:
event_subscriber() = default;
event_subscriber( const event_subscriber & ) = delete;
event_subscriber &operator=( const event_subscriber & ) = delete;
virtual ~event_subscriber();
virtual void notify( const cata::event & ) = 0;
private:
friend class event_bus;
void on_subscribe( event_bus * );
void on_unsubscribe( event_bus * );
event_bus *subscribed_to = nullptr;
};
class event_subscriber;

class event_bus
{
Expand Down
25 changes: 25 additions & 0 deletions src/event_subscriber.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CATA_SRC_EVENT_SUBSCRIBER_H
#define CATA_SRC_EVENT_SUBSCRIBER_H

namespace cata
{
class event;
} // namespace cata
class event_bus;

class event_subscriber
{
public:
event_subscriber() = default;
event_subscriber( const event_subscriber & ) = delete;
event_subscriber &operator=( const event_subscriber & ) = delete;
virtual ~event_subscriber();
virtual void notify( const cata::event & ) = 0;
private:
friend class event_bus;
void on_subscribe( event_bus * );
void on_unsubscribe( event_bus * );
event_bus *subscribed_to = nullptr;
};

#endif // CATA_SRC_EVENT_SUBSCRIBER_H
2 changes: 1 addition & 1 deletion src/kill_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>
#include <vector>

#include "event_bus.h"
#include "event_subscriber.h"
#include "type_id.h"

class JsonIn;
Expand Down
1 change: 1 addition & 0 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "enum_conversions.h"
#include "enums.h"
#include "event.h"
#include "event_bus.h"
#include "field.h"
#include "game.h"
#include "generic_factory.h"
Expand Down
2 changes: 1 addition & 1 deletion src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "bodypart.h"
#include "damage.h"
#include "enum_bitset.h"
#include "event_bus.h"
#include "event_subscriber.h"
#include "optional.h"
#include "point.h"
#include "sounds.h"
Expand Down
7 changes: 6 additions & 1 deletion src/memorial_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
#include <string>
#include <vector>

#include "event_bus.h"
#include "calendar.h"
#include "event_subscriber.h"
#include "string_formatter.h"
#include "type_id.h"

namespace cata
{
class event;
} // namespace cata
class JsonIn;
class JsonOut;


class memorial_log_entry
{
Expand Down
1 change: 1 addition & 0 deletions src/stats_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "cata_variant.h"
#include "event.h"
#include "event_bus.h"
#include "event_subscriber.h"
#include "hash_utils.h"
#include "string_id.h"

Expand Down
1 change: 1 addition & 0 deletions tests/memorial_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "character_id.h"
#include "debug_menu.h"
#include "event.h"
#include "event_bus.h"
#include "filesystem.h"
#include "memorial_logger.h"
#include "mutation.h"
Expand Down

0 comments on commit 308e02d

Please sign in to comment.