libzypp  17.28.5
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 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
std::ostream & operator<<(std::ostream &str, const PoolStats &obj)
Definition: PoolStats.cc:31
String related utilities and Regular expression matching.
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
void operator()(ResObject::constPtr ptr)
Definition: PoolStats.h:46
Functor counting ResObjects per Kind.
Definition: PoolStats.h:44
std::ostream & dumpPoolStats(std::ostream &str, TIterator begin_r, TIterator end_r)
Definition: PoolStats.h:70
Counter< unsigned > _total
Definition: PoolStats.h:53
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::map< ResKind, Counter< unsigned > > KindMap
Definition: PoolStats.h:52