1 // Copyright (C) 2013 James Turner - zakalawe@mac.com
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #ifndef SG_PACKAGE_CATALOG_HXX
19 #define SG_PACKAGE_CATALOG_HXX
24 #include <simgear/misc/sg_path.hxx>
25 #include <simgear/props/props.hxx>
27 #include <simgear/package/Delegate.hxx>
32 namespace HTTP { class Client; }
42 typedef std::vector<Package*> PackageList;
43 typedef std::vector<Catalog*> CatalogList;
50 static Catalog* createFromUrl(Root* aRoot, const std::string& aUrl);
52 static Catalog* createFromPath(Root* aRoot, const SGPath& aPath);
54 static CatalogList allCatalogs();
60 * perform a refresh of the catalog contents
64 * retrieve packages in this catalog matching a filter.
65 * filter consists of required / minimum values, AND-ed together.
67 PackageList packagesMatching(const SGPropertyNode* aFilter) const;
70 * retrieve all the packages in the catalog which are installed
71 * and have a pendig update
73 PackageList packagesNeedingUpdate() const;
75 SGPath installRoot() const
76 { return m_installRoot; }
78 std::string id() const;
80 std::string url() const;
82 std::string description() const;
84 Package* getPackageById(const std::string& aId) const;
86 unsigned int ageInSeconds() const;
89 * access the raw property data in the catalog
91 SGPropertyNode* properties() const;
96 friend class Downloader;
98 void parseProps(const SGPropertyNode* aProps);
100 void refreshComplete(Delegate::FailureCode aReason);
102 void parseTimestamp();
103 void writeTimestamp();
105 std::string getLocalisedString(const SGPropertyNode* aRoot, const char* aName) const;
108 SGPropertyNode_ptr m_props;
109 SGPath m_installRoot;
111 PackageList m_packages;
112 time_t m_retrievedTime;
115 } // of namespace pkg
117 } // of namespace simgear
119 #endif // of SG_PACKAGE_CATALOG_HXX