libzypp  13.10.6
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 {
25  namespace pool
27  {
28 
30  //
31  // CLASS NAME : PoolStats
32  //
44  struct PoolStats : public std::unary_function<ResObject::constPtr, void>
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 _Iterator>
70  std::ostream & dumpPoolStats( std::ostream & str,
71  _Iterator begin_r, _Iterator 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
std::ostream & dumpPoolStats(std::ostream &str, _Iterator begin_r, _Iterator end_r)
Definition: PoolStats.h:70
std::ostream & operator<<(std::ostream &str, const PoolStats &obj)
Definition: PoolStats.cc:31
TraitsType::constPtrType constPtr
Definition: ResObject.h:50
void operator()(ResObject::constPtr ptr)
Definition: PoolStats.h:46
Functor counting ResObjects per Kind.
Definition: PoolStats.h:44
Counter< unsigned > _total
Definition: PoolStats.h:53
std::map< ResKind, Counter< unsigned > > KindMap
Definition: PoolStats.h:52