From f34f805b1ae73e81f4acdbe49faeb15f21439a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 28 Jul 2013 12:20:00 +0200 Subject: [PATCH] HaikuDepot: Added DepotInfo class --- src/apps/haiku-depot/PackageInfo.cpp | 58 ++++++++++++++++++++++++++++ src/apps/haiku-depot/PackageInfo.h | 27 +++++++++++++ 2 files changed, 85 insertions(+) diff --git a/src/apps/haiku-depot/PackageInfo.cpp b/src/apps/haiku-depot/PackageInfo.cpp index 78a617d243..ef0fac62e8 100644 --- a/src/apps/haiku-depot/PackageInfo.cpp +++ b/src/apps/haiku-depot/PackageInfo.cpp @@ -189,3 +189,61 @@ PackageInfo::AddUserRating(const UserRating& rating) { return fUserRatings.Add(rating); } + + +// #pragma mark - + + +DepotInfo::DepotInfo() + : + fTitle(), + fPackages() +{ +} + + +DepotInfo::DepotInfo(const BString& title) + : + fTitle(title), + fPackages() +{ +} + + +DepotInfo::DepotInfo(const DepotInfo& other) + : + fTitle(other.fTitle), + fPackages(other.fPackages) +{ +} + + +DepotInfo& +DepotInfo::operator=(const DepotInfo& other) +{ + fTitle = other.fTitle; + fPackages = other.fPackages; + return *this; +} + + +bool +DepotInfo::operator==(const DepotInfo& other) const +{ + return fTitle == other.fTitle + && fPackages == other.fPackages; +} + + +bool +DepotInfo::operator!=(const DepotInfo& other) const +{ + return !(*this == other); +} + + +bool +DepotInfo::AddPackage(const PackageInfo& package) +{ + return fPackages.Add(package); +} diff --git a/src/apps/haiku-depot/PackageInfo.h b/src/apps/haiku-depot/PackageInfo.h index 24d4c8e7a1..db5db3022e 100644 --- a/src/apps/haiku-depot/PackageInfo.h +++ b/src/apps/haiku-depot/PackageInfo.h @@ -96,4 +96,31 @@ private: typedef List PackageInfoList; +class DepotInfo { +public: + DepotInfo(); + DepotInfo(const BString& title); + DepotInfo(const DepotInfo& other); + + DepotInfo& operator=(const DepotInfo& other); + bool operator==(const DepotInfo& other) const; + bool operator!=(const DepotInfo& other) const; + + const BString& Title() const + { return fTitle; } + + const PackageInfoList& PackageList() const + { return fPackages; } + + bool AddPackage(const PackageInfo& package); + +private: + BString fTitle; + PackageInfoList fPackages; +}; + + +typedef List DepotInfoList; + + #endif // PACKAGE_INFO_H