libzypp: zypp/pool/PoolStats.h Source File

libzypp 17.25.10

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>
18 #include <zypp/base/Functional.h>
19 #include <zypp/base/Counter.h>
20 #include <zypp/ResObject.h>
21
23 namespace zypp
24 {
26 namespace pool
27 {
28
30 //
31 // CLASS NAME : PoolStats
32 //
44 struct PoolStats : public std::unary_function<ResObject::constPtr, void>
45 {
46 void operator()( ResObject::constPtr ptr )
47 {
48 ++_total;
49 ++_perKind[ptr->kind()];
50 }
51 public:
52 typedef std::map<ResKind,Counter<unsigned> > KindMap;
53 Counter<unsigned> _total;
54 KindMap _perKind;
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,
75 functor::functorRef<void,ResObject::constPtr>(stats) );
76 return str << stats;
77 }
78
80 } // namespace zypp
82 #endif // ZYPP_POOL_POOLSTATS_H
Counter.h
Functional.h
Iterator.h
ResObject.h
zypp::Counter
Integral type with initial value 0.
Definition: Counter.h:29
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
str
String related utilities and Regular expression matching.
zypp::pool::operator<<
std::ostream & operator<<(std::ostream &str, const PoolStats &obj)
Definition: PoolStats.cc:31
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::pool::PoolStats
Functor counting ResObjects per Kind.
Definition: PoolStats.h:45
zypp::pool::PoolStats::_perKind
KindMap _perKind
Definition: PoolStats.h:54
zypp::pool::PoolStats::operator()
void operator()(ResObject::constPtr ptr)
Definition: PoolStats.h:46
zypp::pool::PoolStats::dumpPoolStats
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
zypp::pool::PoolStats::KindMap
std::map< ResKind, Counter< unsigned > > KindMap
Definition: PoolStats.h:52
zypp::pool::PoolStats::_total
Counter< unsigned > _total
Definition: PoolStats.h:53