libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #include <iostream> 00013 00014 #include "zypp/base/Logger.h" 00015 #include "zypp/base/Exception.h" 00016 #include "zypp/base/ReferenceCounted.h" 00017 00019 namespace zypp 00020 { 00021 00022 namespace base 00023 { 00024 00025 ReferenceCounted::ReferenceCounted() 00026 : _counter( 0 ) 00027 {} 00028 00029 ReferenceCounted::ReferenceCounted( const ReferenceCounted & /*rhs*/ ) 00030 : _counter( 0 ) 00031 {} 00032 00033 ReferenceCounted::~ReferenceCounted() 00034 { 00035 if ( _counter ) 00036 { 00037 INT << "~ReferenceCounted: nonzero reference count" << std::endl; 00038 throw std::out_of_range( "~ReferenceCounted: nonzero reference count" ); 00039 } 00040 } 00041 00042 void ReferenceCounted::unrefException() const 00043 { 00044 INT << "ReferenceCounted::unref: zero reference count" << std::endl; 00045 throw std::out_of_range( "ReferenceCounted::unref: zero reference count" ); 00046 } 00047 00048 std::ostream & ReferenceCounted::dumpOn( std::ostream & str ) const 00049 { 00050 return str << "ReferenceCounted(@" << (const void *)this 00051 << "<=" << _counter << ")"; 00052 } 00053 00055 } // namespace base 00058 } // namespace zypp