author Dmitriy Morozov <>
Thu, 21 Dec 2006 13:32:34 -0500
changeset 5 ee9052408c40
parent 4 c1be260ad990
permissions -rw-r--r--
Switched to a new architecture (Vineyard is a visitor for Filtration), added LowerStarFilation, examples/grid (pdbdistance-vineyard in particular)

#include "sys.h"
#include "debug.h"

#ifdef CWDEBUG

namespace dionysus
	namespace debug 
		namespace channels 		// DEBUGCHANNELS is set to this in debug.h
			namespace dc 
		        // Add new debug channels here.
				channel_ct filtration("FILTRATION");
				channel_ct transpositions("TRANSPOS");
				channel_ct vineyard("VINEYARD");
				channel_ct cycle("CYCLE");
				channel_ct lsfiltration("LSFILTRATION");
				channel_ct orderlist("ORDERLIST");
    	} // namespace DEBUGCHANNELS

		// Initialize debugging code from new threads.
		void init_thread(void)
			// Everything below needs to be repeated at the start of every
			// thread function, because every thread starts in a completely
			// reset state with all debug channels off etc.
			#if LIBCWD_THREAD_SAFE		// For the non-threaded case this is set by the rcfile.
			// Turn on all debug channels by default.
			ForAllDebugChannels(while(!debugChannel.is_on()) debugChannel.on());
			// Turn off specific debug channels.
			// Turn on debug output.
			// Only turn on debug output when the environment variable SUPPRESS_DEBUG_OUTPUT is not set.
			Debug(if (getenv("SUPPRESS_DEBUG_OUTPUT") == NULL) libcw_do.on());
			Debug(libcw_do.set_ostream(&std::cout, &cout_mutex));
			// Set the thread id in the margin.
			char margin[12];
			sprintf(margin, "%-10lu ", pthread_self());
			Debug(libcw_do.margin().assign(margin, 11));
			// Write a list of all existing debug channels to the default debug device.
		// Initialize debugging code from main().
		void init(void)
			// You want this, unless you mix streams output with C output.
			// Read for an explanation.
			// We can't use it, because other code uses printf to write to the console.

			// This will warn you when you are using header files that do not belong to the
			// shared libcwd object that you linked with.
			// Remove all current (pre- main) allocations from the Allocated Memory Overview.
	} // namespace debug
} // namespace dionysus

#endif // CWDEBUG