Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
debfc7cb
Commit
debfc7cb
authored
Aug 14, 2021
by
LEFEBVREJP email
Browse files
Merge branch 'master' into 'ranged-for'
# Conflicts: # radixcore/tests/CMakeLists.txt
parents
427beebe
c9281d89
Pipeline
#159206
passed with stages
in 20 minutes and 40 seconds
Changes
54
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
radixalgorithm/chaikins.hh
View file @
debfc7cb
...
...
@@ -10,7 +10,7 @@
#include <ostream>
#include <vector>
#include "radix
bug
/bug.hh"
#include "radix
core
/bug.hh"
namespace
radix
{
...
...
radixalgorithm/chaikins.i.hh
View file @
debfc7cb
...
...
@@ -4,7 +4,7 @@
#include <vector>
#include "radixalgorithm/chaikins.hh"
#include "radix
bug
/bug.hh"
#include "radix
core
/bug.hh"
namespace
radix
{
...
...
radixalgorithm/marchingsquares.hh
View file @
debfc7cb
...
...
@@ -9,7 +9,7 @@
#include <ostream>
#include <vector>
#include "radix
bug
/bug.hh"
#include "radix
core
/bug.hh"
namespace
radix
{
...
...
radixalgorithm/marchingsquares.i.hh
View file @
debfc7cb
...
...
@@ -4,7 +4,7 @@
#include "radixalgorithm/marchingsquares.hh"
#include "radixalgorithm/ordering.hh"
#include "radix
bug
/bug.hh"
#include "radix
core
/bug.hh"
namespace
radix
{
...
...
radixalgorithm/tests/tstChaikins.cc
View file @
debfc7cb
...
...
@@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "radixalgorithm/chaikins.hh"
#include "radix
bug
/bug.hh"
#include "radix
core
/bug.hh"
using
namespace
radix
;
TEST
(
RadixChaikins
,
Simple
)
...
...
radixalgorithm/tests/tstMarchingSquares.cc
View file @
debfc7cb
...
...
@@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "radixalgorithm/marchingsquares.hh"
#include "radix
bug
/bug.hh"
#include "radix
core
/bug.hh"
#include "radixcore/stringfunctions.hh"
#include "radixcore/system.hh"
...
...
radixams/main.cc
View file @
debfc7cb
#include "radixmath/util.hh"
#include "radixco
mmand
/commandline.hh"
#include "radixco
re
/commandline.hh"
#include <cstdlib>
#include <iomanip>
...
...
radixbug/bug.hh
View file @
debfc7cb
#ifndef RADIX_RADIXCORE_BUG_HH_
#define RADIX_RADIXCORE_BUG_HH_
// default to c++ compiler
/*
* @file: bug.hh
* @author: Jordan P. Lefebvre, lefebvrejp@ornl.gov
* @brief Debug functionality for including debug output \
* in your source without a performance penalty.
* This is an include ONLY package. There is no library to link against
* Each function is preprocessed to be included or not.
* If DEBUG_OUTPUT is defined the MACROs are included.
*
* Available MACROs:
* radix(arg) - std::cerr << arg - Pushes content to stderr
* radix_line(arg) - std::cerr << arg << std::endl - Push newline terminated
* content to stderr
* radix_eol() - std::cerr << std::endl - Push newline to stderr
* radix(arg) - std::cerr << arg - Pushes content to stderr
* radix_warning(arg) - std::cerr << arg << std::endl - Push newline terminated
* content to stderr
* radix_tagged_line(arg) - Same as radixLine, prefixed with
* FILE and LINE
* radix_tagged(arg) - Same as radix, prefixed with FILE and LINE
* radix_tagged_warning(arg) - Same as radixWarning, prefixed with FILE and Line
* radix_block(block) - block - Simply places code block in preprocessor
*/
#include <cstdio>
#include <iostream>
#if RADIX_DEBUG_OUTPUT
#ifndef radix_stream
#define radix_stream std::cerr
#endif
#define radix_define_stream
#define radix_line(arg) radix_stream << arg << std::endl
#define radix_eol() radix_stream << std::endl
#define radix_flush_line(arg) \
radix_stream << arg << std::endl; \
fflush(stderr)
#define radix(arg) radix_stream << arg
#define radix_warning(arg) radix_stream << arg << std::endl
#define radix_tagged_warning(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl
#define radix_flush_warning(arg) \
radix_stream << arg << std::endl; \
fflush(stderr)
#define radix_tagged_line(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl
#define radix_flush_tagged_line(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl; \
fflush(stderr)
#define radix_tagged(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg
#define radix_flush_tagged_warning(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl; \
fflush(stderr)
#define radix_tagged_block(block) \
radix_stream << __FILE__ << ":" << __LINE__ << ":" << std::endl; \
block
#define radix_block(block) block
#else
#define radix(arg)
#define radix_line(arg)
#define radix_eol()
#define radix_flush_line(arg)
#define radix_warning(arg)
#define radix_flush_warning(arg)
#define radix_tagged_line(arg)
#define radix_flush_tagged_line(arg)
#define radix_tagged(arg)
#define radix_tagged_warning(arg)
#define radix_flush_tagged_warning(arg)
#define radix_tagged_block(block)
#define radix_block(block)
#endif
/* RADIX_DEBUG_OUTPUT */
#include <sstream>
#include <stdexcept>
#ifndef RADIX_DBC
#define RADIX_DBC 0
#endif
//
// Defined all levels of RADIX_DBC
// RADIX_DBC = 1 enables Require
// RADIX_DBC = 2 enables Check
// RADIX_DBC = 4 enables Remember & Ensure
// RADIX_DBC = 7 enables all
// Insist is always enabled
#if RADIX_DBC & 1
#define radix_require(c) \
do \
{ \
if (!(c)) \
{ \
std::ostringstream stream; \
stream << __FILE__ << ":" << __LINE__ << " radix_require(" << #c \
<< ") failed." << std::endl; \
throw std::runtime_error(stream.str()); \
} \
} while (false)
#else
#define radix_require(c)
#endif
#if RADIX_DBC & 2
#define radix_check(c) \
do \
{ \
if (!(c)) \
{ \
std::ostringstream stream; \
stream << __FILE__ << ":" << __LINE__ << " radix_check(" << #c \
<< ") failed." << std::endl; \
throw std::runtime_error(stream.str()); \
} \
} while (false)
#else
#define radix_check(c)
#endif
#if RADIX_DBC & 4
#define radix_ensure(c) \
do \
{ \
if (!(c)) \
{ \
std::ostringstream stream; \
stream << __FILE__ << ":" << __LINE__ << " radix_ensure(" << #c \
<< ") failed." << std::endl; \
throw std::runtime_error(stream.str()); \
} \
} while (false)
#define radix_remember(c) c
#else
#define radix_ensure(c)
#define radix_remember(c)
#endif
#define radix_insist(c, msg) \
do \
{ \
if (!(c)) \
{ \
std::ostringstream stream; \
stream << __FILE__ << ":" << __LINE__ << "radix_insist(" << #c \
<< ") failed with this message:" << std::endl \
<< msg << std::endl; \
throw std::runtime_error(stream.str()); \
} \
} while (false)
#define radix_not_implemented(msg) \
do \
{ \
std::ostringstream stream; \
stream << __FILE__ << ":" << __LINE__ << " : " << msg \
<< " is not implemented. " << std::endl; \
throw std::runtime_error(stream.str()); \
} while (false)
#define radix_not_reachable() \
do \
{ \
std::ostringstream stream; \
stream << "Execution encountered unreachable code point at " << __FILE__ \
<< ":" << __LINE__ << std::endl; \
throw std::runtime_error(stream.str()); \
} while (false)
/// set default timing to off
#ifndef RADIX_TIMING
#define RADIX_TIMING 0
#endif
#include <chrono>
#include <ctime>
namespace
radix
{
/**
* @brief Timer implementation for recording duration between start and stop
* points.
*
*/
class
Timer
{
private:
bool
mRunning
;
std
::
chrono
::
steady_clock
::
time_point
mStart
;
std
::
chrono
::
steady_clock
::
time_point
mEnd
;
std
::
chrono
::
nanoseconds
mDuration
;
size_t
mIntervals
;
public:
Timer
()
:
mRunning
(
false
)
,
mDuration
(
0
)
,
mIntervals
(
0
)
{
}
/**
* @brief Mark the start time for this timer
*
*/
void
start
()
{
radix_check
(
!
mRunning
);
mRunning
=
true
;
mIntervals
++
;
mStart
=
std
::
chrono
::
steady_clock
::
now
();
}
/**
* @brief Mark the stop time and record duration of time.
*
*/
void
stop
()
{
radix_check
(
mRunning
);
mEnd
=
std
::
chrono
::
steady_clock
::
now
();
mRunning
=
false
;
mDuration
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
mEnd
-
mStart
);
}
/**
* @brief Returns duration this timer ran in nanoseconds
*
* @return std::chrono::nanoseconds::rep
*/
std
::
chrono
::
nanoseconds
::
rep
duration
()
const
{
radix_check
(
!
mRunning
);
return
mDuration
.
count
();
}
/**
* @brief Returns the number times this timer was started and subsequently
* stopped.
*
* @return size_t
*/
size_t
intervals
()
const
{
return
mIntervals
;
}
/**
* @brief Returns the duration this timer ran in wall clock seconds.
* Does not account for intervals
* @return double durantion in seconds
*/
double
wall_clock
()
{
radix_require
(
!
mRunning
);
// 1e9 nanoseconds in a second
using
seconds
=
std
::
chrono
::
duration
<
double
,
std
::
ratio
<
1000
,
1
>>
;
return
seconds
(
mEnd
-
mStart
).
count
();
}
/**
* @brief Returns the duration this timer ran accounting for start/stop
* intervals
*
* @return double duration in seconds
*/
double
sum_wall_clock
()
{
// 1e9 nanoseconds in a second
using
seconds
=
std
::
chrono
::
duration
<
double
,
std
::
ratio
<
1000
,
1
>>
;
return
seconds
(
mDuration
).
count
();
}
/**
* @brief Returns whether this timer is currently counting.
*
* @return true The timer is running.
* @return false The timer is not running.
*/
bool
running
()
const
{
return
mRunning
;
};
};
// class Timer
}
// namespace radix
#if RADIX_TIMING > 0
#define radix_timer(name) radix::Timer name
#define radix_timer_start(name) name.start()
#define radix_timer_stop(name) name.stop()
#define radix_timer_block(content) content
#else
#define radix_timer(name)
#define radix_timer_start(name)
#define radix_timer_stop(name)
#define radix_timer_block(content)
#endif
#if RADIX_TIMING > 1
#define radix_timer_2(name) radix::Timer name
#define radix_timer_start_2(name) name.start()
#define radix_timer_stop_2(name) name.stop()
#define radix_timer_block_2(content) content
#else
#define radix_timer_2(name)
#define radix_timer_start_2(name)
#define radix_timer_stop_2(name)
#define radix_timer_block_2(content)
#endif
#if RADIX_TIMING > 2
#define radix_timer_3(name) radix::Timer name
#define radix_timer_start_3(name) name.start()
#define radix_timer_stop_3(name) name.stop()
#define radix_timer_block_3(content) content
#else
#define radix_timer_3(name)
#define radix_timer_start_3(name)
#define radix_timer_stop_3(name)
#define radix_timer_block_3(content)
#endif
#endif
/* RADIX_RADIXCORE_BUG_HH_*/
#ifndef RADIX_RADIXBUG_BUG_HH_
#define RADIX_RADIXBUG_BUG_HH_
#if defined(__GNUC__)
#warning \
"#include \'radixbug/bug.hh\' is deprecated. Switch to #include \"radixcore/bug.hh\""
#elif defined(_MSC_VER)
#pragma message( \
"#include \'radixbug/bug.hh\' is deprecated. Switch to #include \"radixcore/bug.hh\"")
#endif
#include "../radixcore/bug.hh"
#endif
/* RADIX_RADIXBUG_BUG_HH_*/
radixcommand/CMakeLists.txt
View file @
debfc7cb
TRIBITS_SUBPACKAGE
(
command
)
SET
(
SOURCE
commandline.cc
)
SET
(
HEADERS
commandline.hh
commandline.i.hh
)
#
# Add library
TRIBITS_ADD_LIBRARY
(
radixcommand
SOURCES
${
SOURCE
}
NOINSTALLHEADERS
${
HEADERS
}
)
#
...
...
radixcommand/commandline.hh
View file @
debfc7cb
#ifndef RADIX_RADIXCOMMAND_COMMANDLINE_HH_
#define RADIX_RADIXCOMMAND_COMMANDLINE_HH_
#include <ostream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "radixcore/visibility.hh"
namespace
radix
{
class
RADIX_PUBLIC
CommandLine
{
public:
CommandLine
(
int
argc
,
char
**
argv
);
/**
* @brief addOption Adds official option to this commandline
* @param name key
* @param description description of option
* @param required whether it is required or not
*/
void
addOption
(
const
std
::
string
&
name
,
const
std
::
string
&
description
,
bool
required
=
false
);
// dumps all options to \code out
void
printParsedLine
(
std
::
ostream
&
out
)
const
;
// dumps the optional and required options to \code out
void
help
(
std
::
ostream
&
out
)
const
;
// does an option exist in this commandline
bool
exists
(
const
std
::
string
&
name
)
const
;
// does an option exist in this commandline
bool
existsNotEmpty
(
const
std
::
string
&
name
)
const
;
const
std
::
vector
<
std
::
string
>
&
arguments
()
const
;
void
setArguments
(
const
std
::
vector
<
std
::
string
>
&
args
);
std
::
string
executable
()
const
;
void
setExecutable
(
const
std
::
string
&
executable
);
void
declareArgument
(
const
std
::
string
&
id
,
const
std
::
string
&
description
=
std
::
string
());
/**
* @brief get retrieve option value as type \code return_type
* @param name key of command line option
* @return \code return_type
*/
template
<
typename
return_type
>
return_type
get
(
const
std
::
string
&
name
)
const
;
/**
* @brief get retrieve option value as type \code return_type
* @param name key of command line option
* @param defaultValue default return value in the event name was not provided
* @return \code return_type
*/
template
<
typename
return_type
>
return_type
get
(
const
std
::
string
&
name
,
return_type
defaultValue
)
const
;
/**
* @brief arg retrieve argument as type \code return_type
* @param i int index of argument [0,N)
* @return \code return_type
*/
template
<
typename
return_type
>
return_type
arg
(
size_t
i
)
const
;
/**
* @brief validate Checks for existince of required options
* @param errors list of errors
* @return success/failure
*/
bool
validate
(
std
::
vector
<
std
::
string
>
&
errors
)
const
;
/**
* @brief validate Checks for existince of required options
* @param std::ostream& stream for errors
* @return success/failure
*/
bool
validate
(
std
::
ostream
&
out
)
const
;
const
std
::
string
&
description
()
const
;
void
setDescription
(
const
std
::
string
&
description
);
private:
int
mArgc
;
char
**
mArgv
;
std
::
string
mDescription
;
std
::
string
mExecutable
;
std
::
vector
<
std
::
string
>
mArgs
;
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
mDeclArgs
;
std
::
unordered_map
<
std
::
string
,
std
::
tuple
<
std
::
string
,
std
::
string
,
bool
>>
mData
;
};
// class CommandLine
//
// Specialized get/arg method declarations
template
<
>
std
::
string
RADIX_PUBLIC
CommandLine
::
get
(
const
std
::
string
&
name
)
const
;
template
<
>
std
::
string
RADIX_PUBLIC
CommandLine
::
get
(
const
std
::
string
&
name
,
std
::
string
defaultValue
)
const
;
template
<
>
std
::
string
RADIX_PUBLIC
CommandLine
::
arg
(
size_t
i
)
const
;
}
// namespace radix
#include "radixcommand/commandline.i.hh"
#if defined(__GNUC__)
#warning \
"#include \'radixcommand/commandline.hh\' is deprecated. Switch to #include \"radixcore/commandline.hh\""
#elif defined(_MSC_VER)
#pragma message( \
"#include \'radixcommand/commandline.hh\' is deprecated. Switch to #include \"radixcore/commandline.hh\"")
#endif
#include "../radixcore/commandline.hh"
#endif
/** RADIX_RADIXCOMMAND_COMMANDLINE_HH_ */
radixcommand/tests/tstCommandLine.cc
View file @
debfc7cb
...
...
@@ -7,8 +7,8 @@
#include <iostream>
#include "gtest/gtest.h"
#include "radix
bug
/bug.hh"
#include "radixco
mmand
/commandline.hh"
#include "radix
core
/bug.hh"
#include "radixco
re
/commandline.hh"
using
namespace
std
;
using
namespace
radix
;
...
...
radixcore/CMakeLists.txt
View file @
debfc7cb
...
...
@@ -3,6 +3,8 @@ TRIBITS_SUBPACKAGE(core)
TRIBITS_CONFIGURE_FILE
(
visibility.hh
)
SET
(
HEADERS
commandline.hh
commandline.i.hh
fuzzy.hh
json.hh
system.hh
...
...
@@ -13,6 +15,7 @@ range.i.hh
value.hh
)
SET
(
SOURCES
commandline.cc
fuzzy.cc
system.cc
stringfunctions.cc
...
...
radixcore/bug.hh
0 → 100644
View file @
debfc7cb
#ifndef RADIX_RADIXCORE_BUG_HH_
#define RADIX_RADIXCORE_BUG_HH_
// default to c++ compiler
/*
* @file: bug.hh
* @author: Jordan P. Lefebvre, lefebvrejp@ornl.gov
* @brief Debug functionality for including debug output \
* in your source without a performance penalty.
* This is an include ONLY package. There is no library to link against
* Each function is preprocessed to be included or not.
* If DEBUG_OUTPUT is defined the MACROs are included.
*
* Available MACROs:
* radix(arg) - std::cerr << arg - Pushes content to stderr
* radix_line(arg) - std::cerr << arg << std::endl - Push newline terminated
* content to stderr
* radix_eol() - std::cerr << std::endl - Push newline to stderr
* radix(arg) - std::cerr << arg - Pushes content to stderr
* radix_warning(arg) - std::cerr << arg << std::endl - Push newline terminated
* content to stderr
* radix_tagged_line(arg) - Same as radixLine, prefixed with
* FILE and LINE
* radix_tagged(arg) - Same as radix, prefixed with FILE and LINE
* radix_tagged_warning(arg) - Same as radixWarning, prefixed with FILE and Line
* radix_block(block) - block - Simply places code block in preprocessor
*/
#include <cstdio>
#include <iostream>
#if RADIX_DEBUG_OUTPUT
#ifndef radix_stream
#define radix_stream std::cerr
#endif
#define radix_define_stream
#define radix_line(arg) radix_stream << arg << std::endl
#define radix_eol() radix_stream << std::endl
#define radix_flush_line(arg) \
radix_stream << arg << std::endl; \
fflush(stderr)
#define radix(arg) radix_stream << arg
#define radix_warning(arg) radix_stream << arg << std::endl
#define radix_tagged_warning(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl
#define radix_flush_warning(arg) \
radix_stream << arg << std::endl; \
fflush(stderr)
#define radix_tagged_line(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl
#define radix_flush_tagged_line(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl; \
fflush(stderr)
#define radix_tagged(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg
#define radix_flush_tagged_warning(arg) \
radix_stream << __FILE__ << ":" << __LINE__ << ": " << arg << std::endl; \
fflush(stderr)
#define radix_tagged_block(block) \
radix_stream << __FILE__ << ":" << __LINE__ << ":" << std::endl; \
block
#define radix_block(block) block
#else
#define radix(arg)
#define radix_line(arg)
#define radix_eol()
#define radix_flush_line(arg)
#define radix_warning(arg)
#define radix_flush_warning(arg)
#define radix_tagged_line(arg)
#define radix_flush_tagged_line(arg)
#define radix_tagged(arg)
#define radix_tagged_warning(arg)