- ServiceType introduced
[platform/upstream/libzypp.git] / zypp / repo / ServiceType.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 #ifndef ZYPP_SERVICE_TYPE_H_
11 #define ZYPP_SERVICE_TYPE_H_
12
13 #include <iosfwd>
14 #include <string>
15
16 namespace zypp
17 {
18   namespace repo
19   {
20
21   /**
22    * \short Service type enumeration
23    *
24    * Currently we have only RIS service, but more can come later.
25    */
26   struct ServiceType
27   {
28     /**
29      * Repository Index Service (RIS)
30      * (formerly known as 'Novell Update' (NU) service)
31      */
32     static const ServiceType RIS;
33     /** No service set. */
34     static const ServiceType NONE;
35
36     enum Type
37     {
38       NONE_e,
39       RIS_e,
40     };
41
42     ServiceType() : _type(NONE_e) {}
43
44     ServiceType(Type type) : _type(type) {}
45
46     explicit ServiceType(const std::string & strval_r);
47
48     Type toEnum() const { return _type; }
49
50     ServiceType::Type parse(const std::string & strval_r);
51
52     const std::string & asString() const;
53
54     Type _type;
55   };
56
57
58   inline std::ostream & operator<<( std::ostream & str, const ServiceType & obj )
59   { return str << obj.asString(); }
60
61   inline bool operator==(const ServiceType & obj1, const ServiceType & obj2)
62   { return obj1._type == obj2._type; }
63
64   inline bool operator!=(const ServiceType & obj1, const ServiceType & obj2)
65   { return ! (obj1 == obj2); }
66
67
68   } // ns repo
69 } // ns zypp
70
71 #endif /* ZYPP_SERVICE_TYPE_H_ */
72
73 // vim: set ts=2 sts=2 sw=2 et ai: