X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=zypp%2Fbase%2FDebug.h;h=fb724b9d4991ca5b94549f5121adb98dd4ae44a1;hb=42b5d038414cf4a4a050e816b471f890b24e8032;hp=e19d94ff939a1c23a1bcfdefeab04439f40be93d;hpb=b61a0ff7e76a542a874714e4ee7753db48f9f8aa;p=platform%2Fupstream%2Flibzypp.git diff --git a/zypp/base/Debug.h b/zypp/base/Debug.h index e19d94f..fb724b9 100644 --- a/zypp/base/Debug.h +++ b/zypp/base/Debug.h @@ -10,6 +10,7 @@ * * Debuging tools which should not be used in released code. */ +#ifndef ZYPP_NDEBUG #warning ZYPP_BASE_DEBUG_H included #ifndef ZYPP_BASE_DEBUG_H #define ZYPP_BASE_DEBUG_H @@ -65,7 +66,7 @@ namespace zypp */ struct TraceCADBase { - enum What { CTOR, COPYCTOR, ASSIGN, DTOR, PING }; + enum What { CTOR, COPYCTOR, MOVECTOR, ASSIGN, MOVEASSIGN, DTOR, PING }; std::string _ident; }; @@ -74,11 +75,13 @@ namespace zypp { switch( obj ) { - case TraceCADBase::CTOR: return str << "CTOR"; - case TraceCADBase::COPYCTOR: return str << "COPYCTOR"; - case TraceCADBase::ASSIGN: return str << "ASSIGN"; - case TraceCADBase::DTOR: return str << "DTOR"; - case TraceCADBase::PING: return str << "PING"; + case TraceCADBase::CTOR: return str << "CTOR"; + case TraceCADBase::COPYCTOR: return str << "COPYCTOR"; + case TraceCADBase::MOVECTOR: return str << "MOVECTOR"; + case TraceCADBase::ASSIGN: return str << "ASSIGN"; + case TraceCADBase::MOVEASSIGN: return str << "MOVEASSIGN"; + case TraceCADBase::DTOR: return str << "DTOR"; + case TraceCADBase::PING: return str << "PING"; } return str; } @@ -89,23 +92,23 @@ namespace zypp * traced method, and traceCAD simply drops a line in the log. * * This tracer logs construction, copy construction, assignment, - * destruction and _PING. + * destruction and ping. * * assignment: In case the traced class defines an operator= * it must be altered to call TraceCAD::operator=, otherwise it * won't be triggered. * - * _PING: Completely up to you. Call _PING somewhere in the traced + * ping: Completely up to you. Call ping somewhere in the traced * class to indicate something. In case you overload traceCAD, do - * whatever is appropriate on _PING. It's just an offer to perform + * whatever is appropriate on ping. It's just an offer to perform * logging or actions here, and not in the traced code. * * But traceCAD may be overloaded to produce more stats. * * \see \c Example.COW_debug.cc. */ - template - struct TraceCAD : public base::ProvideNumericId, unsigned long> + template + struct TraceCAD : public base::ProvideNumericId, unsigned long> , public TraceCADBase { static unsigned long & _totalTraceCAD() @@ -121,42 +124,51 @@ namespace zypp { ++_totalTraceCAD(); traceCAD( COPYCTOR, *this, rhs ); } + TraceCAD( TraceCAD && rhs ) + { ++_totalTraceCAD(); + traceCAD( MOVECTOR, *this, rhs ); } + TraceCAD & operator=( const TraceCAD & rhs ) { traceCAD( ASSIGN, *this, rhs ); return *this; } + TraceCAD & operator=( TraceCAD && rhs ) + { traceCAD( MOVEASSIGN, *this, rhs ); return *this; } + virtual ~TraceCAD() { --_totalTraceCAD(); traceCAD( DTOR, *this, *this ); } - void _PING() const + void ping() const { traceCAD( PING, *this, *this ); } }; /** \relates TraceCAD Stream output. */ - template - inline std::ostream & operator<<( std::ostream & str, const TraceCAD<_Tp> & obj ) + template + inline std::ostream & operator<<( std::ostream & str, const TraceCAD & obj ) { return str << "(ID " << obj.numericId() << ", TOTAL " << obj._totalTraceCAD() << ") [" << &obj << "] "; } /** Drop a log line about the traced method. Overload to * fit your needs. */ - template + template void traceCAD( TraceCADBase::What what_r, - const TraceCAD<_Tp> & self_r, - const TraceCAD<_Tp> & rhs_r ) + const TraceCAD & self_r, + const TraceCAD & rhs_r ) { switch( what_r ) { case TraceCADBase::CTOR: case TraceCADBase::PING: case TraceCADBase::DTOR: - _DBG("DEBUG") << what_r << self_r << " (" << self_r._ident << ")" << std::endl; + L_DBG("DEBUG") << what_r << self_r << " (" << self_r._ident << ")" << std::endl; break; case TraceCADBase::COPYCTOR: + case TraceCADBase::MOVECTOR: case TraceCADBase::ASSIGN: - _DBG("DEBUG") << what_r << self_r << "( " << rhs_r << ")" << " (" << self_r._ident << ")" << std::endl; + case TraceCADBase::MOVEASSIGN: + L_DBG("DEBUG") << what_r << self_r << "( " << rhs_r << ")" << " (" << self_r._ident << ")" << std::endl; break; } } @@ -170,3 +182,4 @@ namespace zypp } // namespace zypp /////////////////////////////////////////////////////////////////// #endif // ZYPP_BASE_DEBUG_H +#endif // ZYPP_NDEBUG