#ifndef USER_RATING_SUMMARY_H
#define USER_RATING_SUMMARY_H
#include <Referenceable.h>
class UserRatingSummary : public BReferenceable
{
friend class UserRatingSummaryBuilder;
public:
UserRatingSummary();
UserRatingSummary(const UserRatingSummary& other);
bool operator==(const UserRatingSummary& other) const;
bool operator!=(const UserRatingSummary& other) const;
float AverageRating() const;
int RatingCount() const;
int RatingCountByStar(int star) const;
private:
void SetAverageRating(float value);
void SetRatingCount(int value);
void SetRatingByStar(int star, int ratingCount);
private:
float fAverageRating;
int fRatingCount;
int fRatingCountNoStar;
int fRatingCountByStar[6];
};
typedef BReference<UserRatingSummary> UserRatingSummaryRef;
class UserRatingSummaryBuilder
{
public:
UserRatingSummaryBuilder();
UserRatingSummaryBuilder(const UserRatingSummaryRef& other);
virtual ~UserRatingSummaryBuilder();
UserRatingSummaryRef
BuildRef();
UserRatingSummaryBuilder&
WithAverageRating(float value);
UserRatingSummaryBuilder&
WithRatingCount(int value);
UserRatingSummaryBuilder&
AddRatingByStar(int star, int ratingCount);
private:
void _InitFromSource();
void _Init(const UserRatingSummary* value);
private:
UserRatingSummaryRef
fSource;
float fAverageRating;
int fRatingCount;
int fRatingCountNoStar;
int fRatingCountByStar[6];
};
#endif