libzypp  11.13.5
ReferenceCounted.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 
14 #include "zypp/base/Logger.h"
15 #include "zypp/base/Exception.h"
17 
19 namespace zypp
20 {
21 
22  namespace base
23  {
24 
26  : _counter( 0 )
27  {}
28 
30  : _counter( 0 )
31  {}
32 
34  {
35  if ( _counter )
36  {
37  INT << "~ReferenceCounted: nonzero reference count" << std::endl;
38  throw std::out_of_range( "~ReferenceCounted: nonzero reference count" );
39  }
40  }
41 
43  {
44  INT << "ReferenceCounted::unref: zero reference count" << std::endl;
45  throw std::out_of_range( "ReferenceCounted::unref: zero reference count" );
46  }
47 
48  std::ostream & ReferenceCounted::dumpOn( std::ostream & str ) const
49  {
50  return str << "ReferenceCounted(@" << (const void *)this
51  << "<=" << _counter << ")";
52  }
53 
55  } // namespace base
58 } // namespace zypp