1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZYppFactory.h
12 #ifndef ZYPP_ZYPPFACTORY_H
13 #define ZYPP_ZYPPFACTORY_H
17 #include "zypp/base/Exception.h"
18 #include "zypp/ZYpp.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 class ZYppFactoryException : public Exception
27 ZYppFactoryException( const std::string & msg_r, pid_t lockerPid_r, const std::string & lockerName_r );
28 virtual ~ZYppFactoryException() throw ();
30 pid_t lockerPid() const { return _lockerPid; }
31 const std::string & lockerName() const { return _lockerName; }
34 std::string _lockerName;
37 ///////////////////////////////////////////////////////////////////
39 // CLASS NAME : ZYppFactory
41 /** ZYpp factory class (Singleton)
45 friend std::ostream & operator<<( std::ostream & str, const ZYppFactory & obj );
49 static ZYppFactory instance();
54 /** \return Pointer to the ZYpp instance.
55 * \throw EXCEPTION In case we can't acquire a lock.
57 ZYpp::Ptr getZYpp() const;
59 /** Whether the ZYpp instance is already created.*/
60 bool haveZYpp() const;
66 ///////////////////////////////////////////////////////////////////
68 /** \relates ZYppFactory Stream output */
69 std::ostream & operator<<( std::ostream & str, const ZYppFactory & obj );
71 /** \relates ZYppFactory Convenience to get the Pointer
72 * to the ZYpp instance.
73 * \see ZYppFactory::getZYpp
75 inline ZYpp::Ptr getZYpp()
76 { return ZYppFactory::instance().getZYpp(); }
78 /////////////////////////////////////////////////////////////////
80 ///////////////////////////////////////////////////////////////////
81 #endif // ZYPP_ZYPPFACTORY_H