xref: /haiku/src/apps/haikudepot/packagemodel/UserRatingInfo.h (revision 344ded80d400028c8f561b4b876257b94c12db4a)
1 /*
2  * Copyright 2024, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef USER_RATING_INFO_H
6 #define USER_RATING_INFO_H
7 
8 #include <vector>
9 
10 #include <Referenceable.h>
11 
12 #include "UserRating.h"
13 #include "UserRatingSummary.h"
14 
15 
16 /*!	This class carries the collection of user ratings related to a package but also provides
17 	an instance of `UserRatingSummaryRef` which is a summary of the user ratings.
18 */
19 
20 class UserRatingInfo : public BReferenceable
21 {
22 public:
23 								UserRatingInfo();
24 								UserRatingInfo(const UserRatingInfo& other);
25 
26 			void				Clear();
27 
28 	const	UserRatingSummaryRef
29 								Summary() const
30 									{ return fSummary; }
31 			void				SetSummary(UserRatingSummaryRef value);
32 
33 			void				ClearUserRatings();
34 			void				AddUserRating(const UserRatingRef& rating);
35 			int32				CountUserRatings() const;
36 			UserRatingRef		UserRatingAtIndex(int32 index) const;
37 
38 			void				SetUserRatingsPopulated();
39 			bool				UserRatingsPopulated() const;
40 
41 			UserRatingInfo&		operator=(const UserRatingInfo& other);
42 			bool				operator==(const UserRatingInfo& other) const;
43 			bool				operator!=(const UserRatingInfo& other) const;
44 
45 private:
46 			std::vector<UserRatingRef>
47 								fUserRatings;
48 			UserRatingSummaryRef
49 								fSummary;
50 			bool				fUserRatingsPopulated;
51 };
52 
53 typedef BReference<UserRatingInfo> UserRatingInfoRef;
54 
55 
56 #endif // USER_RATING_SUMMARY_H
57