- Create the cache directly from the schema (installed) file.
[platform/upstream/libzypp.git] / zypp / CapFactory.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/CapFactory.h
10  *
11 */
12 #ifndef ZYPP_CAPFACTORY_H
13 #define ZYPP_CAPFACTORY_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/PtrTypes.h"
18
19 #include "zypp/Capability.h"
20
21 ///////////////////////////////////////////////////////////////////
22 namespace zypp
23 { /////////////////////////////////////////////////////////////////
24
25   ///////////////////////////////////////////////////////////////////
26   //
27   //    CLASS NAME : CapFactory
28   //
29   /** Factory for creating Capability.
30    *
31    * Besides parsing, CapFactory asserts that equal capabilites
32    * share the same implementation.
33    *
34    * \todo define EXCEPTIONS
35    * \todo Parser needs improvement in speed and accuracy.
36   */
37   class CapFactory
38   {
39     friend std::ostream & operator<<( std::ostream & str, const CapFactory & obj );
40
41   public:
42     /** Default ctor */
43     CapFactory();
44
45     /** Dtor */
46     ~CapFactory();
47
48   public:
49     /** Parse Capability from string providing Resolvable::Kind.
50      * \a strval_r is expected to define a valid Capability.
51      * \throw EXCEPTION on parse error.
52     */
53     Capability parse( const Resolvable::Kind & refers_r,
54                       const std::string & strval_r ) const;
55
56
57     /** Parse Capability providing Resolvable::Kind, name, Rel and Edition as strings.
58      * \throw EXCEPTION on parse error.
59     */
60     Capability parse( const Resolvable::Kind & refers_r,
61                       const std::string & name_r,
62                       const std::string & op_r,
63                       const std::string & edition_r ) const;
64
65     /** Parse Capability providing Resolvable::Kind, name, Rel and Edition.
66      * \throw EXCEPTION on parse error.
67     */
68     Capability parse( const Resolvable::Kind & refers_r,
69                       const std::string & name_r,
70                       Rel op_r,
71                       const Edition & edition_r ) const;
72
73     /** Special Capability, triggering evaluation of Hal
74      * capabilities when matched.
75     */
76     Capability halEvalCap() const;
77
78     /** Special Capability, triggering evaluation of modalias
79      * capabilities when matched.
80     */
81     Capability modaliasEvalCap() const;
82
83   public:
84     /** Provide a parsable string representation of \a cap_r. */
85     std::string encode( const Capability & cap_r ) const;
86
87   private:
88     /** Implementation */
89     struct Impl;
90     /** Pointer to implementation */
91     RW_pointer<Impl> _pimpl;
92   };
93   ///////////////////////////////////////////////////////////////////
94
95   /** \relates CapFactory Stream output */
96   extern std::ostream & operator<<( std::ostream & str, const CapFactory & obj );
97
98   /////////////////////////////////////////////////////////////////
99 } // namespace zypp
100 ///////////////////////////////////////////////////////////////////
101 #endif // ZYPP_CAPFACTORY_H