libzypp: zypp-core/base/ReferenceCounted.cc Source File

libzypp 17.36.6

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
25 ReferenceCounted::ReferenceCounted()
26 : _counter( 0 )
27 {}
28
29 ReferenceCounted::ReferenceCounted( const ReferenceCounted & /*rhs*/ )
30 : _counter( 0 )
31 {}
32
33 ReferenceCounted::~ReferenceCounted()
34 {
35 if ( _counter )
36 {
37 INT << "~ReferenceCounted: nonzero reference count" << std::endl;
38 }
39 }
40
41 void ReferenceCounted::unrefException() const
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::~ReferenceCounted
virtual ~ReferenceCounted()
Dtor.
Definition ReferenceCounted.cc:33
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::unrefException
void unrefException() const
Throws Exception on unref.
Definition ReferenceCounted.cc:41
zypp::base::ReferenceCounted::_counter
unsigned _counter
The reference counter.
Definition ReferenceCounted.h:111
zypp::base::ReferenceCounted::ReferenceCounted
ReferenceCounted()
Default ctor.
Definition ReferenceCounted.cc:25
str
String related utilities and Regular expression matching.
zypp::base
Definition Random.cc:7
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
Exception.h
Logger.h
INT
#define INT
Definition Logger.h:104
ReferenceCounted.h