X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fpackage%2FCatalog.hxx;h=11928b1ccfdcb626a57ba69e9af7c19dd75b1469;hb=a3f1bb546fec72b07f11f69934e6894696fea57a;hp=e38618193df250a7c47c951d164e588b38d6c382;hpb=03cafe4547d9a9c617ce0a7840946e4c7a72272f;p=simgear.git diff --git a/simgear/package/Catalog.hxx b/simgear/package/Catalog.hxx index e3861819..11928b1c 100644 --- a/simgear/package/Catalog.hxx +++ b/simgear/package/Catalog.hxx @@ -20,20 +20,25 @@ #include #include +#include + +#include #include #include #include #include +#include +#include #include namespace simgear { - + namespace HTTP { class Client; } - + namespace pkg { @@ -41,28 +46,32 @@ namespace pkg class Package; class Catalog; class Root; +class Install; typedef SGSharedPtr PackageRef; typedef SGSharedPtr CatalogRef; typedef SGSharedPtr InstallRef; - + typedef std::vector PackageList; typedef std::vector CatalogList; - class Catalog : public SGReferenced +class Catalog : public SGReferenced { public: virtual ~Catalog(); - + static CatalogRef createFromUrl(Root* aRoot, const std::string& aUrl); - + static CatalogRef createFromPath(Root* aRoot, const SGPath& aPath); - - static CatalogList allCatalogs(); - + Root* root() const { return m_root;}; - + + /** + * uninstall this catalog entirely, including all installed packages + */ + bool uninstall(); + /** * perform a refresh of the catalog contents */ @@ -87,56 +96,81 @@ public: /** * retrieve all the packages in the catalog which are installed * and have a pendig update - */ + */ PackageList packagesNeedingUpdate() const; - + SGPath installRoot() const { return m_installRoot; } - + std::string id() const; - + std::string url() const; - + + std::string name() const; + std::string description() const; - + PackageRef getPackageById(const std::string& aId) const; - + + PackageRef getPackageByPath(const std::string& aPath) const; + /** * test if the catalog data was retrieved longer ago than the * maximum permitted age for this catalog. */ bool needsRefresh() const; - + unsigned int ageInSeconds() const; - + /** * access the raw property data in the catalog */ SGPropertyNode* properties() const; + + Delegate::StatusCode status() const; + + typedef boost::function Callback; + + void addStatusCallback(const Callback& cb); + + template + void addStatusCallback(C* instance, void (C::*mem_func)(Catalog*)) + { + return addStatusCallback(boost::bind(mem_func, instance, _1)); + } private: Catalog(Root* aRoot); - + class Downloader; friend class Downloader; - + void parseProps(const SGPropertyNode* aProps); - - void refreshComplete(Delegate::FailureCode aReason); - + + void refreshComplete(Delegate::StatusCode aReason); + void parseTimestamp(); void writeTimestamp(); - + std::string getLocalisedString(const SGPropertyNode* aRoot, const char* aName) const; - + + void changeStatus(Delegate::StatusCode newStatus); + Root* m_root; SGPropertyNode_ptr m_props; SGPath m_installRoot; std::string m_url; - + Delegate::StatusCode m_status; + HTTP::Request_ptr m_refreshRequest; + PackageList m_packages; time_t m_retrievedTime; -}; - + + typedef std::map PackageWeakMap; + PackageWeakMap m_variantDict; + + function_list m_statusCallbacks; +}; + } // of namespace pkg } // of namespace simgear