libzypp 17.37.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
45 {
46 void operator()( const ResObject::constPtr& ptr )
47 {
48 ++_total;
49 ++_perKind[ptr->kind()];
50 }
51 public:
52 using KindMap = std::map<ResKind, Counter<unsigned int>>;
53 Counter<unsigned> _total;
54 KindMap _perKind;
55 };
56
57
59 std::ostream & operator<<( std::ostream & str, const PoolStats & obj ) ZYPP_API;
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
Counter.h
Functional.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
Definition ByIdent.h:24
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 Application.cc:20
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::pool::PoolStats
Functor counting ResObjects per Kind.
Definition PoolStats.h:45
zypp::pool::PoolStats::operator()
void operator()(const ResObject::constPtr &ptr)
Definition PoolStats.h:46
zypp::pool::PoolStats::_perKind
KindMap _perKind
Definition PoolStats.h:54
zypp::pool::PoolStats::KindMap
std::map< ResKind, Counter< unsigned int > > KindMap
Definition PoolStats.h:52
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::_total
Counter< unsigned > _total
Definition PoolStats.h:53
Iterator.h