libzypp 17.31.23
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-core/base/Logger.h>
15#include <zypp-core/base/Exception.h>
16#include <zypp-core/base/ReferenceCounted.h>
17
19namespace zypp
20{
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 }
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
Base class for reference counted objects.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
void unrefException() const
Throws Exception on unref.
unsigned _counter
The reference counter.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
#define INT
Definition: Logger.h:100