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,
98  };
99 
104  {
105  public:
106 
107  virtual ~IGalaxyListener()
108  {
109  }
110  };
111 
116  template<ListenerType type> class GalaxyTypeAwareListener : public IGalaxyListener
117  {
118  public:
119 
126  {
127  return type;
128  }
129  };
130 
137  {
138  public:
139 
140  virtual ~IListenerRegistrar()
141  {
142  }
143 
154  virtual void Register(ListenerType listenerType, IGalaxyListener* listener) = 0;
155 
165  virtual void Unregister(ListenerType listenerType, IGalaxyListener* listener) = 0;
166  };
167 
178  GALAXY_DLL_EXPORT IListenerRegistrar* GALAXY_CALLTYPE ListenerRegistrar();
179 
192  GALAXY_DLL_EXPORT IListenerRegistrar* GALAXY_CALLTYPE GameServerListenerRegistrar();
193 
209  template<typename _TypeAwareListener, IListenerRegistrar*(*_Registrar)() = ListenerRegistrar>
210  class SelfRegisteringListener : public _TypeAwareListener
211  {
212  public:
213 
221  {
222  if (_Registrar())
223  _Registrar()->Register(_TypeAwareListener::GetListenerType(), this);
224  }
225 
232  {
233  if (_Registrar())
234  _Registrar()->Unregister(_TypeAwareListener::GetListenerType(), this);
235  }
236  };
237 
239  }
240 }
241 
242 #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:117
static ListenerType GetListenerType()
Returns the type of the listener.
Definition: IListenerRegistrar.h:125
The interface that is implemented by all specific callback listeners.
Definition: IListenerRegistrar.h:104
The class that enables and disables global registration of the instances of specific listeners.
Definition: IListenerRegistrar.h:137
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:211
SelfRegisteringListener()
Creates an instance of SelfRegisteringListener and registers it with the IListenerRegistrar provided ...
Definition: IListenerRegistrar.h:220
~SelfRegisteringListener()
Destroys the instance of SelfRegisteringListener and unregisters it with the instance of IListenerReg...
Definition: IListenerRegistrar.h:231
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
@ CLOUD_STORAGE_DELETE_FILE
Used by ICloudStorageDeleteFileListener.
Definition: IListenerRegistrar.h:93
@ 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:97
@ CLOUD_STORAGE_GET_FILE
Used by ICloudStorageGetFileListener.
Definition: IListenerRegistrar.h:91
@ 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
@ CLOUD_STORAGE_PUT_FILE
Used by ICloudStoragePutFileListener.
Definition: IListenerRegistrar.h:92
@ 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
@ IS_DLC_OWNED
Used for IIsDlcOwnedListener.
Definition: IListenerRegistrar.h:94
@ 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
@ CLOUD_STORAGE_GET_FILE_LIST
Used by ICloudStorageGetFileListListener.
Definition: IListenerRegistrar.h:90
@ 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
@ PLAYFAB_CREATE_OPENID_CONNECTION
Used by IPlayFabCreateOpenIDConnectionListener.
Definition: IListenerRegistrar.h:95
@ 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
@ PLAYFAB_LOGIN_WITH_OPENID_CONNECT
Used by IPlayFabLoginWithOpenIDConnectListener.
Definition: IListenerRegistrar.h:96
@ LEADERBOARDS_RETRIEVE
Used by ILeaderboardsRetrieveListener.
Definition: IListenerRegistrar.h:45