libzypp 17.31.23
PoolStats.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_POOL_POOLSTATS_H
13#define ZYPP_POOL_POOLSTATS_H
14
15#include <iosfwd>
16
17#include <zypp/base/Iterator.h>
19#include <zypp/base/Counter.h>
20#include <zypp/ResObject.h>
21
23namespace zypp
24{
26 namespace pool
27 {
28
30 //
31 // CLASS NAME : PoolStats
32 //
44 struct PoolStats
45 {
47 {
48 ++_total;
49 ++_perKind[ptr->kind()];
50 }
51 public:
52 typedef std::map<ResKind,Counter<unsigned> > KindMap;
55 };
57
59 std::ostream & operator<<( std::ostream & str, const PoolStats & obj );
60
62 } // namespace pool
64
69 template <class TIterator>
70 std::ostream & dumpPoolStats( std::ostream & str,
71 TIterator begin_r, TIterator end_r )
72 {
73 pool::PoolStats stats;
74 std::for_each( begin_r, end_r, std::ref(stats) );
75 return str << stats;
76 }
77
79} // namespace zypp
81#endif // ZYPP_POOL_POOLSTATS_H
Integral type with initial value 0.
Definition: Counter.h:29
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const PoolStats &obj)
Definition: PoolStats.cc:31
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Functor counting ResObjects per Kind.
Definition: PoolStats.h:45
void operator()(ResObject::constPtr ptr)
Definition: PoolStats.h:46
std::ostream & dumpPoolStats(std::ostream &str, TIterator begin_r, TIterator end_r)
Convenience to count and print out the number of ResObjects per Kind in a container.
Definition: PoolStats.h:70
std::map< ResKind, Counter< unsigned > > KindMap
Definition: PoolStats.h:52
Counter< unsigned > _total
Definition: PoolStats.h:53