1
/*---------------------------------------------------------------------\
3
| |__ / \ / / . \ . \ |
8
\---------------------------------------------------------------------*/
9
/** \file zypp/SysContent.h
12
#ifndef ZYPP_SYSCONTENT_H
13
#define ZYPP_SYSCONTENT_H
19
#include "zypp/base/PtrTypes.h"
21
#include "zypp/PoolItem.h"
22
#include "zypp/Edition.h"
23
#include "zypp/Date.h"
25
///////////////////////////////////////////////////////////////////
27
{ /////////////////////////////////////////////////////////////////
28
///////////////////////////////////////////////////////////////////
30
{ /////////////////////////////////////////////////////////////////
32
///////////////////////////////////////////////////////////////////
34
// CLASS NAME : Writer
36
/** Collect and serialize a set of \ref ResObject.
38
* <?xml version="1.0" encoding="UTF-8"?>
41
* <name>mycollection</name>
42
* <version epoch="0" ver="1.0" rel="1"/>
43
* <description>All the cool stuff...</description>
44
* <created>1165270942</created>
47
* <entry kind="package" name="pax" epoch="0" ver="3.4" rel="12" arch="x86_64"/>
48
* <entry kind="product" name="SUSE_SLES" epoch="0" ver="10" arch="x86_64"/>
57
typedef std::set<ResObject::constPtr> StorageT;
59
typedef StorageT::value_type value_type;
60
typedef StorageT::size_type size_type;
61
typedef StorageT::iterator iterator;
62
typedef StorageT::const_iterator const_iterator;
69
/** \name Identification.
70
* User provided optional data to identify the collection.
74
const std::string & name() const;
77
Writer & name( const std::string & val_r );
80
const Edition & edition() const;
83
Writer & edition( const Edition & val_r );
85
/** Get description. */
86
const std::string & description() const;
88
/** Set description.*/
89
Writer & description( const std::string & val_r );
93
/** \name Collecting data.
95
* syscontent::Writer contentW;
96
* contentW.name( "mycollection" )
97
* .edition( Edition( "1.0" ) )
98
* .description( "All the cool stuff..." );
100
* ResPool pool( getZYpp()->pool() );
101
* for_each( pool.begin(), pool.end(),
102
* bind( &syscontent::Writer::addIf, ref(contentW), _1 ) );
104
* std::ofstream my_file( "some_file" );
105
* my_file << contentW;
110
/** Collect currently installed \ref PoolItem. */
111
void addInstalled( const PoolItem & obj_r );
113
/** Collect \ref PoolItem if it stays on the system.
114
* I.e. it stays installed or is tagged to be installed.
115
* Solver selected items are omitted.
117
void addIf( const PoolItem & obj_r );
119
/** Unconditionally add this \ref ResObject (or \ref PoolItem). */
120
void add( const ResObject::constPtr & obj_r );
124
/** \name Collected data. */
126
/** Whether no data collected so far. */
129
/** Number of items collected. */
130
size_type size() const;
132
/** Iterator to the begin of collected data. */
133
const_iterator begin() const;
135
/** Iterator to the end of collected data. */
136
const_iterator end() const;
140
/** Write collected data as XML.
141
* Read them back using \ref Reader.
143
std::ostream & writeXml( std::ostream & str ) const;
147
RWCOW_pointer<Impl> _pimpl;
149
///////////////////////////////////////////////////////////////////
151
/** \relates Writer Stream output */
152
inline std::ostream & operator<<( std::ostream & str, const Writer & obj )
153
{ return obj.writeXml( str ); }
155
///////////////////////////////////////////////////////////////////
157
// CLASS NAME : Reader
159
/** Retrieve \ref ResObject data serialized by \ref Writer.
165
/** Restored \ref ResObject data. */
169
typedef std::list<Entry> StorageT;
172
typedef StorageT::value_type value_type;
173
typedef StorageT::size_type size_type;
174
typedef StorageT::iterator iterator;
175
typedef StorageT::const_iterator const_iterator;
181
/** Ctor parsing data from \a input_r.
182
* \throws Exception on read or parse error.
184
Reader( std::istream & input_r );
187
/** \name Identification.
188
* User provided optional data to identify the collection.
192
const std::string & name() const;
195
const Edition & edition() const;
197
/** Get description. */
198
const std::string & description() const;
200
/** Get creation date. */
201
const Date & ctime() const;
204
/** \name Collected data. */
206
/** Whether no data collected so far. */
209
/** Number of items collected. */
210
size_type size() const;
212
/** Iterator to the begin of collected data. */
213
const_iterator begin() const;
215
/** Iterator to the end of collected data. */
216
const_iterator end() const;
221
RWCOW_pointer<Impl> _pimpl;
224
/** \relates Reader Stream output */
225
std::ostream & operator<<( std::ostream & str, const Reader & obj );
227
///////////////////////////////////////////////////////////////////
229
///////////////////////////////////////////////////////////////////
231
// CLASS NAME : Reader::Entry
233
/** Restored \ref ResObject data. */
238
const std::string & kind() const;
239
const std::string & name() const;
240
const Edition & edition() const;
241
const Arch & arch() const;
244
Entry( const shared_ptr<Impl> & pimpl_r );
246
RW_pointer<Impl> _pimpl;
248
///////////////////////////////////////////////////////////////////
250
/////////////////////////////////////////////////////////////////
251
} // namespace syscontent
252
///////////////////////////////////////////////////////////////////
253
/////////////////////////////////////////////////////////////////
255
///////////////////////////////////////////////////////////////////
256
#endif // ZYPP_SYSCONTENT_H