Основная часть рефакторинга закончена

This commit is contained in:
Andrei Astafev 2020-04-22 20:59:39 +03:00
parent d6143953f6
commit f550594b85
33 changed files with 144 additions and 41 deletions

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include "config.hpp" #include "config.hpp"

View File

@ -5,8 +5,10 @@
#ifdef MYXLIB_BUILD_LIBRARIES #ifdef MYXLIB_BUILD_LIBRARIES
#undef MYXLIB_HEADER_ONLY #undef MYXLIB_HEADER_ONLY
#define MYXLIB_INLINE inline
#else #else
#define MYXLIB_HEADER_ONLY #define MYXLIB_HEADER_ONLY
#define MYXLIB_INLINE inline
#endif #endif
#ifdef MYXLIB_HEADER_ONLY #ifdef MYXLIB_HEADER_ONLY

View File

@ -1,7 +1,6 @@
#ifndef MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_ #ifndef MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_
#define MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_ #define MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_
#pragma once #pragma once
#include <type_traits> #include <type_traits>

View File

@ -22,14 +22,14 @@ namespace filesystem {
error "Class CurrentExecutable is supported only in Linux" error "Class CurrentExecutable is supported only in Linux"
#endif #endif
CurrentExecutable::CurrentExecutable() : MYXLIB_INLINE CurrentExecutable::CurrentExecutable() :
m_procFilePath( QStringLiteral( "/proc/self/exe" ) ) m_procFilePath( QStringLiteral( "/proc/self/exe" ) )
{ {
m_canonicalFilePath = m_procFilePath.canonicalFilePath(); m_canonicalFilePath = m_procFilePath.canonicalFilePath();
} }
const QFileInfo& CurrentExecutable::canonicalFilePath() const MYXLIB_INLINE const QFileInfo& CurrentExecutable::canonicalFilePath() const
{ {
return( m_canonicalFilePath ); return( m_canonicalFilePath );
} }

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/filesystem/current_executable-inl.hpp> #include <myx/filesystem/current_executable-inl.hpp>

View File

@ -19,9 +19,9 @@ namespace myx {
namespace filesystem { namespace filesystem {
Paths::Paths() = default; MYXLIB_INLINE Paths::Paths() = default;
Paths::HierarchyType Paths::getHierarchyType() MYXLIB_INLINE Paths::HierarchyType Paths::getHierarchyType()
{ {
QRegExp binUnityRegexp( "/s*bin/unity$" ); QRegExp binUnityRegexp( "/s*bin/unity$" );
QRegExp binRegexp( "/s*bin$" ); QRegExp binRegexp( "/s*bin$" );
@ -170,7 +170,7 @@ Paths::HierarchyType Paths::getHierarchyType()
} // Paths::getHierarchyType } // Paths::getHierarchyType
bool Paths::init( const QString& projectDir, const QString& configFileExtension ) MYXLIB_INLINE bool Paths::init( const QString& projectDir, const QString& configFileExtension )
{ {
m_projectName = projectDir.isEmpty() ? m_currentExecutable.m_canonicalFilePath.fileName() m_projectName = projectDir.isEmpty() ? m_currentExecutable.m_canonicalFilePath.fileName()
: projectDir; : projectDir;
@ -214,7 +214,7 @@ bool Paths::init( const QString& projectDir, const QString& configFileExtension
} // Paths::updatePaths } // Paths::updatePaths
bool Paths::makeDefaultDirectories() MYXLIB_INLINE bool Paths::makeDefaultDirectories()
{ {
bool status = true; bool status = true;
@ -226,7 +226,7 @@ bool Paths::makeDefaultDirectories()
} }
QString Paths::findConfigFile( const QString& defaultConfigFile ) MYXLIB_INLINE QString Paths::findConfigFile( const QString& defaultConfigFile )
{ {
if ( !defaultConfigFile.isEmpty() && QFileInfo( defaultConfigFile ).isReadable() ) if ( !defaultConfigFile.isEmpty() && QFileInfo( defaultConfigFile ).isReadable() )
{ {
@ -251,103 +251,103 @@ QString Paths::findConfigFile( const QString& defaultConfigFile )
} // Paths::findConfigFile } // Paths::findConfigFile
QDir Paths::executableFileDirectory() const MYXLIB_INLINE QDir Paths::executableFileDirectory() const
{ {
return( m_currentExecutable.m_canonicalFilePath.dir() ); return( m_currentExecutable.m_canonicalFilePath.dir() );
} }
const QDir& Paths::userConfigDirectory() const MYXLIB_INLINE const QDir& Paths::userConfigDirectory() const
{ {
return( m_userConfigDirectory ); return( m_userConfigDirectory );
} }
const QDir& Paths::systemConfigDirectory() const MYXLIB_INLINE const QDir& Paths::systemConfigDirectory() const
{ {
return( m_systemConfigDirectory ); return( m_systemConfigDirectory );
} }
const QFileInfo& Paths::configFilePath() const MYXLIB_INLINE const QFileInfo& Paths::configFilePath() const
{ {
return( m_configFilePath ); return( m_configFilePath );
} }
const QString& Paths::configFileName() const MYXLIB_INLINE const QString& Paths::configFileName() const
{ {
return( m_configFileName ); return( m_configFileName );
} }
const QString& Paths::configFileExtension() const MYXLIB_INLINE const QString& Paths::configFileExtension() const
{ {
return( m_configFileExtension ); return( m_configFileExtension );
} }
const QDir& Paths::userVarDataDirectory() const MYXLIB_INLINE const QDir& Paths::userVarDataDirectory() const
{ {
return( m_userVarDataDirectory ); return( m_userVarDataDirectory );
} }
const QDir& Paths::systemVarDataDirectory() const MYXLIB_INLINE const QDir& Paths::systemVarDataDirectory() const
{ {
return( m_systemVarDataDirectory ); return( m_systemVarDataDirectory );
} }
const QDir& Paths::userConstDataDirectory() const MYXLIB_INLINE const QDir& Paths::userConstDataDirectory() const
{ {
return( m_userConstDataDirectory ); return( m_userConstDataDirectory );
} }
const QDir& Paths::systemConstDataDirectory() const MYXLIB_INLINE const QDir& Paths::systemConstDataDirectory() const
{ {
return( m_systemConstDataDirectory ); return( m_systemConstDataDirectory );
} }
const QDir& Paths::userLogDirectory() const MYXLIB_INLINE const QDir& Paths::userLogDirectory() const
{ {
return( m_userLogDirectory ); return( m_userLogDirectory );
} }
const QDir& Paths::systemLogDirectory() const MYXLIB_INLINE const QDir& Paths::systemLogDirectory() const
{ {
return( m_systemLogDirectory ); return( m_systemLogDirectory );
} }
const QDir& Paths::tempDirectory() const MYXLIB_INLINE const QDir& Paths::tempDirectory() const
{ {
return( m_tempDirectory ); return( m_tempDirectory );
} }
const QDir& Paths::homeDirectory() const MYXLIB_INLINE const QDir& Paths::homeDirectory() const
{ {
return( m_homeDirectory ); return( m_homeDirectory );
} }
const QString& Paths::projectName() const MYXLIB_INLINE const QString& Paths::projectName() const
{ {
return( m_projectName ); return( m_projectName );
} }
QString Paths::executableFileName() const MYXLIB_INLINE QString Paths::executableFileName() const
{ {
return( m_currentExecutable.m_canonicalFilePath.fileName() ); return( m_currentExecutable.m_canonicalFilePath.fileName() );
} }
const QFileInfo& Paths::executableFilePath() const MYXLIB_INLINE const QFileInfo& Paths::executableFilePath() const
{ {
return( m_currentExecutable.m_canonicalFilePath ); return( m_currentExecutable.m_canonicalFilePath );
} }

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/filesystem/paths-inl.hpp> #include <myx/filesystem/paths-inl.hpp>

View File

@ -19,9 +19,9 @@ namespace myx {
namespace filesystem { namespace filesystem {
PathsMT::PathsMT() = default; MYXLIB_INLINE PathsMT::PathsMT() = default;
PathsMT& PathsMT::instance() MYXLIB_INLINE PathsMT& PathsMT::instance()
{ {
volatile PathsMT* localInstance = mInstance.load( std::memory_order_acquire ); volatile PathsMT* localInstance = mInstance.load( std::memory_order_acquire );
if ( localInstance == nullptr ) if ( localInstance == nullptr )

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/filesystem/paths_mt-inl.hpp> #include <myx/filesystem/paths_mt-inl.hpp>

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_ALL_HPP_
#define MYX_MATH_ALL_HPP_
#pragma once
#include <myx/math/almost_equal_relative.hpp> #include <myx/math/almost_equal_relative.hpp>
#include <myx/math/almost_equal_relative_and_abs.hpp> #include <myx/math/almost_equal_relative_and_abs.hpp>
#include <myx/math/almost_equal_ulps.hpp> #include <myx/math/almost_equal_ulps.hpp>
@ -6,3 +11,5 @@
#include <myx/math/functions.hpp> #include <myx/math/functions.hpp>
#include <myx/math/radar.hpp> #include <myx/math/radar.hpp>
#include <myx/math/units.hpp> #include <myx/math/units.hpp>
#endif

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY #ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_relative.hpp> #include <myx/math/almost_equal_relative.hpp>
#endif #endif
@ -8,7 +13,7 @@ namespace myx {
namespace math { namespace math {
bool almost_equal_relative( const float a, const float b, MYXLIB_INLINE bool almost_equal_relative( const float a, const float b,
const float maxRelDiff ) const float maxRelDiff )
{ {
float diff = fabsf( a - b ); float diff = fabsf( a - b );
@ -24,7 +29,7 @@ bool almost_equal_relative( const float a, const float b,
} }
bool almost_equal_relative( const double a, const double b, MYXLIB_INLINE bool almost_equal_relative( const double a, const double b,
const double maxRelDiff ) const double maxRelDiff )
{ {
double diff = fabs( a - b ); double diff = fabs( a - b );
@ -42,3 +47,5 @@ bool almost_equal_relative( const double a, const double b,
} // namespace math } // namespace math
} // namespace myx } // namespace myx
#endif

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/math/almost_equal_relative-inl.hpp> #include <myx/math/almost_equal_relative-inl.hpp>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_ #ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_ #define MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_
#pragma once
#include <myx/base/config.hpp> #include <myx/base/config.hpp>
#include <cfloat> #include <cfloat>

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY #ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_relative_and_abs.hpp> #include <myx/math/almost_equal_relative_and_abs.hpp>
#endif #endif
@ -8,7 +13,7 @@ namespace myx {
namespace math { namespace math {
bool almost_equal_relative_and_abs( const float a, const float b, MYXLIB_INLINE bool almost_equal_relative_and_abs( const float a, const float b,
const float maxAbsDiff, const float maxRelDiff ) const float maxAbsDiff, const float maxRelDiff )
{ {
// Check if the numbers are really close -- needed // Check if the numbers are really close -- needed
@ -31,7 +36,7 @@ bool almost_equal_relative_and_abs( const float a, const float b,
} }
bool almost_equal_relative_and_abs( const double a, const double b, MYXLIB_INLINE bool almost_equal_relative_and_abs( const double a, const double b,
const double maxAbsDiff, const double maxRelDiff ) const double maxAbsDiff, const double maxRelDiff )
{ {
// Check if the numbers are really close -- needed // Check if the numbers are really close -- needed
@ -56,3 +61,5 @@ bool almost_equal_relative_and_abs( const double a, const double b,
} // namespace math } // namespace math
} // namespace myx } // namespace myx
#endif

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/math/almost_equal_relative_and_abs-inl.hpp> #include <myx/math/almost_equal_relative_and_abs-inl.hpp>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_ #ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_ #define MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_
#pragma once
#include <myx/base/config.hpp> #include <myx/base/config.hpp>
#include <cfloat> #include <cfloat>

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY #ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_ulps.hpp> #include <myx/math/almost_equal_ulps.hpp>
#endif #endif
@ -10,7 +15,7 @@ namespace myx {
namespace math { namespace math {
bool almost_equal_ulps( const float a, const float b, MYXLIB_INLINE bool almost_equal_ulps( const float a, const float b,
const int maxUlpsDiff ) const int maxUlpsDiff )
{ {
FloatCmp uA( a ); FloatCmp uA( a );
@ -46,7 +51,7 @@ bool almost_equal_ulps( const float a, const float b,
} // almost_equal_ulps } // almost_equal_ulps
bool almost_equal_ulps( const double a, const double b, MYXLIB_INLINE bool almost_equal_ulps( const double a, const double b,
const int maxUlpsDiff ) const int maxUlpsDiff )
{ {
DoubleCmp uA( a ); DoubleCmp uA( a );
@ -84,3 +89,5 @@ bool almost_equal_ulps( const double a, const double b,
} // namespace math } // namespace math
} // namespace myx } // namespace myx
#endif

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/math/almost_equal_ulps-inl.hpp> #include <myx/math/almost_equal_ulps-inl.hpp>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ #ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ #define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#pragma once
#include <myx/base/config.hpp> #include <myx/base/config.hpp>
#include <myx/math/float_cmp_types.hpp> #include <myx/math/float_cmp_types.hpp>

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY #ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_ulps_and_abs.hpp> #include <myx/math/almost_equal_ulps_and_abs.hpp>
#endif #endif
@ -10,7 +15,7 @@ namespace myx {
namespace math { namespace math {
bool almost_equal_ulps_and_abs( const float a, const float b, MYXLIB_INLINE bool almost_equal_ulps_and_abs( const float a, const float b,
const float maxAbsDiff, const int maxUlpsDiff ) const float maxAbsDiff, const int maxUlpsDiff )
{ {
// Check if the numbers are really close -- needed // Check if the numbers are really close -- needed
@ -43,7 +48,7 @@ bool almost_equal_ulps_and_abs( const float a, const float b,
} // almost_equal_ulps_and_abs } // almost_equal_ulps_and_abs
bool almost_equal_ulps_and_abs( const double a, const double b, MYXLIB_INLINE bool almost_equal_ulps_and_abs( const double a, const double b,
const double maxAbsDiff, const int maxUlpsDiff ) const double maxAbsDiff, const int maxUlpsDiff )
{ {
// Check if the numbers are really close -- needed // Check if the numbers are really close -- needed
@ -78,3 +83,5 @@ bool almost_equal_ulps_and_abs( const double a, const double b,
} // namespace math } // namespace math
} // namespace myx } // namespace myx
#endif

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/math/almost_equal_ulps_and_abs-inl.hpp> #include <myx/math/almost_equal_ulps_and_abs-inl.hpp>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ #ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ #define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#pragma once
#include <myx/base/config.hpp> #include <myx/base/config.hpp>
namespace myx { namespace myx {

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_CONSTANTS_INL_HPP_
#define MYX_MATH_CONSTANTS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY #ifndef MYXLIB_HEADER_ONLY
#include <myx/math/constants.hpp> #include <myx/math/constants.hpp>
#endif #endif
@ -9,3 +14,5 @@ namespace math {
} // namespace math } // namespace math
} // namespace myx } // namespace myx
#endif

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/math/constants-inl.hpp> #include <myx/math/constants-inl.hpp>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_CONSTANTS_HPP_ #ifndef MYX_MATH_CONSTANTS_HPP_
#define MYX_MATH_CONSTANTS_HPP_ #define MYX_MATH_CONSTANTS_HPP_
#pragma once
#include <myx/base/config.hpp> #include <myx/base/config.hpp>
#include <cmath> #include <cmath>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_FLOAT_CMP_TYPES_HPP_ #ifndef MYX_MATH_FLOAT_CMP_TYPES_HPP_
#define MYX_MATH_FLOAT_CMP_TYPES_HPP_ #define MYX_MATH_FLOAT_CMP_TYPES_HPP_
#pragma once
#include <cstdint> #include <cstdint>
/** /**

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_FUNCTIONS_HPP_ #ifndef MYX_MATH_FUNCTIONS_HPP_
#define MYX_MATH_FUNCTIONS_HPP_ #define MYX_MATH_FUNCTIONS_HPP_
#pragma once
#include <boost/math/special_functions/pow.hpp> #include <boost/math/special_functions/pow.hpp>
#include <cmath> #include <cmath>
#include <type_traits> #include <type_traits>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_RADAR_HPP_ #ifndef MYX_MATH_RADAR_HPP_
#define MYX_MATH_RADAR_HPP_ #define MYX_MATH_RADAR_HPP_
#pragma once
#include <cmath> #include <cmath>
#include <type_traits> #include <type_traits>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_UNITS_HPP_ #ifndef MYX_MATH_UNITS_HPP_
#define MYX_MATH_UNITS_HPP_ #define MYX_MATH_UNITS_HPP_
#pragma once
#include <cmath> #include <cmath>
#include <type_traits> #include <type_traits>
@ -88,5 +90,4 @@ T magnitude_to_decibel( T const& magnitude )
} // namespace myx } // namespace myx
#endif // MYX_MATH_UNITS_HPP_ #endif // MYX_MATH_UNITS_HPP_

View File

@ -1,6 +1,8 @@
#ifndef MYX_QT_BACKPORTS_HPP_ #ifndef MYX_QT_BACKPORTS_HPP_
#define MYX_QT_BACKPORTS_HPP_ #define MYX_QT_BACKPORTS_HPP_
#pragma once
#if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) ) #if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) )
#define override #define override

View File

@ -17,7 +17,7 @@ namespace myx {
namespace qt { namespace qt {
void append_translators( QTranslatorsList& translators, const QString& appName ) MYXLIB_INLINE void append_translators( QTranslatorsList& translators, const QString& appName )
{ {
auto* translator = new QTranslator( qApp ); auto* translator = new QTranslator( qApp );

View File

@ -1,2 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/qt/translators.hpp> #include <myx/qt/translators.hpp>
#include <myx/qt/translators-inl.hpp>

View File

@ -1,5 +1,7 @@
#ifndef MYX_LOG_QT_TRANSLATORS_HPP_ #ifndef MYX_QT_TRANSLATORS_HPP_
#define MYX_LOG_QT_TRANSLATORS_HPP_ #define MYX_QT_TRANSLATORS_HPP_
#pragma once
#include <myx/base/config.hpp> #include <myx/base/config.hpp>
#include <myx/qt/backports.hpp> #include <myx/qt/backports.hpp>
@ -22,4 +24,4 @@ void append_translators( QTranslatorsList& translators, const QString& appName )
#include "translators-inl.hpp" #include "translators-inl.hpp"
#endif #endif
#endif // ifndef MYX_LOG_QT_TRANSLATORS_HPP_ #endif // ifndef MYX_QT_TRANSLATORS_HPP_