Commit d7173382 authored by Martin Marinov's avatar Martin Marinov
Browse files

Reformatting some of the debug related code.

[git-p4: depot-paths = "//ReForm/ReForm/main/Base/": change = 10521]
parent 3d053053
......@@ -8,21 +8,21 @@
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef REFORM_DEBUG_OUT_HH_INCLUDED
#define REFORM_DEBUG_OUT_HH_INCLUDED
#ifndef REFORM_DEBOUT_HH_INCLUDED
#define REFORM_DEBOUT_HH_INCLUDED
// DEB_ON is defined, or not, in Cmakelists.txt for primary project
#ifndef DEB_ON
#define DEB_module(SS)
#define DEB_enter_func
#define DEB_module(SS)
#define DEB_enter_func
#define DEB_only( CC )
#define DEB_out(LL, AA ) {}
#define DEB_out_if( CC, LL, AA ) {}
#define DEB_out_if( CC, LL, AA ) {}
#define DEB_warning( LL, AA ) {}
#define DEB_warning_if( CC, LL, AA ) {}
#define DEB_mesh_if( CC, LL, FF, MM ) {}
#define DEB_warning_if( CC, LL, AA ) {}
#define DEB_mesh_if( CC, LL, FF, MM ) {}
#define DEB_error(AA) {}
#define DEB_error_if(CC, AA) {}
......@@ -35,7 +35,7 @@ namespace ReForm {}
#define DEB_module(SS) static const char * l_g_module = SS;
/* TODO: This should use an atomic thread safe static int
/* TODO: This should use an atomic thread safe static int
*/
#define DEB_enter_func static int deb_enter_count =0; \
ReForm::DebEnter deb(__FUNCTION__, deb_enter_count++, l_g_module);
......@@ -62,18 +62,17 @@ namespace ReForm {}
#define DEB_error(AA) { if (deb.permission(0, 1) )\
{ deb.stream(1) << "Error:" << AA << deb.end_lf(); } }
#define DEB_error_if(CC, AA) if (CC) DEB_error(AA)
#define DEB_error_if(CC, AA) if (CC) DEB_error(AA)
// DebStream does not fulfill ostream. If you want to exploit an existing
// ostream streamer to DEB_out a class as text without exploiting any
// ostream streamer to DEB_out a class as text without exploiting any
// numeric processing or custom DebStream streamers then use this macro thus
// DEB_out(1, "my_class is " << DEB_os_str(my_c) )
#define DEB_os_str(AA) dynamic_cast<std::ostringstream &>((std::ostringstream() << AA )).str()
namespace ReForm
{
namespace ReForm {
class DebStream;
class DebCommand
......@@ -85,88 +84,100 @@ public:
end_lf = 0x03
};
CommandType com_;
CommandType com() const { return com_; }
CommandType com() const
{
return com_;
}
DebCommand(CommandType _com) : com_(_com) {}
~DebCommand() {};
};
// Class used to maintain DebStream's CallStack
// This does not currently contain a pointer to the file streamer used
// but might do in future.
class DebEnter
{
public:
int id_; /*!< Unique identifier for this DebEnter (used in ANCHORS) */
int count_; /*!< deb_enter_count for this function. */
int deb_outs_; /*!< Number of DEB_outs encountered within this function
// Class used to maintain DebStream's CallStack
// This does not currently contain a pointer to the file streamer used
// but might do in future.
class DebEnter
{
public:
int id_; /*!< Unique identifier for this DebEnter (used in ANCHORS) */
int count_; /*!< deb_enter_count for this function. */
int deb_outs_; /*!< Number of DEB_outs encountered within this function
determining whether a given DEB_out should include or omit
a call stack or exit trace. */
int deb_lines_; /*!< Number of call stack indents including this call. */
const char * module_; /*!< Module name for this DEB_enter. */
int deb_lines_; /*!< Number of call stack indents including this call. */
const char* module_; /*!< Module name for this DEB_enter. */
DebEnter(const char * const _funcname, const int _count,const char * const _module);
~DebEnter();
DebStream& stream(const int _warn = 0, const bool _print = true);
int permission(const int _lev, const int _warn=0);
DebEnter(const char* const _funcname, const int _count, const char* const _module);
~DebEnter();
DebStream& stream(const int _warn = 0, const bool _print = true);
int permission(const int _lev, const int _warn = 0);
DebCommand end() { return DebCommand(DebCommand::CommandType::end); }
DebCommand end_lf() { return DebCommand(DebCommand::CommandType::end_lf); }
};
DebCommand end()
{
return DebCommand(DebCommand::CommandType::end);
}
DebCommand end_lf()
{
return DebCommand(DebCommand::CommandType::end_lf);
}
};
class DebFile;
class DebStream
{
public:
enum StreamType
{
append = 0x01,
html = 0x02,
retain = 0x04,
keep_open = 0x08
};
private:
DebFile * dfile_;
public:
DebFile * dfile() const { return dfile_;}
//! Constructor.
DebStream(
const char * _file_name = nullptr, //!< [in] File name if file based.
const StreamType _type = append //!< [in] bitsfield enum type identifier
) ;
~DebStream();
DebStream& print(const int);
DebStream& print(const double);
DebStream& print(const char * const, bool fork = true);
DebStream& print(const char);
DebStream& print(const DebCommand &);
//! Get the currently active DebStream
static DebStream& get_global(int _warn=0);
class DebFile;
class DebStream
{
public:
enum StreamType
{
append = 0x01,
html = 0x02,
retain = 0x04,
keep_open = 0x08
};
DebStream& operator<<(DebStream& ds, const int i );
DebStream& operator<<(DebStream& ds, const double d );
private:
DebFile* dfile_;
public:
DebFile* dfile() const
{
return dfile_;
}
//! Constructor.
DebStream(
const char* _file_name = nullptr, //!< [in] File name if file based.
const StreamType _type = append //!< [in] bitsfield enum type identifier
) ;
~DebStream();
DebStream& print(const int);
DebStream& print(const double);
DebStream& print(const char* const, bool fork = true);
DebStream& print(const char);
DebStream& print(const DebCommand&);
//! Get the currently active DebStream
static DebStream& get_global(int _warn = 0);
};
DebStream& operator<<(DebStream& ds, const int i);
DebStream& operator<<(DebStream& ds, const double d);
DebStream& operator<<(DebStream& ds, const size_t i );
DebStream& operator<<(DebStream& ds, const unsigned int i );
DebStream& operator<<(DebStream& ds, const float d );
DebStream& operator<<(DebStream& ds, const size_t i);
DebStream& operator<<(DebStream& ds, const unsigned int i);
DebStream& operator<<(DebStream& ds, const float d);
DebStream& operator<<(DebStream& ds, const char c);
DebStream& operator<<(DebStream& ds, const char* const s );
DebStream& operator<<(DebStream& ds, const std::string& s );
DebStream& operator<<(DebStream& ds, const char* const s);
DebStream& operator<<(DebStream& ds, const std::string& s);
DebStream& operator<<(DebStream& ds, const DebCommand& co );
DebStream& operator<<(DebStream& ds, const DebCommand& co);
// A std::stream streamer might be useful here. Add when needed.
}//namespace
}//namespace
#endif // DEB_out_INCLUDED
#endif // REFORM_DEBUG_OUT_HH_INCLUDED
#endif//REFORM_DEBOUT_HH_INCLUDED
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment