Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CoMISo
Base
Commits
aeab4906
Commit
aeab4906
authored
Dec 17, 2015
by
Max Lyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed c++11
parent
189b7646
Pipeline
#461
skipped
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1338 additions
and
1316 deletions
+1338
-1316
Debug/DebOut.hh
Debug/DebOut.hh
+250
-230
Debug/DebStream.cc
Debug/DebStream.cc
+1087
-1085
Debug/DebTime.hh
Debug/DebTime.hh
+1
-1
No files found.
Debug/DebOut.hh
View file @
aeab4906
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_DEBOUT_HH_INCLUDED
#define BASE_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_only(CC)
#define DEB_exec(LL, AA) {}
#define DEB_exec_if(CC, LL, AA) {}
#define DEB_out(LL, AA) {}
#define DEB_out_if(CC, LL, AA) {}
#define DEB_line(LL, AA) {}
#define DEB_line_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_error(AA) {}
#define DEB_error_if(CC, AA) {}
#else // DEB_ON
#include <string>
#include <vector>
#include <array>
namespace
Debug
{
const
int
INVALID_LEVEL
=
-
1
;
class
Stream
;
class
Command
{
public:
enum
CommandType
{
END
=
0x01
,
END_LF
=
0x03
,
END_ERR
=
0x07
};
CommandType
com_
;
CommandType
com
()
const
{
return
com_
;
}
Command
(
CommandType
_com
)
:
com_
(
_com
)
{}
};
// Class used to maintain Stream's CallStack
// This does not currently contain a pointer to the file streamer used
// but might do in future.
class
Enter
{
public:
const
char
*
flnm_
;
//!< File name for this DEB_enter
int
nmbr_
;
//!< deb_nmbr for this function.
int
lvl_
;
//!< deb_level for this function.
int
id_
;
/*!< Unique identifier for this Enter (used in ANCHORS) */
int
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
lns_
;
/*!< Number of call stack indents including this call. */
Enter
(
const
char
*
const
_flnm
,
const
char
*
const
_fnct
,
int
&
_nmbr
,
int
&
_lvl
);
~
Enter
();
//! pass the output on the level or not?
bool
pass
(
const
int
_lvl
)
const
{
return
_lvl
<=
lvl_
;
}
Stream
&
stream
(
const
int
_warn
=
0
,
const
bool
_print
=
true
);
Command
end
()
const
{
return
Command
(
Command
::
CommandType
::
END
);
}
Command
end_lf
()
const
{
return
Command
(
Command
::
CommandType
::
END_LF
);
}
Command
end_err
()
const
{
return
Command
(
Command
::
CommandType
::
END_ERR
);
}
};
class
File
;
class
Stream
{
public:
enum
StreamType
{
APPEND
=
0x01
,
HTML
=
0x02
,
RETAIN
=
0x04
,
KEEP_OPEN
=
0x08
};
private:
File
*
dfile_
;
public:
File
*
dfile
()
const
{
return
dfile_
;
}
//! Constructor.
Stream
(
const
char
*
_file_name
=
nullptr
,
//!< [in] File name if file based.
const
StreamType
_type
=
APPEND
//!< [in] bitsfield enum type identifier
)
;
~
Stream
();
const
char
*
string_out
()
const
;
Stream
&
print
(
const
int
);
Stream
&
print
(
const
double
);
Stream
&
print
(
const
char
*
const
,
bool
fork
=
true
);
Stream
&
print
(
const
char
);
Stream
&
print
(
const
Command
&
);
//! Get the currently active Stream
static
Stream
&
get_global
(
int
_warn
=
0
);
private:
// inhibit copy
Stream
(
const
Stream
&
);
Stream
&
operator
=
(
const
Stream
&
);
};
Stream
&
operator
<<
(
Stream
&
_ds
,
const
int
i
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
double
d
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
size_t
i
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
unsigned
int
i
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
float
d
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
char
c
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
char
*
const
s
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
string
&
s
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
Command
&
co
);
// Stream operator for std::vector<>
template
<
typename
ElementT
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
vector
<
ElementT
>&
_vec
)
{
_ds
<<
"[ "
;
for
(
const
auto
el
:
_vec
)
_ds
<<
el
<<
" "
;
_ds
<<
"]"
;
return
_ds
;
}
// Stream operator for std::array<>
template
<
typename
ElementT
,
size_t
_el_nmbr
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
array
<
ElementT
,
_el_nmbr
>&
_vec
)
{
_ds
<<
"[ "
;
for
(
const
auto
el
:
_vec
)
_ds
<<
el
<<
" "
;
_ds
<<
"]"
;
return
_ds
;
}
// Stream operator for fixed size arrays
template
<
typename
ElementT
,
size_t
_el_nmbr
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
ElementT
(
&
_arr
)[
_el_nmbr
])
{
_ds
<<
"[ "
;
for
(
const
auto
el
:
_arr
)
_ds
<<
el
<<
" "
;
_ds
<<
"]"
;
return
_ds
;
}
// Stream std::pair<>
template
<
typename
T0
,
typename
T1
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
pair
<
T0
,
T1
>&
_pair
)
{
_ds
<<
"("
<<
_pair
.
first
<<
", "
<<
_pair
.
second
<<
")"
;
return
_ds
;
}
#define DEB_module(MODULE)
//TODO: This should use an atomic thread-safe static int(s)
#define DEB_enter_func static int deb_nmbr = 0; \
static int deb_lvl = Debug::INVALID_LEVEL; \
Debug::Enter deb(__FILE__, __FUNCTION__, deb_nmbr, deb_lvl);
#define DEB_only(CC) CC
#define DEB_exec(LL, AA) DEB_exec_if(true, LL, AA)
#define DEB_exec_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) { AA; } }
#define DEB_out(LL, AA) DEB_out_if(true, LL, AA)
#define DEB_out_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{ deb.stream() << AA << deb.end(); } }
#define DEB_line(LL, AA) DEB_line_if(true, LL, AA)
#define DEB_line_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{ deb.stream() << AA << deb.end_lf(); } }
#define DEB_warning(LL, AA) DEB_warning_if(true, LL, AA)
#define DEB_warning_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{ deb.stream(1) << "WARNING: " << AA << deb.end_lf(); } }
#define DEB_error(AA) { deb.stream(2) << "ERROR: " << AA << deb.end_err(); }
#define DEB_error_if(CC, AA) { if (CC) DEB_error(AA); }
// Stream does not fulfill ostream. If you want to exploit an existing
// ostream streamer to DEB_out a class as text without exploiting any
// numeric processing or custom Stream 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 Debug
#endif // DEB_ON
#endif // BASE_DEBOUT_HH_INCLUDED
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_DEBOUT_HH_INCLUDED
#define BASE_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_only(CC)
#define DEB_exec(LL, AA) {}
#define DEB_exec_if(CC, LL, AA) {}
#define DEB_out(LL, AA) {}
#define DEB_out_if(CC, LL, AA) {}
#define DEB_line(LL, AA) {}
#define DEB_line_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_error(AA) {}
#define DEB_error_if(CC, AA) {}
#else // DEB_ON
#include <string>
#include <sstream>
#include <vector>
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#include <array>
#endif
namespace
Debug
{
const
int
INVALID_LEVEL
=
-
1
;
class
Stream
;
class
Command
{
public:
enum
CommandType
{
END
=
0x01
,
END_LF
=
0x03
,
END_ERR
=
0x07
};
CommandType
com_
;
CommandType
com
()
const
{
return
com_
;
}
Command
(
CommandType
_com
)
:
com_
(
_com
)
{}
};
// Class used to maintain Stream's CallStack
// This does not currently contain a pointer to the file streamer used
// but might do in future.
class
Enter
{
public:
const
char
*
flnm_
;
//!< File name for this DEB_enter
int
nmbr_
;
//!< deb_nmbr for this function.
int
lvl_
;
//!< deb_level for this function.
int
id_
;
/*!< Unique identifier for this Enter (used in ANCHORS) */
int
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
lns_
;
/*!< Number of call stack indents including this call. */
Enter
(
const
char
*
const
_flnm
,
const
char
*
const
_fnct
,
int
&
_nmbr
,
int
&
_lvl
);
~
Enter
();
//! pass the output on the level or not?
bool
pass
(
const
int
_lvl
)
const
{
return
_lvl
<=
lvl_
;
}
Stream
&
stream
(
const
int
_warn
=
0
,
const
bool
_print
=
true
);
Command
end
()
const
{
return
Command
(
Command
::
END
);
}
Command
end_lf
()
const
{
return
Command
(
Command
::
END_LF
);
}
Command
end_err
()
const
{
return
Command
(
Command
::
END_ERR
);
}
};
class
File
;
class
Stream
{
public:
enum
StreamType
{
APPEND
=
0x01
,
HTML
=
0x02
,
RETAIN
=
0x04
,
KEEP_OPEN
=
0x08
};
private:
File
*
dfile_
;
public:
File
*
dfile
()
const
{
return
dfile_
;
}
//! Constructor.
Stream
(
const
char
*
_file_name
=
NULL
,
//!< [in] File name if file based.
const
StreamType
_type
=
APPEND
//!< [in] bitsfield enum type identifier
)
;
~
Stream
();
const
char
*
string_out
()
const
;
Stream
&
print
(
const
int
);
Stream
&
print
(
const
double
);
Stream
&
print
(
const
char
*
const
,
bool
fork
=
true
);
Stream
&
print
(
const
char
);
Stream
&
print
(
const
Command
&
);
//! Get the currently active Stream
static
Stream
&
get_global
(
int
_warn
=
0
);
private:
// inhibit copy
Stream
(
const
Stream
&
);
Stream
&
operator
=
(
const
Stream
&
);
};
Stream
&
operator
<<
(
Stream
&
_ds
,
const
int
i
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
double
d
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
size_t
i
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
unsigned
int
i
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
float
d
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
char
c
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
char
*
const
s
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
string
&
s
);
Stream
&
operator
<<
(
Stream
&
_ds
,
const
Command
&
co
);
// Stream operator for std::vector<>
template
<
typename
ElementT
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
vector
<
ElementT
>&
_vec
)
{
_ds
<<
"[ "
;
for
(
typename
std
::
vector
<
ElementT
>::
const_iterator
el_it
=
_vec
.
begin
();
el_it
!=
_vec
.
end
();
++
el_it
)
_ds
<<
*
el_it
<<
" "
;
_ds
<<
"]"
;
return
_ds
;
}
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
// Stream operator for std::array<>
template
<
typename
ElementT
,
size_t
_el_nmbr
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
array
<
ElementT
,
_el_nmbr
>&
_vec
)
{
_ds
<<
"[ "
;
for
(
const
auto
el
:
_vec
)
_ds
<<
el
<<
" "
;
_ds
<<
"]"
;
return
_ds
;
}
#endif
// Stream operator for fixed size arrays
template
<
typename
ElementT
,
size_t
_el_nmbr
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
ElementT
(
&
_arr
)[
_el_nmbr
])
{
_ds
<<
"[ "
;
for
(
unsigned
int
i
=
0
;
i
<
_el_nmbr
;
++
i
)
_ds
<<
_arr
[
i
]
<<
" "
;
_ds
<<
"]"
;
return
_ds
;
}
// Stream std::pair<>
template
<
typename
T0
,
typename
T1
>
Stream
&
operator
<<
(
Stream
&
_ds
,
const
std
::
pair
<
T0
,
T1
>&
_pair
)
{
_ds
<<
"("
<<
_pair
.
first
<<
", "
<<
_pair
.
second
<<
")"
;
return
_ds
;
}
#define DEB_module(MODULE)
//TODO: This should use an atomic thread-safe static int(s)
#define DEB_enter_func static int deb_nmbr = 0; \
static
int
deb_lvl
=
Debug
::
INVALID_LEVEL
;
\
Debug
::
Enter
deb
(
__FILE__
,
__FUNCTION__
,
deb_nmbr
,
deb_lvl
);
#define DEB_only(CC) CC
#define DEB_exec(LL, AA) DEB_exec_if(true, LL, AA)
#define DEB_exec_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) { AA; } }
#define DEB_out(LL, AA) DEB_out_if(true, LL, AA)
#define DEB_out_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{
deb
.
stream
()
<<
AA
<<
deb
.
end
();
}
}
#define DEB_line(LL, AA) DEB_line_if(true, LL, AA)
#define DEB_line_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{
deb
.
stream
()
<<
AA
<<
deb
.
end_lf
();
}
}
#define DEB_warning(LL, AA) DEB_warning_if(true, LL, AA)
#define DEB_warning_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{
deb
.
stream
(
1
)
<<
"WARNING: "
<<
AA
<<
deb
.
end_lf
();
}
}
#define DEB_error(AA) { deb.stream(2) << "ERROR: " << AA << deb.end_err(); }
#define DEB_error_if(CC, AA) { if (CC) DEB_error(AA); }
// Stream does not fulfill ostream. If you want to exploit an existing
// ostream streamer to DEB_out a class as text without exploiting any
// numeric processing or custom Stream streamers then use this macro thus
// DEB_out(1, "my_class is " << DEB_os_str(my_c) )
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#define DEB_os_str(AA) \
dynamic_cast
<
std
::
ostringstream
&&>
((
std
::
ostringstream
()
<<
AA
)).
str
()
#else
template
<
typename
T
>
std
::
string
toString
(
const
T
&
t
)
{
std
::
ostringstream
ss
;
ss
<<
t
;
return
ss
.
str
();
}
#define DEB_os_str(AA) \
Debug
::
toString
(
AA
)
#endif
}
//namespace Debug
#endif // DEB_ON
#endif // BASE_DEBOUT_HH_INCLUDED
Debug/DebStream.cc
View file @
aeab4906
This diff is collapsed.
Click to expand it.
Debug/DebTime.hh
View file @
aeab4906
...
...
@@ -21,7 +21,7 @@ namespace Debug {
class
StopWatchSession
{
public:
StopWatchSession
(
Enter
&
_deb
,
const
char
*
_sssn_name
=
nullptr
,
StopWatchSession
(
Enter
&
_deb
,
const
char
*
_sssn_name
=
NULL
,
const
int
_deb_lvl
=
2
)
:
deb
(
_deb
),
sssn_name_
(
_sssn_name
),
deb_lvl_
(
_deb_lvl
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment