Commit 7337c276 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

[Doc] Enhance documentation.

parent 51af4d5b
Pipeline #2460 passed with stage
in 11 minutes and 26 seconds
PREDEFINED = HPP_DEBUG HPP_ENABLE_BENCHMARK
......@@ -235,16 +235,28 @@ namespace hpp
# ifdef HPP_DEBUG
/// \addtogroup hpp_util_debugging
/// \{
/// \brief Enable \c statement when HPP_DEBUG is defined.
# define hppDebug(statement) \
do { \
using namespace ::hpp::debug; \
{ statement; } \
} while(0)
/// \brief Enable \c statement when HPP_DEBUG is defined.
# define hppDebugStatement(statement) \
statement
/// \}
/// \addtogroup hpp_util_logging Macros for logging
/// \{
/// \brief Write \c data to \c channel when HPP_DEBUG is defined.
/// \param channel one of \em error, \em warning, \em notice, \em info or \em benchmark.
/// \param data a statement that can be \c << to a \c std::stringstream.
# define hppDout(channel, data) \
do { \
using namespace hpp; \
......@@ -255,6 +267,9 @@ namespace hpp
__ss); \
} while (0)
/// \brief Write \c data to \c channel and exit the program.
/// \param channel one of \em error, \em warning, \em notice, \em info or \em benchmark.
/// \param data a statement that can be \c << to a \c std::stringstream.
# define hppDoutFatal(channel, data) \
do { \
using namespace hpp; \
......@@ -266,6 +281,8 @@ namespace hpp
::std::exit(EXIT_FAILURE); \
} while (1)
/// \}
# else
# define hppDebug(statement) \
......
......@@ -34,7 +34,11 @@
<a href="http://github.com/laas/hpp-util/issues">github ticketing
system</a>.
\defgroup macro_exception Preprocessor macros for std exceptions
\defgroup hpp_util_debugging Macros for debugging
\defgroup hpp_util_logging Macros for logging
\defgroup hpp_util_exceptions Macros for \c std::exception
It eases throwing exceptions built from string stream. You can use equivalently
\code
......
......@@ -70,7 +70,7 @@ namespace hpp
/// \endcond
} // end of namespace hpp.
/// \addtogroup macro_exception
/// \addtogroup hpp_util_exceptions
/// \{
/// \brief Throw an exception of type using MSG as a string stream
......
......@@ -88,6 +88,7 @@ namespace hpp
# define hppBenchmark(data)
# endif // HPP_ENABLE_BENCHMARK
/// \brief Computation of min, max and mean time from a set of measurements.
class HPP_UTIL_DLLAPI TimeCounter
{
public:
......@@ -124,16 +125,25 @@ namespace hpp
std::ostream& operator<< (std::ostream& os, const TimeCounter& tc);
# if HPP_ENABLE_BENCHMARK
# ifdef HPP_ENABLE_BENCHMARK
/// \addtogroup hpp_util_logging
/// \{
/// \brief Define a new TimeCounter
# define HPP_DEFINE_TIMECOUNTER(name) \
::hpp::debug::TimeCounter _##name##_timecounter_ (#name)
/// \brief Compute the time spent in the current scope.
# define HPP_SCOPE_TIMECOUNTER(name) \
::hpp::debug::TimeCounter::Scope _##name##_scopetimecounter_ \
(_##name##_timecounter_)
/// \brief Start a watch.
# define HPP_START_TIMECOUNTER(name) \
_##name##_timecounter_.start ()
/// \brief Stop a watch and save elapsed time.
# define HPP_STOP_TIMECOUNTER(name) \
_##name##_timecounter_.stop()
/// \brief Print last elapsed time to the logs.
# define HPP_DISPLAY_LAST_TIMECOUNTER(name) \
do { \
using namespace hpp; \
......@@ -144,6 +154,7 @@ namespace hpp
logging.benchmark.write (__FILE__, __LINE__, \
__PRETTY_FUNCTION__, __ss); \
} while (0)
/// \brief Print min, max and mean time of the time measurements.
# define HPP_DISPLAY_TIMECOUNTER(name) \
do { \
using namespace hpp; \
......@@ -153,10 +164,13 @@ namespace hpp
logging.benchmark.write (__FILE__, __LINE__, \
__PRETTY_FUNCTION__, __ss); \
} while (0)
/// \brief Reset a TimeCounter.
# define HPP_RESET_TIMECOUNTER(name) \
_##name##_timecounter_.reset();
/// \brief Stream (\c operator<<) to the output stream.
# define HPP_STREAM_TIMECOUNTER(os, name) \
os << _##name##_timecounter_
/// \}
# else // HPP_ENABLE_BENCHMARK
# define HPP_DEFINE_TIMECOUNTER(name) \
struct _##name##_EndWithSemiColon_{}
......
......@@ -138,7 +138,7 @@ namespace hpp
TimeCounter::time_duration TimeCounter::mean () const
{
return ( c_ > 0 ) ? t_ / c_ : time_duration (0,0,0,0);
return ( c_ > 0 ) ? t_ / (int)c_ : time_duration (0,0,0,0);
}
TimeCounter::time_duration TimeCounter::totalTime () const
......
Supports Markdown
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