compilable milestone of the day
[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 #include "zypp/capability/CapabilityImpl.h"
21
22 ///////////////////////////////////////////////////////////////////
23 namespace zypp
24 { /////////////////////////////////////////////////////////////////
25
26   ///////////////////////////////////////////////////////////////////
27   //
28   //    CLASS NAME : CapFactory
29   //
30   /** Factory for creating Capability.
31    *
32    * Besides parsing, CapFactory asserts that equal capabilites
33    * share the same implementation.
34    *
35    * \todo define EXCEPTIONS
36    * \todo Parser needs improvement in speed and accuracy.
37   */
38   class CapFactory
39   {
40     friend std::ostream & operator<<( std::ostream & str, const CapFactory & obj );
41
42   public:
43     /** Default ctor */
44     CapFactory();
45
46     /** Dtor */
47     ~CapFactory();
48
49   public:
50     
51     /** Create capability from Implementation
52      * \a impl is a valid \ref CapabilityImpl Ptr
53      * \throw EXCEPTION on null capability
54     */
55     Capability fromImpl( capability::CapabilityImpl::Ptr impl ) const;
56     
57     /** Parse Capability from string providing Resolvable::Kind.
58      * \a strval_r is expected to define a valid Capability.
59      * \throw EXCEPTION on parse error.
60     */
61     Capability parse( const Resolvable::Kind & refers_r,
62                       const std::string & strval_r ) const;
63
64
65     /** Parse Capability providing Resolvable::Kind, name, Rel and Edition as strings.
66      * \throw EXCEPTION on parse error.
67     */
68     Capability parse( const Resolvable::Kind & refers_r,
69                       const std::string & name_r,
70                       const std::string & op_r,
71                       const std::string & edition_r ) const;
72
73     /** Parse Capability providing Resolvable::Kind, name, Rel and Edition.
74      * \throw EXCEPTION on parse error.
75     */
76     Capability parse( const Resolvable::Kind & refers_r,
77                       const std::string & name_r,
78                       Rel op_r,
79                       const Edition & edition_r ) const;
80
81     /** Special Capability, triggering evaluation of Hal
82      * capabilities when matched.
83     */
84     Capability halEvalCap() const;
85
86     /** Special Capability, triggering evaluation of modalias
87      * capabilities when matched.
88     */
89     Capability modaliasEvalCap() const;
90
91   public:
92     /** Provide a parsable string representation of \a cap_r. */
93     std::string encode( const Capability & cap_r ) const;
94
95   private:
96     /** Implementation */
97     struct Impl;
98     /** Pointer to implementation */
99     RW_pointer<Impl> _pimpl;
100   };
101   ///////////////////////////////////////////////////////////////////
102
103   /** \relates CapFactory Stream output */
104   extern std::ostream & operator<<( std::ostream & str, const CapFactory & obj );
105
106   /////////////////////////////////////////////////////////////////
107 } // namespace zypp
108 ///////////////////////////////////////////////////////////////////
109 #endif // ZYPP_CAPFACTORY_H