GOG GALAXY SDK Documentation
IStats.h
Go to the documentation of this file.
1 #ifndef GALAXY_I_STATS_H
2 #define GALAXY_I_STATS_H
3 
9 #include "IListenerRegistrar.h"
10 #include "GalaxyID.h"
11 
12 namespace galaxy
13 {
14  namespace api
15  {
25  {
29  };
30 
35  {
40  };
41 
46  class IUserStatsAndAchievementsRetrieveListener : public GalaxyTypeAwareListener<USER_STATS_AND_ACHIEVEMENTS_RETRIEVE>
47  {
48  public:
49 
62 
67  {
70  };
71 
79  virtual void OnUserStatsAndAchievementsRetrieveFailure(GalaxyID userID, FailureReason failureReason) = 0;
80  };
81 
86 
90  class IStatsAndAchievementsStoreListener : public GalaxyTypeAwareListener<STATS_AND_ACHIEVEMENTS_STORE>
91  {
92  public:
93 
99 
104  {
107  };
108 
115  virtual void OnUserStatsAndAchievementsStoreFailure(FailureReason failureReason) = 0;
116  };
117 
122 
126  class IAchievementChangeListener : public GalaxyTypeAwareListener<ACHIEVEMENT_CHANGE>
127  {
128  public:
129 
130  // // /**
131  // // * Notification for the event of changing progress in unlocking
132  // // * a particular achievement.
133  // // *
134  // // * @param [in] name The code name of the achievement.
135  // // * @param [in] currentProgress Current value of progress for the achievement.
136  // // * @param [in] maxProgress The maximum value of progress for the achievement.
137  // // */
138  // // void OnAchievementProgressChanged(const char* name, uint32_t currentProgress, uint32_t maxProgress) = 0;
139 
146  virtual void OnAchievementUnlocked(const char* name) = 0;
147  };
148 
153 
157  class ILeaderboardsRetrieveListener : public GalaxyTypeAwareListener<LEADERBOARDS_RETRIEVE>
158  {
159  public:
160 
170  virtual void OnLeaderboardsRetrieveSuccess() = 0;
171 
176  {
179  };
180 
186  virtual void OnLeaderboardsRetrieveFailure(FailureReason failureReason) = 0;
187  };
188 
193 
197  class ILeaderboardEntriesRetrieveListener : public GalaxyTypeAwareListener<LEADERBOARD_ENTRIES_RETRIEVE>
198  {
199  public:
200 
209  virtual void OnLeaderboardEntriesRetrieveSuccess(const char* name, uint32_t entryCount) = 0;
210 
215  {
219  };
220 
227  virtual void OnLeaderboardEntriesRetrieveFailure(const char* name, FailureReason failureReason) = 0;
228  };
229 
234 
238  class ILeaderboardScoreUpdateListener : public GalaxyTypeAwareListener<LEADERBOARD_SCORE_UPDATE_LISTENER>
239  {
240  public:
241 
250  virtual void OnLeaderboardScoreUpdateSuccess(const char* name, int32_t score, uint32_t oldRank, uint32_t newRank) = 0;
251 
256  {
260  };
261 
269  virtual void OnLeaderboardScoreUpdateFailure(const char* name, int32_t score, FailureReason failureReason) = 0;
270  };
271 
276 
280  class ILeaderboardRetrieveListener : public GalaxyTypeAwareListener<LEADERBOARD_RETRIEVE>
281  {
282  public:
283 
295  virtual void OnLeaderboardRetrieveSuccess(const char* name) = 0;
296 
301  {
304  };
305 
312  virtual void OnLeaderboardRetrieveFailure(const char* name, FailureReason failureReason) = 0;
313  };
314 
319 
323  class IUserTimePlayedRetrieveListener : public GalaxyTypeAwareListener<USER_TIME_PLAYED_RETRIEVE>
324  {
325  public:
326 
334  virtual void OnUserTimePlayedRetrieveSuccess(GalaxyID userID) = 0;
335 
340  {
343  };
344 
351  virtual void OnUserTimePlayedRetrieveFailure(GalaxyID userID, FailureReason failureReason) = 0;
352  };
353 
358 
362  class IStats
363  {
364  public:
365 
366  virtual ~IStats()
367  {
368  }
369 
380 
390  virtual int32_t GetStatInt(const char* name, GalaxyID userID = GalaxyID()) = 0;
391 
401  virtual float GetStatFloat(const char* name, GalaxyID userID = GalaxyID()) = 0;
402 
413  virtual void SetStatInt(const char* name, int32_t value) = 0;
414 
425  virtual void SetStatFloat(const char* name, float value) = 0;
426 
438  virtual void UpdateAvgRateStat(const char* name, float countThisSession, double sessionLength) = 0;
439 
450  virtual void GetAchievement(const char* name, bool& unlocked, uint32_t& unlockTime, GalaxyID userID = GalaxyID()) = 0;
451 
462  virtual void SetAchievement(const char* name) = 0;
463 
473  virtual void ClearAchievement(const char* name) = 0;
474 
486  virtual void StoreStatsAndAchievements(IStatsAndAchievementsStoreListener* const listener = NULL) = 0;
487 
499  virtual void ResetStatsAndAchievements(IStatsAndAchievementsStoreListener* const listener = NULL) = 0;
500 
511  virtual const char* GetAchievementDisplayName(const char* name) = 0;
512 
522  virtual void GetAchievementDisplayNameCopy(const char* name, char* buffer, uint32_t bufferLength) = 0;
523 
534  virtual const char* GetAchievementDescription(const char* name) = 0;
535 
545  virtual void GetAchievementDescriptionCopy(const char* name, char* buffer, uint32_t bufferLength) = 0;
546 
555  virtual bool IsAchievementVisible(const char* name) = 0;
556 
565  virtual bool IsAchievementVisibleWhileLocked(const char* name) = 0;
566 
574  virtual void RequestLeaderboards(ILeaderboardsRetrieveListener* const listener = NULL) = 0;
575 
588  virtual const char* GetLeaderboardDisplayName(const char* name) = 0;
589 
601  virtual void GetLeaderboardDisplayNameCopy(const char* name, char* buffer, uint32_t bufferLength) = 0;
602 
613  virtual LeaderboardSortMethod GetLeaderboardSortMethod(const char* name) = 0;
614 
625  virtual LeaderboardDisplayType GetLeaderboardDisplayType(const char* name) = 0;
626 
645  const char* name,
646  uint32_t rangeStart,
647  uint32_t rangeEnd,
648  ILeaderboardEntriesRetrieveListener* const listener = NULL) = 0;
649 
673  const char* name,
674  uint32_t countBefore,
675  uint32_t countAfter,
676  GalaxyID userID = GalaxyID(),
677  ILeaderboardEntriesRetrieveListener* const listener = NULL) = 0;
678 
694  const char* name,
695  GalaxyID* userArray,
696  uint32_t userArraySize,
697  ILeaderboardEntriesRetrieveListener* const listener = NULL) = 0;
698 
716  virtual void GetRequestedLeaderboardEntry(uint32_t index, uint32_t& rank, int32_t& score, GalaxyID& userID) = 0;
717 
742  uint32_t index,
743  uint32_t& rank,
744  int32_t& score,
745  void* details,
746  uint32_t detailsSize,
747  uint32_t& outDetailsSize,
748  GalaxyID& userID) = 0;
749 
767  virtual void SetLeaderboardScore(
768  const char* name,
769  int32_t score,
770  bool forceUpdate = false,
771  ILeaderboardScoreUpdateListener* const listener = NULL) = 0;
772 
793  const char* name,
794  int32_t score,
795  const void* details,
796  uint32_t detailsSize,
797  bool forceUpdate = false,
798  ILeaderboardScoreUpdateListener* const listener = NULL) = 0;
799 
810  virtual uint32_t GetLeaderboardEntryCount(const char* name) = 0;
811 
820  virtual void FindLeaderboard(const char* name, ILeaderboardRetrieveListener* const listener = NULL) = 0;
821 
839  const char* name,
840  const char* displayName,
841  const LeaderboardSortMethod& sortMethod,
842  const LeaderboardDisplayType& displayType,
843  ILeaderboardRetrieveListener* const listener = NULL) = 0;
844 
853  virtual void RequestUserTimePlayed(GalaxyID userID = GalaxyID(), IUserTimePlayedRetrieveListener* const listener = NULL) = 0;
854 
863  virtual uint32_t GetUserTimePlayed(GalaxyID userID = GalaxyID()) = 0;
864  };
865 
867  }
868 }
869 
870 #endif
Contains GalaxyID, which is the class that represents the ID of an entity used by Galaxy Peer.
Contains data structures and interfaces related to callback listeners.
Represents the ID of an entity used by Galaxy Peer.
Definition: GalaxyID.h:30
The class that is inherited by all specific callback listeners and provides a static method that retu...
Definition: IListenerRegistrar.h:117
Listener for the event of changing an achievement.
Definition: IStats.h:127
virtual void OnAchievementUnlocked(const char *name)=0
Notification for the event of storing changes that result in unlocking a particular achievement.
Listener for the event of retrieving requested entries of a leaderboard.
Definition: IStats.h:198
FailureReason
The reason of a failure in retrieving requested entries of a leaderboard.
Definition: IStats.h:215
@ FAILURE_REASON_NOT_FOUND
Could not find any entries for specified search criteria.
Definition: IStats.h:217
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:216
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:218
virtual void OnLeaderboardEntriesRetrieveFailure(const char *name, FailureReason failureReason)=0
Notification for the event of a failure in retrieving requested entries of a leaderboard.
virtual void OnLeaderboardEntriesRetrieveSuccess(const char *name, uint32_t entryCount)=0
Notification for the event of a success in retrieving requested entries of a leaderboard.
Listener for the event of retrieving definition of a leaderboard.
Definition: IStats.h:281
FailureReason
The reason of a failure in retrieving definition of a leaderboard.
Definition: IStats.h:301
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:302
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:303
virtual void OnLeaderboardRetrieveSuccess(const char *name)=0
Notification for the event of a success in retrieving definition of a leaderboard.
virtual void OnLeaderboardRetrieveFailure(const char *name, FailureReason failureReason)=0
Notification for the event of a failure in retrieving definition of a leaderboard.
Listener for the event of updating score in a leaderboard.
Definition: IStats.h:239
FailureReason
The reason of a failure in updating score in a leaderboard.
Definition: IStats.h:256
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:257
@ FAILURE_REASON_NO_IMPROVEMENT
Previous score was better and the update operation was not forced.
Definition: IStats.h:258
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:259
virtual void OnLeaderboardScoreUpdateSuccess(const char *name, int32_t score, uint32_t oldRank, uint32_t newRank)=0
Notification for the event of a success in setting score in a leaderboard.
virtual void OnLeaderboardScoreUpdateFailure(const char *name, int32_t score, FailureReason failureReason)=0
The reason of a failure in updating score in a leaderboard.
Listener for the event of retrieving definitions of leaderboards.
Definition: IStats.h:158
FailureReason
The reason of a failure in retrieving definitions of leaderboards.
Definition: IStats.h:176
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:177
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:178
virtual void OnLeaderboardsRetrieveFailure(FailureReason failureReason)=0
Notification for the event of a failure in retrieving definitions of leaderboards.
virtual void OnLeaderboardsRetrieveSuccess()=0
Notification for the event of a success in retrieving definitions of leaderboards.
Listener for the event of storing own statistics and achievements.
Definition: IStats.h:91
virtual void OnUserStatsAndAchievementsStoreFailure(FailureReason failureReason)=0
Notification for the event of a failure in storing statistics and achievements.
FailureReason
The reason of a failure in storing statistics and achievements.
Definition: IStats.h:104
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:105
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:106
virtual void OnUserStatsAndAchievementsStoreSuccess()=0
Notification for the event of success in storing statistics and achievements.
The interface for managing statistics, achievements and leaderboards.
Definition: IStats.h:363
virtual void SetLeaderboardScoreWithDetails(const char *name, int32_t score, const void *details, uint32_t detailsSize, bool forceUpdate=false, ILeaderboardScoreUpdateListener *const listener=NULL)=0
Updates entry with details for own user in a specified leaderboard.
virtual void StoreStatsAndAchievements(IStatsAndAchievementsStoreListener *const listener=NULL)=0
Persists all changes in statistics and achievements.
virtual void RequestLeaderboardEntriesAroundUser(const char *name, uint32_t countBefore, uint32_t countAfter, GalaxyID userID=GalaxyID(), ILeaderboardEntriesRetrieveListener *const listener=NULL)=0
Performs a request for entries of a specified leaderboard for and near the specified user.
virtual void FindOrCreateLeaderboard(const char *name, const char *displayName, const LeaderboardSortMethod &sortMethod, const LeaderboardDisplayType &displayType, ILeaderboardRetrieveListener *const listener=NULL)=0
Performs a request for definition of a specified leaderboard, creating it if there is no such leaderb...
virtual LeaderboardSortMethod GetLeaderboardSortMethod(const char *name)=0
Returns sort method of a specified leaderboard.
virtual void RequestUserTimePlayed(GalaxyID userID=GalaxyID(), IUserTimePlayedRetrieveListener *const listener=NULL)=0
Performs a request for user time played.
virtual bool IsAchievementVisibleWhileLocked(const char *name)=0
Returns visibility status of a specified achievement before unlocking.
virtual void GetRequestedLeaderboardEntry(uint32_t index, uint32_t &rank, int32_t &score, GalaxyID &userID)=0
Returns data from the currently processed request for leaderboard entries.
virtual void GetAchievementDescriptionCopy(const char *name, char *buffer, uint32_t bufferLength)=0
Copies description of a specified achievement.
virtual void RequestUserStatsAndAchievements(GalaxyID userID=GalaxyID(), IUserStatsAndAchievementsRetrieveListener *const listener=NULL)=0
Performs a request for statistics and achievements of a specified user.
virtual float GetStatFloat(const char *name, GalaxyID userID=GalaxyID())=0
Reads floating point value of a statistic of a specified user.
virtual void GetAchievement(const char *name, bool &unlocked, uint32_t &unlockTime, GalaxyID userID=GalaxyID())=0
Reads the state of an achievement of a specified user.
virtual int32_t GetStatInt(const char *name, GalaxyID userID=GalaxyID())=0
Reads integer value of a statistic of a specified user.
virtual LeaderboardDisplayType GetLeaderboardDisplayType(const char *name)=0
Returns display type of a specified leaderboard.
virtual void RequestLeaderboards(ILeaderboardsRetrieveListener *const listener=NULL)=0
Performs a request for definitions of leaderboards.
virtual const char * GetAchievementDescription(const char *name)=0
Returns description of a specified achievement.
virtual uint32_t GetLeaderboardEntryCount(const char *name)=0
Returns the leaderboard entry count for requested leaderboard.
virtual void RequestLeaderboardEntriesGlobal(const char *name, uint32_t rangeStart, uint32_t rangeEnd, ILeaderboardEntriesRetrieveListener *const listener=NULL)=0
Performs a request for entries of a specified leaderboard in a global scope, i.e.
virtual void ResetStatsAndAchievements(IStatsAndAchievementsStoreListener *const listener=NULL)=0
Resets all statistics and achievements.
virtual void SetLeaderboardScore(const char *name, int32_t score, bool forceUpdate=false, ILeaderboardScoreUpdateListener *const listener=NULL)=0
Updates entry for own user in a specified leaderboard.
virtual void SetAchievement(const char *name)=0
Unlocks an achievement.
virtual void SetStatFloat(const char *name, float value)=0
Updates a statistic with a floating point value.
virtual void GetRequestedLeaderboardEntryWithDetails(uint32_t index, uint32_t &rank, int32_t &score, void *details, uint32_t detailsSize, uint32_t &outDetailsSize, GalaxyID &userID)=0
Returns data with details from the currently processed request for leaderboard entries.
virtual uint32_t GetUserTimePlayed(GalaxyID userID=GalaxyID())=0
Reads the number of seconds played by a specified user.
virtual void RequestLeaderboardEntriesForUsers(const char *name, GalaxyID *userArray, uint32_t userArraySize, ILeaderboardEntriesRetrieveListener *const listener=NULL)=0
Performs a request for entries of a specified leaderboard for specified users.
virtual void UpdateAvgRateStat(const char *name, float countThisSession, double sessionLength)=0
Updates an average-rate statistic with a delta.
virtual bool IsAchievementVisible(const char *name)=0
Returns visibility status of a specified achievement.
virtual void FindLeaderboard(const char *name, ILeaderboardRetrieveListener *const listener=NULL)=0
Performs a request for definition of a specified leaderboard.
virtual void ClearAchievement(const char *name)=0
Clears an achievement.
virtual void SetStatInt(const char *name, int32_t value)=0
Updates a statistic with an integer value.
virtual const char * GetLeaderboardDisplayName(const char *name)=0
Returns display name of a specified leaderboard.
virtual void GetAchievementDisplayNameCopy(const char *name, char *buffer, uint32_t bufferLength)=0
Copies display name of a specified achievement.
virtual void GetLeaderboardDisplayNameCopy(const char *name, char *buffer, uint32_t bufferLength)=0
Copies display name of a specified leaderboard.
virtual const char * GetAchievementDisplayName(const char *name)=0
Returns display name of a specified achievement.
Listener for the event of retrieving statistics and achievements of a specified user,...
Definition: IStats.h:47
FailureReason
The reason of a failure in retrieving statistics and achievements.
Definition: IStats.h:67
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:68
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:69
virtual void OnUserStatsAndAchievementsRetrieveFailure(GalaxyID userID, FailureReason failureReason)=0
Notification for the event of a failure in retrieving statistics and achievements for a specified use...
virtual void OnUserStatsAndAchievementsRetrieveSuccess(GalaxyID userID)=0
Notification for the event of success in retrieving statistics and achievements for a specified user.
Listener for the event of retrieving user time played.
Definition: IStats.h:324
FailureReason
The reason of a failure in retrieving user time played.
Definition: IStats.h:340
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStats.h:341
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStats.h:342
virtual void OnUserTimePlayedRetrieveSuccess(GalaxyID userID)=0
Notification for the event of a success in retrieving user time played.
virtual void OnUserTimePlayedRetrieveFailure(GalaxyID userID, FailureReason failureReason)=0
Notification for the event of a failure in retrieving user time played.
The class that is inherited by the self-registering versions of all specific callback listeners.
Definition: IListenerRegistrar.h:211
SelfRegisteringListener< ILeaderboardsRetrieveListener > GlobalLeaderboardsRetrieveListener
Globally self-registering version of a ILeaderboardsRetrieveListener.
Definition: IStats.h:192
SelfRegisteringListener< ILeaderboardScoreUpdateListener > GlobalLeaderboardScoreUpdateListener
Globally self-registering version of a ILeaderboardScoreUpdateListener.
Definition: IStats.h:275
SelfRegisteringListener< ILeaderboardRetrieveListener > GlobalLeaderboardRetrieveListener
Globally self-registering version of a ILeaderboardRetrieveListener.
Definition: IStats.h:318
LeaderboardSortMethod
The sort order of a leaderboard.
Definition: IStats.h:25
SelfRegisteringListener< ILeaderboardEntriesRetrieveListener > GlobalLeaderboardEntriesRetrieveListener
Globally self-registering version of a ILeaderboardEntriesRetrieveListener.
Definition: IStats.h:233
SelfRegisteringListener< IStatsAndAchievementsStoreListener > GlobalStatsAndAchievementsStoreListener
Globally self-registering version of IStatsAndAchievementsStoreListener.
Definition: IStats.h:121
LeaderboardDisplayType
The display type of a leaderboard.
Definition: IStats.h:35
SelfRegisteringListener< IUserStatsAndAchievementsRetrieveListener > GlobalUserStatsAndAchievementsRetrieveListener
Globally self-registering version of IUserStatsAndAchievementsRetrieveListener.
Definition: IStats.h:85
SelfRegisteringListener< IUserTimePlayedRetrieveListener > GlobalUserTimePlayedRetrieveListener
Globally self-registering version of a IUserTimePlayedRetrieveListener.
Definition: IStats.h:357
SelfRegisteringListener< IAchievementChangeListener > GlobalAchievementChangeListener
Globally self-registering version of IAchievementChangeListener.
Definition: IStats.h:152
@ LEADERBOARD_SORT_METHOD_NONE
No sorting method specified.
Definition: IStats.h:26
@ LEADERBOARD_SORT_METHOD_DESCENDING
Top score is highest number.
Definition: IStats.h:28
@ LEADERBOARD_SORT_METHOD_ASCENDING
Top score is lowest number.
Definition: IStats.h:27
@ LEADERBOARD_DISPLAY_TYPE_NUMBER
Simple numerical score.
Definition: IStats.h:37
@ LEADERBOARD_DISPLAY_TYPE_TIME_SECONDS
The score represents time, in seconds.
Definition: IStats.h:38
@ LEADERBOARD_DISPLAY_TYPE_NONE
Not display type specified.
Definition: IStats.h:36
@ LEADERBOARD_DISPLAY_TYPE_TIME_MILLISECONDS
The score represents time, in milliseconds.
Definition: IStats.h:39