GOG GALAXY SDK Documentation
IListenerRegistrar.h
Go to the documentation of this file.
1 #ifndef GALAXY_I_LISTENER_REGISTRAR_H
2 #define GALAXY_I_LISTENER_REGISTRAR_H
3 
9 #include "stdint.h"
10 #include <stdlib.h>
11 #include "GalaxyExport.h"
12 
13 namespace galaxy
14 {
15  namespace api
16  {
29  {
38  AUTH,
84  LOBBY_DATA_UPDATE_LISTENER,
91  };
92 
97  {
98  public:
99 
100  virtual ~IGalaxyListener()
101  {
102  }
103  };
104 
109  template<ListenerType type> class GalaxyTypeAwareListener : public IGalaxyListener
110  {
111  public:
112 
119  {
120  return type;
121  }
122  };
123 
130  {
131  public:
132 
133  virtual ~IListenerRegistrar()
134  {
135  }
136 
147  virtual void Register(ListenerType listenerType, IGalaxyListener* listener) = 0;
148 
158  virtual void Unregister(ListenerType listenerType, IGalaxyListener* listener) = 0;
159  };
160 
171  GALAXY_DLL_EXPORT IListenerRegistrar* GALAXY_CALLTYPE ListenerRegistrar();
172 
185  GALAXY_DLL_EXPORT IListenerRegistrar* GALAXY_CALLTYPE GameServerListenerRegistrar();
186 
202  template<typename _TypeAwareListener, IListenerRegistrar*(*_Registrar)() = ListenerRegistrar>
203  class SelfRegisteringListener : public _TypeAwareListener
204  {
205  public:
206 
214  {
215  if (_Registrar())
216  _Registrar()->Register(_TypeAwareListener::GetListenerType(), this);
217  }
218 
225  {
226  if (_Registrar())
227  _Registrar()->Unregister(_TypeAwareListener::GetListenerType(), this);
228  }
229  };
230 
232  }
233 }
234 
235 #endif
Contains a macro used for DLL export.
The class that is inherited by all specific callback listeners and provides a static method that retu...
Definition: IListenerRegistrar.h:110
static ListenerType GetListenerType()
Returns the type of the listener.
Definition: IListenerRegistrar.h:118
The interface that is implemented by all specific callback listeners.
Definition: IListenerRegistrar.h:97
The class that enables and disables global registration of the instances of specific listeners.
Definition: IListenerRegistrar.h:130
virtual void Unregister(ListenerType listenerType, IGalaxyListener *listener)=0
Unregisters a listener previously globally registered with Register() or registered for specific acti...
virtual void Register(ListenerType listenerType, IGalaxyListener *listener)=0
Globally registers a callback listener that inherits from IGalaxyListener and is of any of the standa...
The class that is inherited by the self-registering versions of all specific callback listeners.
Definition: IListenerRegistrar.h:204
SelfRegisteringListener()
Creates an instance of SelfRegisteringListener and registers it with the IListenerRegistrar provided ...
Definition: IListenerRegistrar.h:213
~SelfRegisteringListener()
Destroys the instance of SelfRegisteringListener and unregisters it with the instance of IListenerReg...
Definition: IListenerRegistrar.h:224
GALAXY_DLL_EXPORT IListenerRegistrar *GALAXY_CALLTYPE GameServerListenerRegistrar()
Returns an instance of IListenerRegistrar interface the for Game Server entity.
GALAXY_DLL_EXPORT IListenerRegistrar *GALAXY_CALLTYPE ListenerRegistrar()
Returns an instance of IListenerRegistrar.
ListenerType
Listener type.
Definition: IListenerRegistrar.h:29
@ LEADERBOARD_SCORE_UPDATE_LISTENER
Used by ILeaderboardScoreUpdateListener.
Definition: IListenerRegistrar.h:47
@ CHAT_ROOM_MESSAGE_SEND_LISTENER
Used by IChatRoomMessageSendListener.
Definition: IListenerRegistrar.h:72
@ ACCESS_TOKEN_CHANGE
Used by IAccessTokenListener.
Definition: IListenerRegistrar.h:54
@ CHAT_ROOM_WITH_USER_RETRIEVE_LISTENER
Used by IChatRoomWithUserRetrieveListener.
Definition: IListenerRegistrar.h:71
@ LOBBY_DATA_RETRIEVE
Used by ILobbyDataRetrieveListener.
Definition: IListenerRegistrar.h:61
@ ACHIEVEMENT_CHANGE
Used by IAchievementChangeListener.
Definition: IListenerRegistrar.h:44
@ FRIEND_INVITATION_SEND_LISTENER
Used by IFriendInvitationSendListener.
Definition: IListenerRegistrar.h:74
@ FRIEND_LIST_RETRIEVE
Used by IFriendListListener.
Definition: IListenerRegistrar.h:52
@ LISTENER_TYPE_BEGIN
Used for iterating over listener types.
Definition: IListenerRegistrar.h:30
@ LOBBY_LEFT
Used by ILobbyLeftListener.
Definition: IListenerRegistrar.h:34
@ LISTENER_TYPE_END
Used for iterating over listener types.
Definition: IListenerRegistrar.h:90
@ SENT_FRIEND_INVITATION_LIST_RETRIEVE_LISTENER
Used by ISentFriendInvitationListRetrieveListener.
Definition: IListenerRegistrar.h:83
@ RICH_PRESENCE_CHANGE_LISTENER
Used by IRichPresenceChangeListener.
Definition: IListenerRegistrar.h:49
@ OTHER_SESSION_START
Used by IOtherSessionStartListener.
Definition: IListenerRegistrar.h:63
@ LOBBY_ENTERED
Used by ILobbyEnteredListener.
Definition: IListenerRegistrar.h:33
@ USER_FIND_LISTENER
Used by IUserFindListener.
Definition: IListenerRegistrar.h:81
@ CUSTOM_NETWORKING_CONNECTION_OPEN
Used by IConnectionOpenListener.
Definition: IListenerRegistrar.h:66
@ USER_TIME_PLAYED_RETRIEVE
Used by IUserTimePlayedRetrieveListener.
Definition: IListenerRegistrar.h:62
@ CHAT_ROOM_MESSAGES_RETRIEVE_LISTENER
Used by IChatRoomMessagesRetrieveListener.
Definition: IListenerRegistrar.h:80
@ OVERLAY_VISIBILITY_CHANGE
Used by IOverlayVisibilityChangeListener.
Definition: IListenerRegistrar.h:70
@ FRIEND_INVITATION_LISTENER
Used by IFriendInvitationListener.
Definition: IListenerRegistrar.h:76
@ SHARED_FILE_DOWNLOAD
Used by ISharedFileDownloadListener.
Definition: IListenerRegistrar.h:65
@ LEADERBOARD_ENTRIES_RETRIEVE
Used by ILeaderboardEntriesRetrieveListener.
Definition: IListenerRegistrar.h:46
@ RICH_PRESENCE_LISTENER
Used by IRichPresenceListener.
Definition: IListenerRegistrar.h:58
@ GAME_INVITATION_RECEIVED_LISTENER
Used by IGameInvitationReceivedListener.
Definition: IListenerRegistrar.h:59
@ NAT_TYPE_DETECTION
Used by INatTypeDetectionListener.
Definition: IListenerRegistrar.h:82
@ NETWORKING
Used by INetworkingListener.
Definition: IListenerRegistrar.h:40
@ LOBBY_CREATED
Used by ILobbyCreatedListener.
Definition: IListenerRegistrar.h:32
@ LOBBY_DATA
Used by ILobbyDataListener.
Definition: IListenerRegistrar.h:35
@ GOG_SERVICES_CONNECTION_STATE_LISTENER
Used by IGogServicesConnectionStateListener.
Definition: IListenerRegistrar.h:88
@ LOBBY_MESSAGE
Used by ILobbyMessageListener.
Definition: IListenerRegistrar.h:39
@ USER_STATS_AND_ACHIEVEMENTS_RETRIEVE
Used by IUserStatsAndAchievementsRetrieveListener.
Definition: IListenerRegistrar.h:42
@ CHAT_ROOM_MESSAGES_LISTENER
Used by IChatRoomMessagesListener.
Definition: IListenerRegistrar.h:73
@ AUTH
Used by IAuthListener.
Definition: IListenerRegistrar.h:38
@ LOBBY_OWNER_CHANGE
Used by ILobbyOwnerChangeListener.
Definition: IListenerRegistrar.h:37
@ LOBBY_LIST
Used by ILobbyListListener.
Definition: IListenerRegistrar.h:31
@ LEADERBOARD_RETRIEVE
Used by ILeaderboardRetrieveListener.
Definition: IListenerRegistrar.h:55
@ FRIEND_ADD_LISTENER
Used by IFriendAddListener.
Definition: IListenerRegistrar.h:78
@ USER_INFORMATION_RETRIEVE_LISTENER
< Used by ILobbyDataUpdateListener.
Definition: IListenerRegistrar.h:86
@ LOBBY_MEMBER_STATE
Used by ILobbyMemberStateListener.
Definition: IListenerRegistrar.h:36
@ INVITATION_SEND
Used by ISendInvitationListener.
Definition: IListenerRegistrar.h:57
@ TELEMETRY_EVENT_SEND_LISTENER
Used by ITelemetryEventSendListener.
Definition: IListenerRegistrar.h:89
@ FILE_SHARE
Used by IFileShareListener.
Definition: IListenerRegistrar.h:64
@ RICH_PRESENCE_RETRIEVE_LISTENER
Used by IRichPresenceRetrieveListener.
Definition: IListenerRegistrar.h:87
@ SPECIFIC_USER_DATA
Used by ISpecificUserDataListener.
Definition: IListenerRegistrar.h:56
@ OVERLAY_INITIALIZATION_STATE_CHANGE
Used by IOverlayInitializationStateChangeListener.
Definition: IListenerRegistrar.h:69
@ GAME_JOIN_REQUESTED_LISTENER
Used by IGameJoinRequested.
Definition: IListenerRegistrar.h:50
@ USER_DATA
Used by IUserDataListener.
Definition: IListenerRegistrar.h:41
@ FRIEND_DELETE_LISTENER
Used by IFriendDeleteListener.
Definition: IListenerRegistrar.h:79
@ PERSONA_DATA_CHANGED
Used by IPersonaDataChangedListener.
Definition: IListenerRegistrar.h:48
@ OPERATIONAL_STATE_CHANGE
Used by IOperationalStateChangeListener.
Definition: IListenerRegistrar.h:51
@ NOTIFICATION_LISTENER
Used by INotificationListener.
Definition: IListenerRegistrar.h:60
@ FRIEND_INVITATION_LIST_RETRIEVE_LISTENER
Used by IFriendInvitationListRetrieveListener.
Definition: IListenerRegistrar.h:75
@ LOBBY_MEMBER_DATA_UPDATE_LISTENER
< Used by ILobbyDataUpdateListener.
Definition: IListenerRegistrar.h:85
@ CUSTOM_NETWORKING_CONNECTION_CLOSE
Used by IConnectionCloseListener.
Definition: IListenerRegistrar.h:67
@ CUSTOM_NETWORKING_CONNECTION_DATA
Used by IConnectionDataListener.
Definition: IListenerRegistrar.h:68
@ ENCRYPTED_APP_TICKET_RETRIEVE
Used by IEncryptedAppTicketListener.
Definition: IListenerRegistrar.h:53
@ STATS_AND_ACHIEVEMENTS_STORE
Used by IStatsAndAchievementsStoreListener.
Definition: IListenerRegistrar.h:43
@ FRIEND_INVITATION_RESPOND_TO_LISTENER
Used by IFriendInvitationRespondToListener.
Definition: IListenerRegistrar.h:77
@ LEADERBOARDS_RETRIEVE
Used by ILeaderboardsRetrieveListener.
Definition: IListenerRegistrar.h:45