work for bug 149869
[platform/upstream/libzypp.git] / zypp / target / store / PersistentStorage.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       devel/devel.dmacvicar/PersistentStorage.h
10 *
11 */
12 #ifndef ZYPP_TARGET_PERSISTENTSTORAGE_H
13 #define ZYPP_TARGET_PERSISTENTSTORAGE_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/ReferenceCounted.h"
18 #include "zypp/base/NonCopyable.h"
19 #include "zypp/base/PtrTypes.h"
20 #include <zypp/Pathname.h>
21 #include <zypp/Patch.h>
22
23 ///////////////////////////////////////////////////////////////////
24 namespace zypp
25 { /////////////////////////////////////////////////////////////////
26   ///////////////////////////////////////////////////////////////////
27   namespace storage
28   { /////////////////////////////////////////////////////////////////
29     ///////////////////////////////////////////////////////////////////
30     //
31     //  CLASS NAME : PersistentStorage
32     //
33     /** */
34     class PersistentStorage : public base::ReferenceCounted, private base::NonCopyable
35     {
36       friend std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
37       typedef intrusive_ptr<PersistentStorage> Ptr;
38       typedef intrusive_ptr<const PersistentStorage> constPtr;
39     public:
40       /** Default ctor */
41       PersistentStorage();
42       /** Dtor */
43       ~PersistentStorage();
44       void doTest();
45       
46       struct SourceData
47       {
48         SourceData()
49         {
50           enabled = false;
51           autorefresh = false;
52         };
53        
54         bool enabled;
55         bool autorefresh;
56         std::string product_dir;
57         std::string type;
58         std::string url;
59         std::string alias;
60       };
61
62     public:
63       /**
64        * Initializes the Storage when the system is located in some
65        * root path. THIS MUST BE CALLED BEFORE DOING ANY OPERATION
66        */
67        void init(const Pathname &root);
68
69       /**
70        * true is backend was already initialized
71        */
72        bool isInitalized();
73
74       /**
75        * Stores a Resolvable in the active backend.
76        */
77       void storeObject( ResObject::constPtr resolvable );
78       /**
79        * Deletes a Resolvable from the active backend.
80        */
81       void deleteObject( ResObject::constPtr resolvable );
82       /**
83        * Query for installed Resolvables.
84        */
85       std::list<ResObject::Ptr> storedObjects() const;
86        /**
87        * Query for installed Resolvables of a certain kind.
88        */
89       std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind kind) const;
90        /**
91        * Query for installed Resolvables of a certain kind by name
92        * \a partial_match allows for text search.
93        */
94       std::list<ResObject::Ptr> storedObjects(const Resolvable::Kind kind, const std::string & name, bool partial_match = false) const;
95
96       /////////////////////////////////////////////////////////
97       // SOURCES API
98       ////////////////////////////////////////////////////////
99       /**
100        * Query for installed Sources
101        */
102       std::list<SourceData> storedSources() const;
103       /**
104        * Query for installed Sources
105        */
106       void storeSource(const SourceData &data);
107       /**
108        * Query for installed Sources
109        */
110       void deleteSource(const std::string &alias);
111
112     private:
113       class Private;
114       Private *d;
115     };
116     ///////////////////////////////////////////////////////////////////
117     /** \relates PersistentStorage Stream output */
118     std::ostream & operator<<( std::ostream & str, const PersistentStorage & obj );
119
120     /////////////////////////////////////////////////////////////////
121   } // namespace storage
122   ///////////////////////////////////////////////////////////////////
123   /////////////////////////////////////////////////////////////////
124 } // namespace zypp
125 ///////////////////////////////////////////////////////////////////
126 #endif // ZYPP_TARGET_PERSISTENTSTORAGE_H