]> git.mxchange.org Git - simgear.git/blob - simgear/package/Package.hxx
d1e798160695c06b6077db0d0e02713700500c8e
[simgear.git] / simgear / package / Package.hxx
1 #ifndef SG_PACKAGE_PACKAGE_HXX
2 #define SG_PACKAGE_PACKAGE_HXX
3
4 #include <set>
5 #include <vector>
6
7 #include <simgear/props/props.hxx>
8 #include <simgear/misc/strutils.hxx>
9
10 typedef std::set<std::string> string_set;
11
12 namespace simgear
13 {
14     
15 namespace pkg
16 {
17
18 // forward decls
19 class Install;
20 class Catalog;
21 class Package;
22
23 typedef std::vector<Package*> PackageList;
24     
25 class Package
26 {
27 public:
28     /**
29      * get or create an install for the package
30      */
31     Install* install();
32     
33     bool isInstalled() const;
34     
35     std::string id() const;
36     
37     /**
38      * access the raw property data in the package
39      */
40     SGPropertyNode* properties() const;
41     
42     /**
43      * hex-encoded MD5 sum of the download files
44      */
45     std::string md5() const;
46     
47     std::string getLocalisedProp(const std::string& aName) const;
48
49     unsigned int revision() const;
50     
51     Catalog* catalog() const
52         { return m_catalog; }
53     
54     bool matches(const SGPropertyNode* aFilter) const;
55     
56     /**
57      * download URLs for the package
58      */
59     string_list downloadUrls() const;
60     
61     string_list thumbnailUrls() const;
62     
63     /**
64      * Packages we depend upon.
65      * If the dependency list cannot be satisifed for some reason,
66      * this will raise an sg_exception.
67      */
68     PackageList dependencies() const;
69 private:
70     friend class Catalog;
71     
72     Package(const SGPropertyNode* aProps, Catalog* aCatalog);
73     
74     void initWithProps(const SGPropertyNode* aProps);
75     
76     std::string getLocalisedString(const SGPropertyNode* aRoot, const char* aName) const;
77     
78     SGPropertyNode_ptr m_props;
79     string_set m_tags;
80     Catalog* m_catalog;
81 };
82
83
84
85
86 } // of namespace pkg
87
88 } // of namespace simgear
89
90 #endif // of SG_PACKAGE_PACKAGE_HXX
91