- Create the cache directly from the schema (installed) file.
[platform/upstream/libzypp.git] / zypp / ZYppFactory.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ZYppFactory.h
10  *
11 */
12 #ifndef ZYPP_ZYPPFACTORY_H
13 #define ZYPP_ZYPPFACTORY_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/Exception.h"
18 #include "zypp/ZYpp.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   class ZYppFactoryException : public Exception
25   {
26   public:
27     ZYppFactoryException( const std::string & msg_r );
28   };
29
30   ///////////////////////////////////////////////////////////////////
31   //
32   //    CLASS NAME : ZYppFactory
33   //
34   /** ZYpp factory class (Singleton)
35   */
36   class ZYppFactory
37   {
38     friend std::ostream & operator<<( std::ostream & str, const ZYppFactory & obj );
39
40   public:
41     /** Singleton ctor */
42     static ZYppFactory instance();
43     /** Dtor */
44     ~ZYppFactory();
45
46   public:
47     /** \return Pointer to the ZYpp instance.
48      * \throw EXCEPTION In case we can't acquire a lock.
49     */
50     ZYpp::Ptr getZYpp() const;
51
52   private:
53     /** Default ctor. */
54     ZYppFactory();
55   };
56   ///////////////////////////////////////////////////////////////////
57
58   /** \relates ZYppFactory Stream output */
59   std::ostream & operator<<( std::ostream & str, const ZYppFactory & obj );
60
61   /** \relates ZYppFactory Convenience to get the Pointer
62    * to the ZYpp instance.
63    * \see ZYppFactory::getZYpp
64   */
65   inline ZYpp::Ptr getZYpp()
66   { return ZYppFactory::instance().getZYpp(); }
67
68   /////////////////////////////////////////////////////////////////
69 } // namespace zypp
70 ///////////////////////////////////////////////////////////////////
71 #endif // ZYPP_ZYPPFACTORY_H