Imported Upstream version 17.21.0
[platform/upstream/libzypp.git] / zypp / repo / yum / ResourceType.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 #ifndef YUMRESOURCETYPE_H_
11 #define YUMRESOURCETYPE_H_
12
13 #include <iosfwd>
14 #include<string>
15
16 namespace zypp
17 {
18   namespace repo
19   {
20     namespace yum
21     {
22
23
24   /**
25    *
26    */
27   struct ResourceType
28   {
29     static const ResourceType NONE; // unknown
30     static const ResourceType REPOMD;
31     static const ResourceType PRIMARY;
32     static const ResourceType OTHER;
33     static const ResourceType FILELISTS;
34     static const ResourceType GROUP;
35     static const ResourceType PATCHES; // suse extension
36     static const ResourceType PATCH;   // suse extension
37     static const ResourceType PRODUCT; // suse extension
38     static const ResourceType PATTERNS; // suse extension
39     // sqlite caches yum extensions:
40     static const ResourceType PRIMARY_DB; // yum extension
41     static const ResourceType OTHER_DB; // yum extension
42
43     enum Type
44     {
45       NONE_e,
46       REPOMD_e,
47       PRIMARY_e,
48       OTHER_e,
49       FILELISTS_e,
50       GROUP_e,
51       PATCHES_e,
52       PATCH_e,
53       PRODUCT_e,
54       PATTERNS_e,
55       PRIMARY_DB_e,
56       OTHER_DB_e,
57     };
58
59     ResourceType(Type type) : _type(type) {}
60
61     explicit ResourceType(const std::string & strval_r);
62
63     Type toEnum() const { return _type; }
64
65     ResourceType::Type parse(const std::string & strval_r);
66
67     const std::string & asString() const;
68
69     Type _type;
70   };
71
72
73   inline std::ostream & operator<<( std::ostream & str, const ResourceType & obj )
74   { return str << obj.asString(); }
75
76   inline bool operator==(const ResourceType & obj1, const ResourceType & obj2)
77   { return obj1._type == obj2._type; }
78
79
80     } // ns yum
81   } // ns source
82 } // ns zypp
83
84 #endif /*YUMRESOURCETYPE_H_*/
85
86 // vim: set ts=2 sts=2 sw=2 et ai: