libzypp  17.23.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  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  }
39  }
40 
42  {
43  INT << "ReferenceCounted::unref: zero reference count" << std::endl;
44  throw std::out_of_range( "ReferenceCounted::unref: zero reference count" );
45  }
46 
47  std::ostream & ReferenceCounted::dumpOn( std::ostream & str ) const
48  {
49  return str << "ReferenceCounted(@" << (const void *)this
50  << "<=" << _counter << ")";
51  }
52 
54  } // namespace base
57 } // namespace zypp
zypp::base::ReferenceCounted::unrefException
void unrefException() const
Throws Exception on unref.
Definition: ReferenceCounted.cc:41
zypp::base::ReferenceCounted::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: ReferenceCounted.cc:47
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition: ReferenceCounted.h:33
INT
#define INT
Definition: Logger.h:83
Exception.h
Logger.h
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::base::ReferenceCounted::~ReferenceCounted
virtual ~ReferenceCounted()
Dtor.
Definition: ReferenceCounted.cc:33
zypp::base::ReferenceCounted::_counter
unsigned _counter
The reference counter.
Definition: ReferenceCounted.h:110
ReferenceCounted.h
zypp::base::ReferenceCounted::ReferenceCounted
ReferenceCounted()
Default ctor.
Definition: ReferenceCounted.cc:25
str
String related utilities and Regular expression matching.