From bd54c8c3553fd4cf72be496cbde8b8365d088f4e Mon Sep 17 00:00:00 2001 From: Enrico Bertolazzi Date: Tue, 27 Dec 2022 22:49:37 +0100 Subject: [PATCH] merged with develop --- Clothoids.prj | 8 +- toolbox/src/ClothoidG2.cc | 12 +- toolbox/src/Console.cc | 103 +++++++++------ toolbox/src/Utils/Console.hxx | 181 +++++++++++++++++++++------ toolbox/src/Utils/Table.hxx | 8 +- toolbox/src/Utils/ThreadPool0.hxx | 2 +- toolbox/src/Utils/ThreadPool2.hxx | 2 +- toolbox/src/Utils/ThreadPoolBase.hxx | 6 +- toolbox/src/Utils/ThreadUtils.hxx | 4 +- toolbox/src/Utils/TicToc.hxx | 2 +- toolbox/src/Utils/Utils.hxx | 6 + toolbox/src/Utils/quickpool.hxx | 2 +- toolbox/src/Utils_AABB_tree.hh | 2 +- toolbox/src/Utils_Algo748.hh | 4 +- toolbox/src/Utils_GG2D.hh | 8 +- toolbox/src/Utils_Trichotomy.cc | 32 ++++- toolbox/src/Utils_Trichotomy.hh | 11 +- 17 files changed, 282 insertions(+), 111 deletions(-) diff --git a/Clothoids.prj b/Clothoids.prj index 1da34b15..32a5bab9 100644 --- a/Clothoids.prj +++ b/Clothoids.prj @@ -7,7 +7,7 @@ Clothoids, a library for clothoids computation and more A library for clothoids computation and more. ${PROJECT_ROOT}/toolbox/logo.png - 2.0.11 + 2.0.12 ${PROJECT_ROOT}/Clothoids.mltbx @@ -98,8 +98,10 @@ setup.m ${PROJECT_ROOT}/toolbox - ${PROJECT_ROOT}/toolbox/CompileClothoidsLib.m + ${PROJECT_ROOT}/toolbox/CMakeLists.txt ${PROJECT_ROOT}/toolbox/bin + ${PROJECT_ROOT}/toolbox/build + ${PROJECT_ROOT}/toolbox/cmake_utils ${PROJECT_ROOT}/toolbox/demos.xml ${PROJECT_ROOT}/toolbox/doc ${PROJECT_ROOT}/toolbox/helptoc.xml @@ -164,7 +166,7 @@ setup.m false false false - 12.2.1 + 13.1 false true maci64 diff --git a/toolbox/src/ClothoidG2.cc b/toolbox/src/ClothoidG2.cc index 6e60a9fc..5b7c90c9 100644 --- a/toolbox/src/ClothoidG2.cc +++ b/toolbox/src/ClothoidG2.cc @@ -943,7 +943,7 @@ namespace G2lib { if ( s < S0.length() ) return S0.theta(s); s -= S0.length(); if ( s < SM.length() ) return SM.theta(s); - s -= S0.length(); + s -= SM.length(); return S1.theta(s); } @@ -954,7 +954,7 @@ namespace G2lib { if ( s < S0.length() ) return S0.theta_D(s); s -= S0.length(); if ( s < SM.length() ) return SM.theta_D(s); - s -= S0.length(); + s -= SM.length(); return S1.theta_D(s); } @@ -965,7 +965,7 @@ namespace G2lib { if ( s < S0.length() ) return S0.theta_DD(s); s -= S0.length(); if ( s < SM.length() ) return SM.theta_DD(s); - s -= S0.length(); + s -= SM.length(); return S1.theta_DD(s); } @@ -976,7 +976,7 @@ namespace G2lib { if ( s < S0.length() ) return S0.theta_DDD(s); s -= S0.length(); if ( s < SM.length() ) return SM.theta_DDD(s); - s -= S0.length(); + s -= SM.length(); return S1.theta_DDD(s); } @@ -987,7 +987,7 @@ namespace G2lib { if ( s < S0.length() ) return S0.X(s); s -= S0.length(); if ( s < SM.length() ) return SM.X(s); - s -= S0.length(); + s -= SM.length(); return S1.X(s); } @@ -998,7 +998,7 @@ namespace G2lib { if ( s < S0.length() ) return S0.Y(s); s -= S0.length(); if ( s < SM.length() ) return SM.Y(s); - s -= S0.length(); + s -= SM.length(); return S1.Y(s); } diff --git a/toolbox/src/Console.cc b/toolbox/src/Console.cc index bb1b7641..d612cfa2 100644 --- a/toolbox/src/Console.cc +++ b/toolbox/src/Console.cc @@ -47,13 +47,8 @@ namespace Utils { m_level = new_level; } - void - Console::change_stream( ostream_type * new_p_stream ) { - m_stream = new_p_stream; - } - Console const & - Console::black( string const & msg, int msg_level ) const { + Console::black( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::black << msg << rang::fg::reset; @@ -61,7 +56,7 @@ namespace Utils { } Console const & - Console::red( string const & msg, int msg_level ) const { + Console::red( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::red << msg << rang::fg::reset; @@ -69,7 +64,7 @@ namespace Utils { } Console const & - Console::green( string const & msg, int msg_level ) const { + Console::green( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::green << msg << rang::fg::reset; @@ -77,7 +72,7 @@ namespace Utils { } Console const & - Console::yellow( string const & msg, int msg_level ) const { + Console::yellow( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::yellow << msg << rang::fg::reset; @@ -85,7 +80,7 @@ namespace Utils { } Console const & - Console::blue( string const & msg, int msg_level ) const { + Console::blue( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::blue << msg << rang::fg::reset; @@ -93,7 +88,7 @@ namespace Utils { } Console const & - Console::magenta( string const & msg, int msg_level ) const { + Console::magenta( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::magenta << msg << rang::fg::reset; @@ -101,7 +96,7 @@ namespace Utils { } Console const & - Console::cyan( string const & msg, int msg_level ) const { + Console::cyan( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::cyan << msg << rang::fg::reset; @@ -109,7 +104,7 @@ namespace Utils { } Console const & - Console::gray( string const & msg, int msg_level ) const { + Console::gray( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::gray << msg << rang::fg::reset; @@ -117,82 +112,90 @@ namespace Utils { } Console const & - Console::black_reversed( string const & msg, int msg_level ) const { + Console::black_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::black << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::red_reversed( string const & msg, int msg_level ) const { + Console::red_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::red << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::green_reversed( string const & msg, int msg_level ) const { + Console::green_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::green << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::yellow_reversed( string const & msg, int msg_level ) const { + Console::yellow_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::yellow << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::blue_reversed( string const & msg, int msg_level ) const { + Console::blue_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::blue << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::magenta_reversed( string const & msg, int msg_level ) const { + Console::magenta_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::magenta << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::cyan_reversed( string const & msg, int msg_level ) const { + Console::cyan_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::cyan << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } Console const & - Console::gray_reversed( string const & msg, int msg_level ) const { + Console::gray_reversed( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) << rang::fg::gray << rang::style::reversed - << msg << rang::style::reset << rang::fg::reset; + << msg + << rang::style::reset << rang::fg::reset; return *this; } @@ -219,13 +222,15 @@ namespace Utils { Console const & Console::semaphore( - unsigned rvg, - string const & msg, - int msg_level + unsigned rvg, + char const * msg, + int msg_level ) const { lock_guard lock_access(m_message_mutex); static rang::fg rvg_color[3] = { - rang::fg::red, rang::fg::yellow, rang::fg::green + rang::fg::red, + rang::fg::yellow, + rang::fg::green }; if ( msg_level <= m_level ) (*m_stream) @@ -238,7 +243,31 @@ namespace Utils { } Console const & - Console::message( string const & msg, int msg_level ) const { + Console::colors( + unsigned c, + char const * msg, + int msg_level + ) const { + lock_guard lock_access(m_message_mutex); + static rang::fg rvg_color[5] = { + rang::fg::red, + rang::fg::magenta, + rang::fg::yellow, + rang::fg::cyan, + rang::fg::green + }; + if ( msg_level <= m_level ) + (*m_stream) + << rang::style::reset + << rang::bg::reset + << rvg_color[c%5] + << msg + << rang::fg::reset; + return *this; + } + + Console const & + Console::message( char const * msg, int msg_level ) const { lock_guard lock_access(m_message_mutex); if ( msg_level <= m_level ) (*m_stream) @@ -253,7 +282,7 @@ namespace Utils { } Console const & - Console::warning( string const & msg ) const { + Console::warning( char const * msg ) const { lock_guard lock_access(m_message_mutex); if ( m_level >= 2 ) (*m_stream) @@ -268,7 +297,7 @@ namespace Utils { } Console const & - Console::error( string const & msg ) const { + Console::error( char const * msg ) const { lock_guard lock_access(m_message_mutex); if ( m_level >= 1 ) (*m_stream) @@ -283,7 +312,7 @@ namespace Utils { } Console const & - Console::fatal( string const & msg ) const { + Console::fatal( char const * msg ) const { lock_guard lock_access(m_message_mutex); (*m_stream) << m_fatal_style.s diff --git a/toolbox/src/Utils/Console.hxx b/toolbox/src/Utils/Console.hxx index ab737f17..da2e52b7 100644 --- a/toolbox/src/Utils/Console.hxx +++ b/toolbox/src/Utils/Console.hxx @@ -25,8 +25,9 @@ namespace Utils { using istream_type = std::basic_istream; using ostream_type = std::basic_ostream; + using string = std::string; - std::string basename( char const * filename ); + string basename( char const * filename ); class Console { @@ -65,104 +66,206 @@ namespace Utils { Console( ostream_type * stream = &std::cout, int level = 4 ); void change_level( int new_level ); - void change_stream( ostream_type * new_stream ); + void changeLevel( int new_level ) { this->change_level(new_level); } + + void change_stream( ostream_type * new_stream ) { m_stream = new_stream; } + void changeStream ( ostream_type * new_stream ) { m_stream = new_stream; } + int get_level() const { return m_level; } + int getLevel() const { return m_level; } ostream_type * get_stream() const { return m_stream; } + ostream_type * getStream() const { return m_stream; } - void changeLevel( int new_level ) { this->change_level(new_level); } - void changeStream( ostream_type * new_stream ) { this->change_stream( new_stream ); } - int getLevel() const { return m_level; } + Console const & flush() const { m_stream->flush(); return *this; } - ostream_type * getStream() const { return m_stream; } + Console const & message ( char const * msg, int msg_level = 4 ) const; + Console const & semaphore( unsigned ryg, char const * msg, int msg_level = 0 ) const; + Console const & colors ( unsigned c, char const * msg, int msg_level = 0 ) const; + Console const & warning ( char const * msg ) const; // level >= 2 + Console const & error ( char const * msg ) const; // level >= 1 + Console const & fatal ( char const * msg ) const; // level >= 0 + + Console const & black ( char const * msg, int msg_level = 0 ) const; + Console const & red ( char const * msg, int msg_level = 0 ) const; + Console const & green ( char const * msg, int msg_level = 0 ) const; + Console const & yellow ( char const * msg, int msg_level = 0 ) const; + Console const & blue ( char const * msg, int msg_level = 0 ) const; + Console const & magenta ( char const * msg, int msg_level = 0 ) const; + Console const & cyan ( char const * msg, int msg_level = 0 ) const; + Console const & gray ( char const * msg, int msg_level = 0 ) const; + + Console const & black_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & red_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & green_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & yellow_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & blue_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & magenta_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & cyan_reversed ( char const * msg, int msg_level = 0 ) const; + Console const & gray_reversed ( char const * msg, int msg_level = 0 ) const; - Console const & flush() const { m_stream->flush(); return *this; } + Console const & + message( string const & msg, int msg_level = 4 ) const + { return this->message( msg.c_str(), msg_level); } Console const & - message( std::string const & msg, int msg_level = 4 ) const; + semaphore( unsigned ryg, string const & msg, int msg_level = 0 ) const + { return this->semaphore( ryg, msg.c_str(), msg_level); } Console const & - semaphore( unsigned ryg, std::string const & msg, int msg_level = 0 ) const; + colors( unsigned c, string const & msg, int msg_level = 0 ) const + { return this->colors( c, msg.c_str(), msg_level); } Console const & - warning( std::string const & msg ) const; // level >= 2 + warning( string const & msg ) const // level >= 2 + { return this->warning( msg.c_str() ); } Console const & - error( std::string const & msg ) const; // level >= 1 + error( string const & msg ) const // level >= 1 + { return this->error( msg.c_str() ); } Console const & - fatal( std::string const & msg ) const; // level >= 0 + fatal( string const & msg ) const // level >= 0 + { return this->fatal( msg.c_str() ); } - Console const & black ( std::string const & msg, int msg_level = 0 ) const; - Console const & red ( std::string const & msg, int msg_level = 0 ) const; - Console const & green ( std::string const & msg, int msg_level = 0 ) const; - Console const & yellow ( std::string const & msg, int msg_level = 0 ) const; - Console const & blue ( std::string const & msg, int msg_level = 0 ) const; - Console const & magenta ( std::string const & msg, int msg_level = 0 ) const; - Console const & cyan ( std::string const & msg, int msg_level = 0 ) const; - Console const & gray ( std::string const & msg, int msg_level = 0 ) const; + Console const & + black( string const & msg, int msg_level = 0 ) const + { return this->black( msg.c_str(), msg_level ); } + + Console const & + red( string const & msg, int msg_level = 0 ) const + { return this->red( msg.c_str(), msg_level ); } - Console const & black_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & red_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & green_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & yellow_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & blue_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & magenta_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & cyan_reversed ( std::string const & msg, int msg_level = 0 ) const; - Console const & gray_reversed ( std::string const & msg, int msg_level = 0 ) const; + Console const & + green( string const & msg, int msg_level = 0 ) const + { return this->green( msg.c_str(), msg_level ); } + + Console const & + yellow( string const & msg, int msg_level = 0 ) const + { return this->yellow( msg.c_str(), msg_level ); } + + Console const & + blue( string const & msg, int msg_level = 0 ) const + { return this->blue( msg.c_str(), msg_level ); } + + Console const & + magenta( string const & msg, int msg_level = 0 ) const + { return this->magenta( msg.c_str(), msg_level ); } + + Console const & + cyan( string const & msg, int msg_level = 0 ) const + { return this->cyan( msg.c_str(), msg_level ); } + + Console const & + gray( string const & msg, int msg_level = 0 ) const + { return this->gray( msg.c_str(), msg_level ); } + + Console const & + black_reversed( string const & msg, int msg_level = 0 ) const + { return this->black_reversed( msg.c_str(), msg_level ); } + + Console const & + red_reversed( string const & msg, int msg_level = 0 ) const + { return this->red_reversed( msg.c_str(), msg_level ); } + + Console const & + green_reversed( string const & msg, int msg_level = 0 ) const + { return this->green_reversed( msg.c_str(), msg_level ); } + + Console const & + yellow_reversed( string const & msg, int msg_level = 0 ) const + { return this->yellow_reversed( msg.c_str(), msg_level ); } + + Console const & + blue_reversed( string const & msg, int msg_level = 0 ) const + { return this->blue_reversed( msg.c_str(), msg_level ); } + + Console const & + magenta_reversed( string const & msg, int msg_level = 0 ) const + { return this->magenta_reversed( msg.c_str(), msg_level ); } + + Console const & + cyan_reversed( string const & msg, int msg_level = 0 ) const + { return this->cyan_reversed( msg.c_str(), msg_level ); } + + Console const & + gray_reversed( string const & msg, int msg_level = 0 ) const + { return this->gray_reversed( msg.c_str(), msg_level ); } void set_message_style( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { m_message_style.s = s; m_message_style.f = f; m_message_style.b = b; } void setMessageStyle( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { this->set_message_style( s, f, b ); } void set_warning_style( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { - m_warning_style.s = s; m_warning_style.f = f; m_warning_style.b = b; + m_warning_style.s = s; + m_warning_style.f = f; + m_warning_style.b = b; } void setWarningStyle( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { this->set_warning_style( s, f, b ); } void set_error_style( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { - m_error_style.s = s; m_error_style.f = f; m_error_style.b = b; + m_error_style.s = s; + m_error_style.f = f; + m_error_style.b = b; } void setErrorStyle( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { this->set_error_style( s, f, b ); } void set_fatal_style( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { - m_fatal_style.s = s; m_fatal_style.f = f; m_fatal_style.b = b; + m_fatal_style.s = s; + m_fatal_style.f = f; + m_fatal_style.b = b; } void setFatalStyle( - rang::style const & s, rang::fg const & f, rang::bg const & b + rang::style const & s, + rang::fg const & f, + rang::bg const & b ) { this->set_fatal_style( s, f, b ); } diff --git a/toolbox/src/Utils/Table.hxx b/toolbox/src/Utils/Table.hxx index 30c1f8b2..32cb3eac 100644 --- a/toolbox/src/Utils/Table.hxx +++ b/toolbox/src/Utils/Table.hxx @@ -89,7 +89,7 @@ namespace Utils { public: - Style() = default; + Style() UTILS_DEFAULT; char border_top() const { return m_border_top; } void border_top( char borderStyle ) { m_border_top = borderStyle; } @@ -159,7 +159,7 @@ namespace Utils { public: - Cell() = default; + Cell() UTILS_DEFAULT; explicit Cell( @@ -198,7 +198,7 @@ namespace Utils { public: - Row() = default; + Row() UTILS_DEFAULT; explicit Row( @@ -242,7 +242,7 @@ namespace Utils { public: - Table() = default; + Table() UTILS_DEFAULT; explicit Table( diff --git a/toolbox/src/Utils/ThreadPool0.hxx b/toolbox/src/Utils/ThreadPool0.hxx index bceb7fa4..ace1357e 100644 --- a/toolbox/src/Utils/ThreadPool0.hxx +++ b/toolbox/src/Utils/ThreadPool0.hxx @@ -46,7 +46,7 @@ namespace Utils { : ThreadPoolBase() {} - virtual ~ThreadPool0() = default; + virtual ~ThreadPool0() UTILS_DEFAULT; void exec( Func && fun ) override { fun(); } void wait() override { } diff --git a/toolbox/src/Utils/ThreadPool2.hxx b/toolbox/src/Utils/ThreadPool2.hxx index c40f7481..51d1e9ce 100644 --- a/toolbox/src/Utils/ThreadPool2.hxx +++ b/toolbox/src/Utils/ThreadPool2.hxx @@ -238,7 +238,7 @@ namespace Utils { /** * Destroy the task object */ - virtual ~VirtualTask() = default; + virtual ~VirtualTask() UTILS_DEFAULT; }; /** diff --git a/toolbox/src/Utils/ThreadPoolBase.hxx b/toolbox/src/Utils/ThreadPoolBase.hxx index dada414b..5e0a5fce 100644 --- a/toolbox/src/Utils/ThreadPoolBase.hxx +++ b/toolbox/src/Utils/ThreadPoolBase.hxx @@ -40,7 +40,7 @@ namespace Utils { ThreadPoolBase & operator = ( ThreadPoolBase const & ) = delete; ThreadPoolBase & operator = ( ThreadPoolBase && ) = delete; - ThreadPoolBase() = default; + ThreadPoolBase() UTILS_DEFAULT; virtual void @@ -163,7 +163,7 @@ namespace Utils { TaskData( std::function && f ) : m_fun(std::move(f)) { } TaskData( std::function & f ) : m_fun(f) { } void operator()() { m_fun(); delete this; } - ~TaskData() = default; + ~TaskData() UTILS_DEFAULT; }; private: @@ -217,7 +217,7 @@ namespace Utils { m_queue_data.resize( m_size ); } - ~Queue() = default; + ~Queue() UTILS_DEFAULT; }; } } diff --git a/toolbox/src/Utils/ThreadUtils.hxx b/toolbox/src/Utils/ThreadUtils.hxx index efa9015a..4671f06e 100644 --- a/toolbox/src/Utils/ThreadUtils.hxx +++ b/toolbox/src/Utils/ThreadUtils.hxx @@ -214,7 +214,7 @@ namespace Utils { public: SpinLock() : m_lock(false) { } SpinLock( SpinLock const & ) = delete; - ~SpinLock() = default; + ~SpinLock() UTILS_DEFAULT; void wait() { @@ -478,7 +478,7 @@ namespace Utils { #ifdef UTILS_OS_WINDOWS WaitWorker() { n_worker = 0; } #else - WaitWorker() = default; + WaitWorker() UTILS_DEFAULT; #endif void diff --git a/toolbox/src/Utils/TicToc.hxx b/toolbox/src/Utils/TicToc.hxx index b01b0cac..22a2a9fa 100644 --- a/toolbox/src/Utils/TicToc.hxx +++ b/toolbox/src/Utils/TicToc.hxx @@ -118,7 +118,7 @@ namespace Utils { : m_elapsed_time(0) { this->tic(); } - ~TicToc() = default; + ~TicToc() UTILS_DEFAULT; //! //! Start timing diff --git a/toolbox/src/Utils/Utils.hxx b/toolbox/src/Utils/Utils.hxx index 38a4c8fb..c74f4dab 100644 --- a/toolbox/src/Utils/Utils.hxx +++ b/toolbox/src/Utils/Utils.hxx @@ -71,6 +71,12 @@ // check if compiler is C++11 #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \ (defined(__cplusplus) && __cplusplus > 199711L) + + #if (defined(__cplusplus) && __cplusplus <= 201103L) + #define UTILS_DEFAULT {} + #else + #define UTILS_DEFAULT = default + #endif #else #error "Lapack Wrapper must be compiled using C++ >= C++11" #endif diff --git a/toolbox/src/Utils/quickpool.hxx b/toolbox/src/Utils/quickpool.hxx index ad79dc22..ca36c7ca 100644 --- a/toolbox/src/Utils/quickpool.hxx +++ b/toolbox/src/Utils/quickpool.hxx @@ -188,7 +188,7 @@ namespace quickpool { struct alignas(Align) atomic : public std::atomic, private padding_impl::padding { public: - atomic() noexcept = default; + atomic() noexcept UTILS_DEFAULT; atomic(T desired) noexcept : std::atomic(desired) {} // Assignment operators have been deleted, must redefine. diff --git a/toolbox/src/Utils_AABB_tree.hh b/toolbox/src/Utils_AABB_tree.hh index 6b1104f8..02f4f5fc 100644 --- a/toolbox/src/Utils_AABB_tree.hh +++ b/toolbox/src/Utils_AABB_tree.hh @@ -117,7 +117,7 @@ namespace Utils { public: - AABBtree() = default; + AABBtree() UTILS_DEFAULT; AABBtree( AABBtree const & t ); diff --git a/toolbox/src/Utils_Algo748.hh b/toolbox/src/Utils_Algo748.hh index 05ffb367..49218ff0 100755 --- a/toolbox/src/Utils_Algo748.hh +++ b/toolbox/src/Utils_Algo748.hh @@ -111,8 +111,8 @@ namespace Utils { public: - Algo748() = default; - ~Algo748() = default; + Algo748() UTILS_DEFAULT; + ~Algo748() UTILS_DEFAULT; Real eval( Real a, Real b, Algo748_base_fun * fun ) { diff --git a/toolbox/src/Utils_GG2D.hh b/toolbox/src/Utils_GG2D.hh index c265c86b..302f93e8 100644 --- a/toolbox/src/Utils_GG2D.hh +++ b/toolbox/src/Utils_GG2D.hh @@ -41,8 +41,8 @@ namespace Utils { class Point2D : public Eigen::Matrix { using P2D = Eigen::Matrix; public: - Point2D() = default; - //~Point2D() = default; + Point2D() UTILS_DEFAULT; + //~Point2D() UTILS_DEFAULT; //Point2D & //operator = ( Point2D const & RHS ) { @@ -73,8 +73,8 @@ namespace Utils { Point2D m_Pb; public: - Segment2D() = default; - //~Segment2D() = default; + Segment2D() UTILS_DEFAULT; + //~Segment2D() UTILS_DEFAULT; Segment2D( Segment2D const & S ) : m_Pa(S.m_Pa) diff --git a/toolbox/src/Utils_Trichotomy.cc b/toolbox/src/Utils_Trichotomy.cc index 31e822fd..c8f84a49 100755 --- a/toolbox/src/Utils_Trichotomy.cc +++ b/toolbox/src/Utils_Trichotomy.cc @@ -33,6 +33,34 @@ namespace Utils { using std::isfinite; + // ================================================================= + // set_max_iterations + // ================================================================= + + template + void + Trichotomy::set_max_iterations( Integer mit ) { + UTILS_ASSERT( + mit > 0, + "Trichotomy::set_max_iterations({}) argument must be >0\n", mit + ); + m_max_iteration = mit; + } + + // ================================================================= + // set_max_fun_evaluation + // ================================================================= + + template + void + Trichotomy::set_max_fun_evaluation( Integer mfev ) { + UTILS_ASSERT( + mfev > 0, + "Trichotomy::set_max_fun_evaluation({}) argument must be >0\n", mfev + ); + m_max_fun_evaluation = mfev; + } + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -94,10 +122,10 @@ namespace Utils { Trichotomy::minimize() { m_num_iter_done = 0; m_converged = false; - while ( m_num_iter_done++ < m_max_iter ) { + while ( m_num_iter_done++ < m_max_iteration ) { m_converged = bracketing(); if ( m_converged ) break; - if ( m_num_fun_eval >= m_max_fun_eval ) break; + if ( m_num_fun_eval >= m_max_fun_evaluation ) break; } return m_x3; } diff --git a/toolbox/src/Utils_Trichotomy.hh b/toolbox/src/Utils_Trichotomy.hh index 7bf51be0..ff06c251 100755 --- a/toolbox/src/Utils_Trichotomy.hh +++ b/toolbox/src/Utils_Trichotomy.hh @@ -70,8 +70,8 @@ namespace Utils { Integer m_num_iter_done{0}; Integer m_num_fun_eval{0}; - Integer m_max_iter{100}; - Integer m_max_fun_eval{1000}; + Integer m_max_iteration{100}; + Integer m_max_fun_evaluation{1000}; Real m_tolerance{pow(machine_eps(),Real(2./3.))}; bool m_converged{false}; @@ -95,8 +95,8 @@ namespace Utils { public: - Trichotomy() = default; - ~Trichotomy() = default; + Trichotomy() UTILS_DEFAULT; + ~Trichotomy() UTILS_DEFAULT; Real eval( Real a, Real b, Trichotomy_base_fun * fun ) { @@ -131,6 +131,9 @@ namespace Utils { Real tolerance() const { return m_tolerance; } bool converged() const { return m_converged; } + void set_max_iterations( Integer mit ); + void set_max_fun_evaluation( Integer mfev ); + }; #ifndef UTILS_OS_WINDOWS