From ef1448a0b197b75864bfd94a6d2a71e28cb75d9d Mon Sep 17 00:00:00 2001 From: Jared Duffey Date: Fri, 18 Oct 2024 14:37:13 -0400 Subject: [PATCH] ENH: Changes to decrease compile time (#1105) Supercedes #1064 Fixes #1063 * Moved Application.hpp dependency to DataArrayUtilities.cpp from hpp Signed-off-by: Jared Duffey * Moved GetAllDataTypes and related functions to their own header Signed-off-by: Jared Duffey * Moved StringLiteral fmt formatting to separate header Signed-off-by: Jared Duffey * Replaced itk header with more specific header * Needed itk::ImageIOBase::IOComponentEnum Signed-off-by: Jared Duffey * Moved some nlohmann json code out of headers Signed-off-by: Jared Duffey * Fixed missing formatting header Signed-off-by: Jared Duffey * Fixed compile issue for msvc v142 Signed-off-by: Jared Duffey --------- Signed-off-by: Jared Duffey --- CMakeLists.txt | 2 + .../Common/ITKArrayHelper.hpp | 2 +- .../OEMEbsdScanSelectionParameter.cpp | 1 + .../Parameters/ReadH5EbsdFileParameter.cpp | 1 + src/nxrunner/src/nxrunner.cpp | 1 + src/simplnx/Common/DataTypeUtilities.hpp | 32 +++++++++++ src/simplnx/Common/StringLiteral.hpp | 39 ------------- .../Common/StringLiteralFormatting.hpp | 42 ++++++++++++++ src/simplnx/Common/Types.hpp | 22 -------- src/simplnx/Common/Uuid.hpp | 2 +- .../DataStructure/AbstractDataStore.hpp | 1 + .../Filter/Actions/CreateDataGroupAction.cpp | 1 + src/simplnx/Filter/Actions/MoveDataAction.cpp | 1 + src/simplnx/Filter/IParameter.cpp | 1 + .../Parameters/ArraySelectionParameter.cpp | 1 + .../Parameters/ArraySelectionParameter.hpp | 3 +- src/simplnx/Parameters/BoolParameter.cpp | 2 + .../Parameters/CalculatorParameter.cpp | 1 + src/simplnx/Parameters/ChoicesParameter.cpp | 1 + .../Parameters/CreateColorMapParameter.cpp | 1 + .../Parameters/CreateColorMapParameter.hpp | 2 - .../DataGroupSelectionParameter.cpp | 1 + .../Parameters/DataObjectNameParameter.cpp | 1 + .../Parameters/DataPathSelectionParameter.cpp | 1 + src/simplnx/Parameters/DataTypeParameter.cpp | 2 + .../Parameters/Dream3dImportParameter.cpp | 1 + .../Parameters/DynamicTableParameter.cpp | 1 + .../Parameters/FileSystemPathParameter.cpp | 1 + .../Parameters/GeneratedFileListParameter.cpp | 1 + .../MultiArraySelectionParameter.cpp | 1 + .../MultiArraySelectionParameter.hpp | 3 +- .../MultiPathSelectionParameter.cpp | 1 + .../NeighborListSelectionParameter.cpp | 1 + src/simplnx/Parameters/NumberParameter.cpp | 2 + .../Parameters/NumericTypeParameter.cpp | 1 + .../Parameters/ReadHDF5DatasetParameter.cpp | 51 +++++++++++++++++ .../Parameters/ReadHDF5DatasetParameter.hpp | 55 ++----------------- src/simplnx/Parameters/StringParameter.cpp | 1 + src/simplnx/Parameters/VectorParameter.cpp | 1 + src/simplnx/Utilities/DataArrayUtilities.cpp | 17 ++++++ src/simplnx/Utilities/DataArrayUtilities.hpp | 25 ++++++--- src/simplnx/Utilities/FilterUtilities.hpp | 1 + src/simplnx/Utilities/SIMPLConversion.cpp | 2 + test/DataArrayTest.cpp | 1 + .../python/CxPybind/CxPybind/CxPybind.hpp | 2 + 45 files changed, 208 insertions(+), 125 deletions(-) create mode 100644 src/simplnx/Common/DataTypeUtilities.hpp create mode 100644 src/simplnx/Common/StringLiteralFormatting.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b38b39865f..687b3beee4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,6 +332,7 @@ set(SIMPLNX_HDRS ${SIMPLNX_SOURCE_DIR}/Common/BoundingBox.hpp ${SIMPLNX_SOURCE_DIR}/Common/SimplnxConstants.hpp ${SIMPLNX_SOURCE_DIR}/Common/Constants.hpp + ${SIMPLNX_SOURCE_DIR}/Common/DataTypeUtilities.hpp ${SIMPLNX_SOURCE_DIR}/Common/DataVector.hpp ${SIMPLNX_SOURCE_DIR}/Common/EulerAngle.hpp ${SIMPLNX_SOURCE_DIR}/Common/IteratorUtility.hpp @@ -344,6 +345,7 @@ set(SIMPLNX_HDRS ${SIMPLNX_SOURCE_DIR}/Common/RgbColor.hpp ${SIMPLNX_SOURCE_DIR}/Common/ScopeGuard.hpp ${SIMPLNX_SOURCE_DIR}/Common/StringLiteral.hpp + ${SIMPLNX_SOURCE_DIR}/Common/StringLiteralFormatting.hpp ${SIMPLNX_SOURCE_DIR}/Common/TypeTraits.hpp ${SIMPLNX_SOURCE_DIR}/Common/Types.hpp ${SIMPLNX_SOURCE_DIR}/Common/TypesUtility.hpp diff --git a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp index ff19849845..6f20863fe1 100644 --- a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp +++ b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp index e2ee8745df..a4fe55637c 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Any.hpp" #include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Utilities/StringUtilities.hpp" #include diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/ReadH5EbsdFileParameter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/ReadH5EbsdFileParameter.cpp index 654e95e027..826cf55b4e 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/ReadH5EbsdFileParameter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/ReadH5EbsdFileParameter.cpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Any.hpp" #include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "EbsdLib/IO/H5EbsdVolumeInfo.h" #include "EbsdLib/IO/HKL/CtfFields.h" diff --git a/src/nxrunner/src/nxrunner.cpp b/src/nxrunner/src/nxrunner.cpp index b85dde4178..b99ea7ed6e 100644 --- a/src/nxrunner/src/nxrunner.cpp +++ b/src/nxrunner/src/nxrunner.cpp @@ -1,6 +1,7 @@ #include "CliObserver.hpp" #include "simplnx/Common/Result.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Core/Application.hpp" #include "simplnx/Pipeline/Pipeline.hpp" #include "simplnx/SIMPLNXVersion.hpp" diff --git a/src/simplnx/Common/DataTypeUtilities.hpp b/src/simplnx/Common/DataTypeUtilities.hpp new file mode 100644 index 0000000000..daf6582030 --- /dev/null +++ b/src/simplnx/Common/DataTypeUtilities.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "simplnx/Common/Types.hpp" + +#include + +namespace nx::core +{ +using DataTypeSetType = std::set; + +inline const std::set& GetAllDataTypes() +{ + static const DataTypeSetType dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, + nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64, + nx::core::DataType::float32, nx::core::DataType::float64, nx::core::DataType::boolean}; + return dataTypes; +} + +inline const std::set& GetAllNumericTypes() +{ + static const DataTypeSetType dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, nx::core::DataType::int32, + nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64, nx::core::DataType::float32, nx::core::DataType::float64}; + return dataTypes; +} + +inline const std::set& GetIntegerDataTypes() +{ + static const DataTypeSetType dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, + nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64}; + return dataTypes; +} +}; // namespace nx::core diff --git a/src/simplnx/Common/StringLiteral.hpp b/src/simplnx/Common/StringLiteral.hpp index fdea059dd9..d25d3b13f2 100644 --- a/src/simplnx/Common/StringLiteral.hpp +++ b/src/simplnx/Common/StringLiteral.hpp @@ -6,9 +6,6 @@ #include #include -#include -#include - namespace nx::core { namespace detail @@ -211,39 +208,3 @@ using WStringLiteral = BasicStringLiteral; using String16Literal = BasicStringLiteral; using String32Literal = BasicStringLiteral; } // namespace nx::core - -template -struct fmt::formatter> -{ - static constexpr const CharT* GetFormatString() - { - if constexpr(std::is_same_v) - { - return "{}"; - } - if constexpr(std::is_same_v) - { - return L"{}"; - } - if constexpr(std::is_same_v) - { - return u"{}"; - } - if constexpr(std::is_same_v) - { - return U"{}"; - } - } - - constexpr typename basic_format_parse_context::iterator parse(basic_format_parse_context& ctx) - { - return ctx.begin(); - } - - typename buffer_context::iterator format(const nx::core::BasicStringLiteral& p, buffer_context& ctx) const - { - static constexpr const CharT* formatStr = GetFormatString(); - - return fmt::format_to(ctx.out(), formatStr, p.view()); - } -}; diff --git a/src/simplnx/Common/StringLiteralFormatting.hpp b/src/simplnx/Common/StringLiteralFormatting.hpp new file mode 100644 index 0000000000..46f501dd90 --- /dev/null +++ b/src/simplnx/Common/StringLiteralFormatting.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "simplnx/Common/StringLiteral.hpp" + +#include +#include + +template +struct fmt::formatter> +{ + static constexpr const CharT* GetFormatString() + { + if constexpr(std::is_same_v) + { + return "{}"; + } + if constexpr(std::is_same_v) + { + return L"{}"; + } + if constexpr(std::is_same_v) + { + return u"{}"; + } + if constexpr(std::is_same_v) + { + return U"{}"; + } + } + + constexpr typename basic_format_parse_context::iterator parse(basic_format_parse_context& ctx) + { + return ctx.begin(); + } + + typename buffer_context::iterator format(const nx::core::BasicStringLiteral& p, buffer_context& ctx) const + { + static constexpr const CharT* formatStr = GetFormatString(); + + return fmt::format_to(ctx.out(), formatStr, p.view()); + } +}; diff --git a/src/simplnx/Common/Types.hpp b/src/simplnx/Common/Types.hpp index a4590ea99c..ae81ba3087 100644 --- a/src/simplnx/Common/Types.hpp +++ b/src/simplnx/Common/Types.hpp @@ -99,26 +99,4 @@ enum class FaultState Errors = 2 }; -inline const std::set& GetAllDataTypes() -{ - static const std::set dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, - nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64, - nx::core::DataType::float32, nx::core::DataType::float64, nx::core::DataType::boolean}; - return dataTypes; -} - -inline const std::set& GetAllNumericTypes() -{ - static const std::set dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, nx::core::DataType::int32, - nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64, nx::core::DataType::float32, nx::core::DataType::float64}; - return dataTypes; -} - -inline const std::set& GetIntegerDataTypes() -{ - static const std::set dataTypes = {nx::core::DataType::int8, nx::core::DataType::uint8, nx::core::DataType::int16, nx::core::DataType::uint16, - nx::core::DataType::int32, nx::core::DataType::uint32, nx::core::DataType::int64, nx::core::DataType::uint64}; - return dataTypes; -} - } // namespace nx::core diff --git a/src/simplnx/Common/Uuid.hpp b/src/simplnx/Common/Uuid.hpp index 89528a4ac7..2cda96aac9 100644 --- a/src/simplnx/Common/Uuid.hpp +++ b/src/simplnx/Common/Uuid.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "simplnx/Common/Bit.hpp" #include "simplnx/Common/Types.hpp" diff --git a/src/simplnx/DataStructure/AbstractDataStore.hpp b/src/simplnx/DataStructure/AbstractDataStore.hpp index a6ebfa8b44..37749ec821 100644 --- a/src/simplnx/DataStructure/AbstractDataStore.hpp +++ b/src/simplnx/DataStructure/AbstractDataStore.hpp @@ -2,6 +2,7 @@ #include "simplnx/Common/IteratorUtility.hpp" #include "simplnx/Common/Result.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/DataStructure/DataObject.hpp" #include "simplnx/DataStructure/IDataStore.hpp" diff --git a/src/simplnx/Filter/Actions/CreateDataGroupAction.cpp b/src/simplnx/Filter/Actions/CreateDataGroupAction.cpp index 2c92adbc20..4ac1224e91 100644 --- a/src/simplnx/Filter/Actions/CreateDataGroupAction.cpp +++ b/src/simplnx/Filter/Actions/CreateDataGroupAction.cpp @@ -1,5 +1,6 @@ #include "CreateDataGroupAction.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/DataStructure/DataStructure.hpp" #include "simplnx/DataStructure/LinkedPath.hpp" diff --git a/src/simplnx/Filter/Actions/MoveDataAction.cpp b/src/simplnx/Filter/Actions/MoveDataAction.cpp index 4eb0492cdd..048fb09fcf 100644 --- a/src/simplnx/Filter/Actions/MoveDataAction.cpp +++ b/src/simplnx/Filter/Actions/MoveDataAction.cpp @@ -1,5 +1,6 @@ #include "MoveDataAction.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/DataStructure/BaseGroup.hpp" #include diff --git a/src/simplnx/Filter/IParameter.cpp b/src/simplnx/Filter/IParameter.cpp index 2c5431b5db..30b39fdaa9 100644 --- a/src/simplnx/Filter/IParameter.cpp +++ b/src/simplnx/Filter/IParameter.cpp @@ -1,6 +1,7 @@ #include "IParameter.hpp" #include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include diff --git a/src/simplnx/Parameters/ArraySelectionParameter.cpp b/src/simplnx/Parameters/ArraySelectionParameter.cpp index b1d5344a80..a8aa7a7d86 100644 --- a/src/simplnx/Parameters/ArraySelectionParameter.cpp +++ b/src/simplnx/Parameters/ArraySelectionParameter.cpp @@ -1,6 +1,7 @@ #include "ArraySelectionParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/DataStructure/DataGroup.hpp" #include "simplnx/DataStructure/IDataArray.hpp" diff --git a/src/simplnx/Parameters/ArraySelectionParameter.hpp b/src/simplnx/Parameters/ArraySelectionParameter.hpp index 9bc880ba75..3afb8846c2 100644 --- a/src/simplnx/Parameters/ArraySelectionParameter.hpp +++ b/src/simplnx/Parameters/ArraySelectionParameter.hpp @@ -1,5 +1,6 @@ #pragma once +#include "simplnx/Common/DataTypeUtilities.hpp" #include "simplnx/DataStructure/IArray.hpp" #include "simplnx/Filter/MutableDataParameter.hpp" #include "simplnx/Filter/ParameterTraits.hpp" @@ -18,7 +19,7 @@ class SIMPLNX_EXPORT ArraySelectionParameter : public MutableDataParameter { public: using ValueType = DataPath; - using AllowedTypes = std::set; + using AllowedTypes = nx::core::DataTypeSetType; using AllowedComponentShapes = std::vector; enum class DataLocation : uint8 diff --git a/src/simplnx/Parameters/BoolParameter.cpp b/src/simplnx/Parameters/BoolParameter.cpp index b6e597a88e..7db09564a0 100644 --- a/src/simplnx/Parameters/BoolParameter.cpp +++ b/src/simplnx/Parameters/BoolParameter.cpp @@ -1,5 +1,7 @@ #include "BoolParameter.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" + #include #include diff --git a/src/simplnx/Parameters/CalculatorParameter.cpp b/src/simplnx/Parameters/CalculatorParameter.cpp index 085f240176..8694ddaefc 100644 --- a/src/simplnx/Parameters/CalculatorParameter.cpp +++ b/src/simplnx/Parameters/CalculatorParameter.cpp @@ -1,6 +1,7 @@ #include "CalculatorParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypeTraits.hpp" #include "simplnx/DataStructure/BaseGroup.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" diff --git a/src/simplnx/Parameters/ChoicesParameter.cpp b/src/simplnx/Parameters/ChoicesParameter.cpp index 70652e8b6d..8000f02ee0 100644 --- a/src/simplnx/Parameters/ChoicesParameter.cpp +++ b/src/simplnx/Parameters/ChoicesParameter.cpp @@ -1,5 +1,6 @@ #include "ChoicesParameter.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include diff --git a/src/simplnx/Parameters/CreateColorMapParameter.cpp b/src/simplnx/Parameters/CreateColorMapParameter.cpp index 0e79538564..eb308d8913 100644 --- a/src/simplnx/Parameters/CreateColorMapParameter.cpp +++ b/src/simplnx/Parameters/CreateColorMapParameter.cpp @@ -1,6 +1,7 @@ #include "CreateColorMapParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/util/ColorTable.hpp" #include diff --git a/src/simplnx/Parameters/CreateColorMapParameter.hpp b/src/simplnx/Parameters/CreateColorMapParameter.hpp index 1f700a1737..76e3381e2a 100644 --- a/src/simplnx/Parameters/CreateColorMapParameter.hpp +++ b/src/simplnx/Parameters/CreateColorMapParameter.hpp @@ -4,8 +4,6 @@ #include "simplnx/Filter/ValueParameter.hpp" #include "simplnx/simplnx_export.hpp" -#include - #include namespace nx::core diff --git a/src/simplnx/Parameters/DataGroupSelectionParameter.cpp b/src/simplnx/Parameters/DataGroupSelectionParameter.cpp index 87a4ff2e29..9d0f2322e5 100644 --- a/src/simplnx/Parameters/DataGroupSelectionParameter.cpp +++ b/src/simplnx/Parameters/DataGroupSelectionParameter.cpp @@ -1,6 +1,7 @@ #include "DataGroupSelectionParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/DataStructure/DataGroup.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" diff --git a/src/simplnx/Parameters/DataObjectNameParameter.cpp b/src/simplnx/Parameters/DataObjectNameParameter.cpp index 69aa0529c6..a33b7b5fa7 100644 --- a/src/simplnx/Parameters/DataObjectNameParameter.cpp +++ b/src/simplnx/Parameters/DataObjectNameParameter.cpp @@ -1,6 +1,7 @@ #include "DataObjectNameParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/DataStructure/DataObject.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" diff --git a/src/simplnx/Parameters/DataPathSelectionParameter.cpp b/src/simplnx/Parameters/DataPathSelectionParameter.cpp index eceb721aac..40d8c94e12 100644 --- a/src/simplnx/Parameters/DataPathSelectionParameter.cpp +++ b/src/simplnx/Parameters/DataPathSelectionParameter.cpp @@ -1,6 +1,7 @@ #include "DataPathSelectionParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include #include diff --git a/src/simplnx/Parameters/DataTypeParameter.cpp b/src/simplnx/Parameters/DataTypeParameter.cpp index afd7b98611..8f91d139a6 100644 --- a/src/simplnx/Parameters/DataTypeParameter.cpp +++ b/src/simplnx/Parameters/DataTypeParameter.cpp @@ -1,5 +1,7 @@ #include "DataTypeParameter.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" + #include #include diff --git a/src/simplnx/Parameters/Dream3dImportParameter.cpp b/src/simplnx/Parameters/Dream3dImportParameter.cpp index ae604b3784..9fbfc9d63c 100644 --- a/src/simplnx/Parameters/Dream3dImportParameter.cpp +++ b/src/simplnx/Parameters/Dream3dImportParameter.cpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Any.hpp" #include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Utilities/Parsing/HDF5/Readers/FileReader.hpp" #include diff --git a/src/simplnx/Parameters/DynamicTableParameter.cpp b/src/simplnx/Parameters/DynamicTableParameter.cpp index c04246992d..f11d0b9f88 100644 --- a/src/simplnx/Parameters/DynamicTableParameter.cpp +++ b/src/simplnx/Parameters/DynamicTableParameter.cpp @@ -1,6 +1,7 @@ #include "DynamicTableParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Utilities/StringUtilities.hpp" #include diff --git a/src/simplnx/Parameters/FileSystemPathParameter.cpp b/src/simplnx/Parameters/FileSystemPathParameter.cpp index 09ad42c3cd..4addddba11 100644 --- a/src/simplnx/Parameters/FileSystemPathParameter.cpp +++ b/src/simplnx/Parameters/FileSystemPathParameter.cpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Any.hpp" #include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Utilities/FileUtilities.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include "simplnx/Utilities/StringUtilities.hpp" diff --git a/src/simplnx/Parameters/GeneratedFileListParameter.cpp b/src/simplnx/Parameters/GeneratedFileListParameter.cpp index faf40061f3..d63af95687 100644 --- a/src/simplnx/Parameters/GeneratedFileListParameter.cpp +++ b/src/simplnx/Parameters/GeneratedFileListParameter.cpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Any.hpp" #include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypeTraits.hpp" #include diff --git a/src/simplnx/Parameters/MultiArraySelectionParameter.cpp b/src/simplnx/Parameters/MultiArraySelectionParameter.cpp index 626608769c..f2df0bb37e 100644 --- a/src/simplnx/Parameters/MultiArraySelectionParameter.cpp +++ b/src/simplnx/Parameters/MultiArraySelectionParameter.cpp @@ -1,6 +1,7 @@ #include "MultiArraySelectionParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/DataStructure/IArray.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include "simplnx/Utilities/StringUtilities.hpp" diff --git a/src/simplnx/Parameters/MultiArraySelectionParameter.hpp b/src/simplnx/Parameters/MultiArraySelectionParameter.hpp index 821f42b195..d6dbe453f6 100644 --- a/src/simplnx/Parameters/MultiArraySelectionParameter.hpp +++ b/src/simplnx/Parameters/MultiArraySelectionParameter.hpp @@ -1,5 +1,6 @@ #pragma once +#include "simplnx/Common/DataTypeUtilities.hpp" #include "simplnx/DataStructure/IArray.hpp" #include "simplnx/Filter/MutableDataParameter.hpp" #include "simplnx/Filter/ParameterTraits.hpp" @@ -14,7 +15,7 @@ class SIMPLNX_EXPORT MultiArraySelectionParameter : public MutableDataParameter public: using ValueType = std::vector; using AllowedTypes = std::set; - using AllowedDataTypes = std::set; + using AllowedDataTypes = nx::core::DataTypeSetType; using AllowedComponentShapes = std::vector; MultiArraySelectionParameter() = delete; diff --git a/src/simplnx/Parameters/MultiPathSelectionParameter.cpp b/src/simplnx/Parameters/MultiPathSelectionParameter.cpp index dddccf80b0..1d904c6a0b 100644 --- a/src/simplnx/Parameters/MultiPathSelectionParameter.cpp +++ b/src/simplnx/Parameters/MultiPathSelectionParameter.cpp @@ -1,6 +1,7 @@ #include "MultiPathSelectionParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include diff --git a/src/simplnx/Parameters/NeighborListSelectionParameter.cpp b/src/simplnx/Parameters/NeighborListSelectionParameter.cpp index 712752f3c7..97502e8fd0 100644 --- a/src/simplnx/Parameters/NeighborListSelectionParameter.cpp +++ b/src/simplnx/Parameters/NeighborListSelectionParameter.cpp @@ -1,6 +1,7 @@ #include "NeighborListSelectionParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/DataStructure/INeighborList.hpp" diff --git a/src/simplnx/Parameters/NumberParameter.cpp b/src/simplnx/Parameters/NumberParameter.cpp index 4223d1973e..ee459b43c1 100644 --- a/src/simplnx/Parameters/NumberParameter.cpp +++ b/src/simplnx/Parameters/NumberParameter.cpp @@ -1,5 +1,7 @@ #include "NumberParameter.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" + #include #include diff --git a/src/simplnx/Parameters/NumericTypeParameter.cpp b/src/simplnx/Parameters/NumericTypeParameter.cpp index 59a09772c3..67bba1c120 100644 --- a/src/simplnx/Parameters/NumericTypeParameter.cpp +++ b/src/simplnx/Parameters/NumericTypeParameter.cpp @@ -1,5 +1,6 @@ #include "NumericTypeParameter.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/Parameters/DataTypeParameter.hpp" diff --git a/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp b/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp index 94ddb7c26f..89a84a5049 100644 --- a/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp +++ b/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp @@ -32,6 +32,8 @@ #include "simplnx/Utilities/SIMPLConversion.hpp" +#include + using namespace nx::core; namespace { @@ -42,6 +44,55 @@ constexpr StringLiteral k_ParentGroupKey = "parent_group"; namespace nx::core { +// ----------------------------------------------------------------------------- +Result ReadHDF5DatasetParameter::DatasetImportInfo::ReadJson(const nlohmann::json& json) +{ + DatasetImportInfo data; + if(!json.contains(k_DatasetPath_Key.view())) + { + return MakeErrorResult(-500, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_DatasetPath_Key)); + } + else if(!json[k_DatasetPath_Key.str()].is_string()) + { + return MakeErrorResult(-501, fmt::format("ImportHDF5DatasetParameter ValueType: 'Dataset Path' value is of type {} and is not a string.", json[k_DatasetPath_Key].type_name())); + } + data.dataSetPath = json[k_DatasetPath_Key.str()]; + + if(!json.contains(k_ComponentDimensions_Key.view())) + { + return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_ComponentDimensions_Key)); + } + else if(!json[k_ComponentDimensions_Key.str()].is_string()) + { + return MakeErrorResult( + -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Component Dimensions' value is of type {} and is not a string.", json[k_ComponentDimensions_Key].type_name())); + } + data.componentDimensions = json[k_ComponentDimensions_Key.str()]; + + if(!json.contains(k_TupleDimensions_Key.view())) + { + return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_TupleDimensions_Key)); + } + else if(!json[k_TupleDimensions_Key.str()].is_string()) + { + return MakeErrorResult( + -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Tuple Dimensions' value is of type {} and is not a string.", json[k_TupleDimensions_Key].type_name())); + } + data.tupleDimensions = json[k_TupleDimensions_Key.str()]; + + return {data}; +} + +// ----------------------------------------------------------------------------- +nlohmann::json ReadHDF5DatasetParameter::DatasetImportInfo::writeJson() const +{ + nlohmann::json json; + json[k_DatasetPath_Key.str()] = dataSetPath; + json[k_ComponentDimensions_Key.str()] = componentDimensions; + json[k_TupleDimensions_Key.str()] = tupleDimensions; + return json; +} + // ----------------------------------------------------------------------------- ReadHDF5DatasetParameter::ReadHDF5DatasetParameter(const std::string& name, const std::string& humanName, const std::string& helpText, const ValueType& defaultValue) : ValueParameter(name, humanName, helpText) diff --git a/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp b/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp index eca3b587a7..ca0d74c6fa 100644 --- a/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp +++ b/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp @@ -31,13 +31,12 @@ #pragma once #include "simplnx/Common/Result.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/Filter/ParameterTraits.hpp" #include "simplnx/Filter/ValueParameter.hpp" #include "simplnx/simplnx_export.hpp" -#include - #include #include @@ -46,7 +45,7 @@ namespace nx::core class SIMPLNX_EXPORT ReadHDF5DatasetParameter : public ValueParameter { public: - struct DatasetImportInfo + struct SIMPLNX_EXPORT DatasetImportInfo { std::string dataSetPath; std::string componentDimensions; @@ -56,53 +55,9 @@ class SIMPLNX_EXPORT ReadHDF5DatasetParameter : public ValueParameter static inline constexpr StringLiteral k_ComponentDimensions_Key = "component_dimensions"; static inline constexpr StringLiteral k_TupleDimensions_Key = "tuple_dimensions"; - static Result ReadJson(const nlohmann::json& json) - { - DatasetImportInfo data; - if(!json.contains(k_DatasetPath_Key.view())) - { - return MakeErrorResult(-500, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_DatasetPath_Key)); - } - else if(!json[k_DatasetPath_Key.str()].is_string()) - { - return MakeErrorResult(-501, - fmt::format("ImportHDF5DatasetParameter ValueType: 'Dataset Path' value is of type {} and is not a string.", json[k_DatasetPath_Key].type_name())); - } - data.dataSetPath = json[k_DatasetPath_Key.str()]; - - if(!json.contains(k_ComponentDimensions_Key.view())) - { - return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_ComponentDimensions_Key)); - } - else if(!json[k_ComponentDimensions_Key.str()].is_string()) - { - return MakeErrorResult( - -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Component Dimensions' value is of type {} and is not a string.", json[k_ComponentDimensions_Key].type_name())); - } - data.componentDimensions = json[k_ComponentDimensions_Key.str()]; - - if(!json.contains(k_TupleDimensions_Key.view())) - { - return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_TupleDimensions_Key)); - } - else if(!json[k_TupleDimensions_Key.str()].is_string()) - { - return MakeErrorResult( - -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Tuple Dimensions' value is of type {} and is not a string.", json[k_TupleDimensions_Key].type_name())); - } - data.tupleDimensions = json[k_TupleDimensions_Key.str()]; - - return {data}; - } - - nlohmann::json writeJson() const - { - nlohmann::json json; - json[k_DatasetPath_Key.str()] = dataSetPath; - json[k_ComponentDimensions_Key.str()] = componentDimensions; - json[k_TupleDimensions_Key.str()] = tupleDimensions; - return json; - } + static Result ReadJson(const nlohmann::json& json); + + nlohmann::json writeJson() const; }; using InputFile = std::string; diff --git a/src/simplnx/Parameters/StringParameter.cpp b/src/simplnx/Parameters/StringParameter.cpp index 581859cd5a..4553c2fa34 100644 --- a/src/simplnx/Parameters/StringParameter.cpp +++ b/src/simplnx/Parameters/StringParameter.cpp @@ -1,6 +1,7 @@ #include "StringParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include #include diff --git a/src/simplnx/Parameters/VectorParameter.cpp b/src/simplnx/Parameters/VectorParameter.cpp index 068e2b6792..15c05dff5e 100644 --- a/src/simplnx/Parameters/VectorParameter.cpp +++ b/src/simplnx/Parameters/VectorParameter.cpp @@ -1,6 +1,7 @@ #include "VectorParameter.hpp" #include "simplnx/Common/Any.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypeTraits.hpp" #include diff --git a/src/simplnx/Utilities/DataArrayUtilities.cpp b/src/simplnx/Utilities/DataArrayUtilities.cpp index ca5ca0c57d..0e8426c31a 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.cpp +++ b/src/simplnx/Utilities/DataArrayUtilities.cpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Types.hpp" #include "simplnx/Common/TypesUtility.hpp" +#include "simplnx/Core/Application.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" #include @@ -32,6 +33,22 @@ struct InitializeNeighborListFunctor namespace nx::core { +//----------------------------------------------------------------------------- +void TryForceLargeDataFormatFromPrefs(std::string& dataFormat) +{ + auto* preferencesPtr = Application::GetOrCreateInstance()->getPreferences(); + if(preferencesPtr->forceOocData()) + { + dataFormat = preferencesPtr->largeDataFormat(); + } +} + +//----------------------------------------------------------------------------- +std::shared_ptr GetIOCollection() +{ + return Application::GetOrCreateInstance()->getIOCollection(); +} + //----------------------------------------------------------------------------- Result<> CheckValueConverts(const std::string& value, NumericType numericType) { diff --git a/src/simplnx/Utilities/DataArrayUtilities.hpp b/src/simplnx/Utilities/DataArrayUtilities.hpp index 0e3db14f2a..2670fb65cf 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.hpp +++ b/src/simplnx/Utilities/DataArrayUtilities.hpp @@ -2,7 +2,6 @@ #include "simplnx/Common/Array.hpp" #include "simplnx/Common/Result.hpp" -#include "simplnx/Core/Application.hpp" #include "simplnx/DataStructure/AttributeMatrix.hpp" #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/DataStore.hpp" @@ -12,6 +11,7 @@ #include "simplnx/DataStructure/NeighborList.hpp" #include "simplnx/DataStructure/StringArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" +#include "simplnx/Filter/IFilter.hpp" #include "simplnx/Filter/Output.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Utilities/MemoryUtilities.hpp" @@ -157,6 +157,19 @@ struct ConvertTo } }; +/** + * @brief Sets the dataFormat string to the large data format from the prefs + * if forceOocData is true. + * @param dataFormat + */ +SIMPLNX_EXPORT void TryForceLargeDataFormatFromPrefs(std::string& dataFormat); + +/** + * @brief Returns the application's DataIOCollection. + * @return + */ +SIMPLNX_EXPORT std::shared_ptr GetIOCollection(); + /** * @brief Checks if the given string can be correctly converted into the given type * @tparam T The primitive type to convert the string into @@ -364,12 +377,8 @@ std::shared_ptr> CreateDataStore(const typename IDataStore: } case IDataAction::Mode::Execute: { uint64 dataSize = CalculateDataSize(tupleShape, componentShape); - auto* preferencesPtr = Application::GetOrCreateInstance()->getPreferences(); - if(preferencesPtr->forceOocData()) - { - dataFormat = preferencesPtr->largeDataFormat(); - } - auto ioCollection = Application::GetOrCreateInstance()->getIOCollection(); + TryForceLargeDataFormatFromPrefs(dataFormat); + auto ioCollection = GetIOCollection(); ioCollection->checkStoreDataFormat(dataSize, dataFormat); return ioCollection->createDataStoreWithType(dataFormat, tupleShape, componentShape); } @@ -476,7 +485,7 @@ std::shared_ptr> ConvertDataStore(const AbstractDataStoregetIOCollection(); + auto ioCollection = GetIOCollection(); std::shared_ptr> newStore = ioCollection->createDataStoreWithType(dataFormat, dataStore.getTupleShape(), dataStore.getComponentShape()); if(newStore == nullptr) { diff --git a/src/simplnx/Utilities/FilterUtilities.hpp b/src/simplnx/Utilities/FilterUtilities.hpp index f34e0d0c0f..aab75f8d51 100644 --- a/src/simplnx/Utilities/FilterUtilities.hpp +++ b/src/simplnx/Utilities/FilterUtilities.hpp @@ -2,6 +2,7 @@ #include "ParallelAlgorithmUtilities.hpp" #include "simplnx/Common/Result.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" #include "simplnx/Common/TypeTraits.hpp" #include "simplnx/Common/Types.hpp" #include "simplnx/Common/TypesUtility.hpp" diff --git a/src/simplnx/Utilities/SIMPLConversion.cpp b/src/simplnx/Utilities/SIMPLConversion.cpp index 553c5d8190..89be0aeb66 100644 --- a/src/simplnx/Utilities/SIMPLConversion.cpp +++ b/src/simplnx/Utilities/SIMPLConversion.cpp @@ -1,5 +1,7 @@ #include "SIMPLConversion.hpp" +#include "simplnx/Common/StringLiteralFormatting.hpp" + namespace nx::core::SIMPLConversion { /* diff --git a/test/DataArrayTest.cpp b/test/DataArrayTest.cpp index 2483ce8e52..a47527189e 100644 --- a/test/DataArrayTest.cpp +++ b/test/DataArrayTest.cpp @@ -1,5 +1,6 @@ #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/Common/Array.hpp" +#include "simplnx/Core/Application.hpp" #include "simplnx/DataStructure/DataStore.hpp" #include "simplnx/DataStructure/DataStructure.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" diff --git a/wrapping/python/CxPybind/CxPybind/CxPybind.hpp b/wrapping/python/CxPybind/CxPybind/CxPybind.hpp index 9936979dd3..77afdb1f13 100644 --- a/wrapping/python/CxPybind/CxPybind/CxPybind.hpp +++ b/wrapping/python/CxPybind/CxPybind/CxPybind.hpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include #include