From: Christian P. <cp...@us...> - 2005-06-16 13:11:59
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29160/include/pclasses Modified Files: Phoenix.h Log Message: - Replaced old tracing messaging with P_TRACE ones Index: Phoenix.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Phoenix.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Phoenix.h 24 Dec 2004 23:04:29 -0000 1.4 +++ Phoenix.h 16 Jun 2005 13:11:49 -0000 1.5 @@ -10,22 +10,9 @@ //////////////////////////////////////////////////////////////////////////////// #include <stdlib.h> // atexit() -#include <iostream> // cout/cerr, only for debuggering - - -#ifndef phoenix_DEBUG -// enable debuggering to see when phoenixes are (re)created. -# define phoenix_DEBUG 0 -#endif +#include <typeinfo> -#if phoenix_DEBUG -# include <typeinfo> -# define phoenix_CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " \ - << "Phoenix<"<<typeid((base_type *)NULL).name()<<" , " \ - << typeid((context_type *)NULL).name()<<"> " -#else -# define phoenix_CERR if(0) std::cerr -#endif // phoenix_DEBUG +#include <pclasses/Trace.h> /** The Phoenix class acts as a wrapper for adding "phoenixing" behaviour to @@ -162,18 +149,26 @@ static bool donethat = false; if( this_type::m_destroyed ) { - phoenix_CERR << "Phoenixing!" << std::endl; + P_TRACE_GLOBAL() << "Phoenix<" << typeid(BaseType).name() + << "," << typeid(ContextType).name() << "> Phoenixing!"; + donethat = false; new( &meyers ) this_type; atexit( this_type::do_atexit ); } if( !donethat ) { - phoenix_CERR << "initializing instance" << std::endl; + P_TRACE_GLOBAL() << "Phoenix<" << typeid(BaseType).name() + << "," << typeid(ContextType).name() << "> init instance"; + donethat = true; initializer_type()( meyers ); } - phoenix_CERR << "instance() == " <<std::hex<<&meyers<<std::endl; + + P_TRACE_GLOBAL() << "Phoenix<" << typeid(BaseType).name() + << "," << typeid(ContextType).name() << ">::instance() == " + << std::hex << &meyers; + return meyers; } @@ -186,13 +181,13 @@ Phoenix() { - phoenix_CERR << "Phoenix() @" << std::hex<< this << std::endl; + P_TRACE(Phoenix) << "Phoenix()"; m_destroyed = false; } virtual ~Phoenix() throw() { - phoenix_CERR << "~Phoenix() @" << std::hex<< this << std::endl; + P_TRACE(Phoenix) << "~Phoenix()"; m_destroyed = true; } /** @@ -201,7 +196,7 @@ static void do_atexit() { if( m_destroyed ) return; - phoenix_CERR << "::do_atexit() @ " << std::hex << &instance() << std::endl; + P_TRACE_GLOBAL() << "Phoenix::do_atexit() @ " << std::hex << & instance(); static_cast<this_type &>(instance()).~Phoenix(); // will eventually trigger the BaseType dtor } @@ -210,6 +205,4 @@ } // namespace -#undef phoenix_DEBUG -#undef phoenix_CERR #endif // p_PHOENIX_HPP_INCLUDED |