1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
10 #ifndef ZYPP_CacheStore_H
11 #define ZYPP_CacheStore_H
16 #include "zypp/base/ReferenceCounted.h"
17 #include "zypp/base/NonCopyable.h"
18 #include "zypp/base/PtrTypes.h"
19 #include "zypp/Pathname.h"
20 #include "zypp/NVRA.h"
21 #include "zypp/capability/CapabilityImpl.h"
22 #include "zypp/capability/Capabilities.h"
24 #include "zypp/data/ResolvableDataConsumer.h"
25 #include "zypp/data/RecordId.h"
27 #include "zypp/base/PtrTypes.h"
29 ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
37 * The cache store caches resolvable data into some backend.
47 * Constructor for the CacheStore
49 * \note a transaction will be started from the moment the
50 * CacheStore is instanciated.
52 * The data will be saved in the directory specified in
55 CacheStore( const Pathname &dbdir );
58 * Implements the ResolvableConsumer consumePackage interface
59 * Consumer a package and inserts it into the database.
60 * Don't use this method yet
62 virtual void consumePackage( const data::Package &package);
65 * Appends a resolvable to the store.
67 * You have to specify with \a kind of resolvable are you inserting
68 * and its \c NVRA (name version release and architecture ).
69 * Optionaly you can pass a list of \c CapabilityImpl::Ptr
70 * as dependencies for the resolvable.
72 * You have to specify the RecordId for the catalog owning
73 * this resolvable. Yuu can obtain it with
74 * \ref lookupOrAppendCatalog
76 * You can create those \a deps using \ref capability::parse
77 * functions, or the build methods to create specific types
79 * \ref capability::buildVersioned for \c VersionedCap
80 * \ref capability::buildNamed for \c NamedCap
83 * Once the resolvable is inserted, you will get back the id
84 * if it in the store. Which you can use for later adding
88 data::RecordId appendResolvable( const data::RecordId &catalog_id,
89 const Resolvable::Kind &kind,
91 const data::Dependencies &deps );
94 * Adds dependencies to the store
96 * A map of dependency lists has to be specified. The map contains
97 * list of capablities for each dependency type \ref zypp::Dep
99 * \a resolvable_id is the resolvable Id in the CacheStore
100 * that will own those capabilities.
102 * FIXME should it \throw if the resolvable does not exist?
104 void appendDependencies( const data::RecordId &resolvable_id,
105 const data::Dependencies &dependencies );
108 * Adds dependencies to the store
110 * A lists of dependencies \a dlist to be specified. Among
111 * which type of dependencies \ref zypp::Dep it is as
112 * the \a deptype argument.
114 * \a resolvable_id is the resolvable Id in the CacheStore
115 * that will own those capabilities.
117 * FIXME should it \throw if the resolvable does not exist?
119 void appendDependencyList( const data::RecordId &resolvable_id,
121 const data::DependencyList &dlist );
124 * Adds a dependency to the store.
126 * A \ref CapabilityImpl::Ptr argument \a cap has to be specified.
127 * Among which type of dependency \ref zypp::Dep it is as
128 * the \a deptype argument.
130 * \a resolvable_id is the resolvable Id in the CacheStore
131 * that will own the capability
133 * FIXME should it \throw if the resolvable does not exist?
135 void appendDependency( const data::RecordId &resolvable_id,
137 capability::CapabilityImpl::Ptr cap );
140 * Adds a Named dependency to the store.
142 * A \ref NamedCap::Ptr \a dlist to be specified. Among
143 * which type of dependency \ref zypp::Dep it is as
144 * the \a deptype argument.
146 * \a resolvable_id is the resolvable Id in the CacheStore
147 * that will own the capability
149 * You can create the named capability using either
150 * \ref capability::parse or \ref capability::buildNamed
152 * FIXME should it \throw if the resolvable does not exist?
154 void appendNamedDependency( const data::RecordId &, zypp::Dep,
155 capability::NamedCap::Ptr);
158 * Adds a file dependency to the store.
160 * A \ref FileCap::Ptr \a dlist to be specified. Among
161 * which type of dependency \ref zypp::Dep it is as
162 * the \a deptype argument.
164 * \a resolvable_id is the resolvable Id in the CacheStore
165 * that will own the capability
167 * You can create the file capability using either
168 * \ref capability::parse or \ref capability::buildFile
170 * FIXME should it \throw if the resolvable does not exist?
172 void appendFileDependency( const data::RecordId &, zypp::Dep,
173 capability::FileCap::Ptr);
176 * Adds a Modalias dependency to the store.
178 * A \ref ModaliasCap::Ptr \a cap to be specified. Among
179 * which type of dependency \ref zypp::Dep it is as
180 * the \a deptype argument.
182 * \a resolvable_id is the resolvable Id in the CacheStore
183 * that will own the capability
185 * You can create the modalias capability using either
186 * \ref capability::parse or \ref capability::buildModalias
188 * FIXME should it \throw if the resolvable does not exist?
190 void appendModaliasDependency( const data::RecordId &resolvable_id,
192 capability::ModaliasCap::Ptr cap);
195 * Adds a Hal dependency to the store.
197 * A \ref HalCap::Ptr \a cap to be specified. Among
198 * which type of dependency \ref zypp::Dep it is as
199 * the \a deptype argument.
201 * \a resolvable_id is the resolvable Id in the CacheStore
202 * that will own the capability
204 * You can create the modalias capability using either
205 * \ref capability::parse or \ref capability::buildHal
207 * FIXME should it \throw if the resolvable does not exist?
209 void appendHalDependency( const data::RecordId &resolvable_id,
211 capability::HalCap::Ptr cap );
214 * Adds a unknown dependency to the store.
216 * A \ref Capability::Ptr \a cap to be specified. Among
217 * which type of dependency \ref zypp::Dep it is as
218 * the \a deptype argument.
220 * \a resolvable_id is the resolvable Id in the CacheStore
221 * that will own the capability
223 * You can create the capability using either
224 * \ref capability::parse
226 * FIXME should it \throw if the resolvable does not exist?
228 void appendUnknownDependency( const data::RecordId &resolvable_id,
230 capability::CapabilityImpl::Ptr cap );
233 * Returns the record id of a catalog (Source) \a path
235 * \note If the catalog entry does not exist, it will
236 * be created and the new inserted entry's id will
239 data::RecordId lookupOrAppendCatalog( const Url &url,
240 const Pathname &path );
243 * Update a known catalog checksum and timestamp
245 * \note If you don't provide timestamp it defaults
248 * It is responsability of the caller to operate with
249 * a valid record id. You can get one
250 * Using \ref lookupOrAppendCatalog
252 void updateCatalog( const data::RecordId &id,
253 const std::string &checksum,
254 const Date ×tamp = Date::now() );
257 * Returns the record id of a file entry \a path
259 * \note If the file entry does not exist, it will
260 * be created and the new inserted entry's id will
263 data::RecordId lookupOrAppendFile( const Pathname &path );
266 * Returns the record id of a name entry \a name
268 * \note If the name entry does not exist, it will
269 * be created and the new inserted entry's id will
272 data::RecordId lookupOrAppendName( const std::string &name );
275 * Returns the record id of a directory name entry \a name
277 * \note If the directory name entry does not exist, it will
278 * be created and the new inserted entry's id will
281 data::RecordId lookupOrAppendDirName( const std::string &name );
284 * Returns the record id of a file name entry \a name
286 * \note If the file name entry does not exist, it will
287 * be created and the new inserted entry's id will
290 data::RecordId lookupOrAppendFileName( const std::string &name );
294 * Internally used function that appends a entry in
295 * the capabilities table for a specific capability
298 // data::RecordId appendDependencyEntry( const data::RecordId &,
299 // zypp::Dep, const Resolvable::Kind & );
302 /** Implementation. */
304 /** Pointer to implementation. */
305 RW_pointer<Impl> _pimpl;