Skip to content

Commit

Permalink
ENH: Changes to decrease compile time (BlueQuartzSoftware#1105)
Browse files Browse the repository at this point in the history
Supercedes BlueQuartzSoftware#1064
Fixes BlueQuartzSoftware#1063

* Moved Application.hpp dependency to DataArrayUtilities.cpp from hpp

Signed-off-by: Jared Duffey <[email protected]>

* Moved GetAllDataTypes and related functions to their own header

Signed-off-by: Jared Duffey <[email protected]>

* Moved StringLiteral fmt formatting to separate header

Signed-off-by: Jared Duffey <[email protected]>

* Replaced itk header with more specific header

* Needed itk::ImageIOBase::IOComponentEnum

Signed-off-by: Jared Duffey <[email protected]>

* Moved some nlohmann json code out of headers

Signed-off-by: Jared Duffey <[email protected]>

* Fixed missing formatting header

Signed-off-by: Jared Duffey <[email protected]>

* Fixed compile issue for msvc v142

Signed-off-by: Jared Duffey <[email protected]>

---------

Signed-off-by: Jared Duffey <[email protected]>
  • Loading branch information
JDuffeyBQ authored and imikejackson committed Oct 18, 2024
1 parent 3684919 commit ef1448a
Show file tree
Hide file tree
Showing 45 changed files with 208 additions and 125 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <itkCastImageFilter.h>
#include <itkImage.h>
#include <itkImageFileWriter.h>
#include <itkImageIOBase.h>
#include <itkImportImageFilter.h>
#include <itkNumericTraits.h>
#include <itkVector.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fmt/core.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/nxrunner/src/nxrunner.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
32 changes: 32 additions & 0 deletions src/simplnx/Common/DataTypeUtilities.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "simplnx/Common/Types.hpp"

#include <set>

namespace nx::core
{
using DataTypeSetType = std::set<DataType>;

inline const std::set<DataType>& 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<DataType>& 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<DataType>& 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
39 changes: 0 additions & 39 deletions src/simplnx/Common/StringLiteral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include <string>
#include <string_view>

#include <fmt/core.h>
#include <fmt/xchar.h>

namespace nx::core
{
namespace detail
Expand Down Expand Up @@ -211,39 +208,3 @@ using WStringLiteral = BasicStringLiteral<wchar_t>;
using String16Literal = BasicStringLiteral<char16_t>;
using String32Literal = BasicStringLiteral<char32_t>;
} // namespace nx::core

template <class CharT>
struct fmt::formatter<nx::core::BasicStringLiteral<CharT>>
{
static constexpr const CharT* GetFormatString()
{
if constexpr(std::is_same_v<CharT, char>)
{
return "{}";
}
if constexpr(std::is_same_v<CharT, wchar_t>)
{
return L"{}";
}
if constexpr(std::is_same_v<CharT, char16_t>)
{
return u"{}";
}
if constexpr(std::is_same_v<CharT, char32_t>)
{
return U"{}";
}
}

constexpr typename basic_format_parse_context<CharT>::iterator parse(basic_format_parse_context<CharT>& ctx)
{
return ctx.begin();
}

typename buffer_context<CharT>::iterator format(const nx::core::BasicStringLiteral<CharT>& p, buffer_context<CharT>& ctx) const
{
static constexpr const CharT* formatStr = GetFormatString();

return fmt::format_to(ctx.out(), formatStr, p.view());
}
};
42 changes: 42 additions & 0 deletions src/simplnx/Common/StringLiteralFormatting.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include "simplnx/Common/StringLiteral.hpp"

#include <fmt/core.h>
#include <fmt/xchar.h>

template <class CharT>
struct fmt::formatter<nx::core::BasicStringLiteral<CharT>>
{
static constexpr const CharT* GetFormatString()
{
if constexpr(std::is_same_v<CharT, char>)
{
return "{}";
}
if constexpr(std::is_same_v<CharT, wchar_t>)
{
return L"{}";
}
if constexpr(std::is_same_v<CharT, char16_t>)
{
return u"{}";
}
if constexpr(std::is_same_v<CharT, char32_t>)
{
return U"{}";
}
}

constexpr typename basic_format_parse_context<CharT>::iterator parse(basic_format_parse_context<CharT>& ctx)
{
return ctx.begin();
}

typename buffer_context<CharT>::iterator format(const nx::core::BasicStringLiteral<CharT>& p, buffer_context<CharT>& ctx) const
{
static constexpr const CharT* formatStr = GetFormatString();

return fmt::format_to(ctx.out(), formatStr, p.view());
}
};
22 changes: 0 additions & 22 deletions src/simplnx/Common/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,4 @@ enum class FaultState
Errors = 2
};

inline const std::set<DataType>& GetAllDataTypes()
{
static const std::set<DataType> 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<DataType>& GetAllNumericTypes()
{
static const std::set<DataType> 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<DataType>& GetIntegerDataTypes()
{
static const std::set<DataType> 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
2 changes: 1 addition & 1 deletion src/simplnx/Common/Uuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>
#include <string_view>

#include <fmt/core.h>
#include <fmt/format.h>

#include "simplnx/Common/Bit.hpp"
#include "simplnx/Common/Types.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/DataStructure/AbstractDataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Filter/Actions/CreateDataGroupAction.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "CreateDataGroupAction.hpp"

#include "simplnx/Common/StringLiteralFormatting.hpp"
#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/DataStructure/LinkedPath.hpp"

Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Filter/Actions/MoveDataAction.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "MoveDataAction.hpp"

#include "simplnx/Common/StringLiteralFormatting.hpp"
#include "simplnx/DataStructure/BaseGroup.hpp"

#include <fmt/core.h>
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Filter/IParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "IParameter.hpp"

#include "simplnx/Common/StringLiteral.hpp"
#include "simplnx/Common/StringLiteralFormatting.hpp"

#include <nlohmann/json.hpp>

Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/ArraySelectionParameter.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/simplnx/Parameters/ArraySelectionParameter.hpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -18,7 +19,7 @@ class SIMPLNX_EXPORT ArraySelectionParameter : public MutableDataParameter
{
public:
using ValueType = DataPath;
using AllowedTypes = std::set<DataType>;
using AllowedTypes = nx::core::DataTypeSetType;
using AllowedComponentShapes = std::vector<IArray::ShapeType>;

enum class DataLocation : uint8
Expand Down
2 changes: 2 additions & 0 deletions src/simplnx/Parameters/BoolParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "BoolParameter.hpp"

#include "simplnx/Common/StringLiteralFormatting.hpp"

#include <fmt/core.h>
#include <nlohmann/json.hpp>

Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/CalculatorParameter.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/ChoicesParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ChoicesParameter.hpp"

#include "simplnx/Common/StringLiteralFormatting.hpp"
#include "simplnx/Utilities/SIMPLConversion.hpp"

#include <fmt/core.h>
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/CreateColorMapParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CreateColorMapParameter.hpp"

#include "simplnx/Common/Any.hpp"
#include "simplnx/Common/StringLiteralFormatting.hpp"
#include "simplnx/util/ColorTable.hpp"

#include <fmt/core.h>
Expand Down
2 changes: 0 additions & 2 deletions src/simplnx/Parameters/CreateColorMapParameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "simplnx/Filter/ValueParameter.hpp"
#include "simplnx/simplnx_export.hpp"

#include <nlohmann/json.hpp>

#include <string>

namespace nx::core
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/DataGroupSelectionParameter.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/DataObjectNameParameter.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/DataPathSelectionParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DataPathSelectionParameter.hpp"

#include "simplnx/Common/Any.hpp"
#include "simplnx/Common/StringLiteralFormatting.hpp"

#include <fmt/core.h>
#include <nlohmann/json.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/simplnx/Parameters/DataTypeParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "DataTypeParameter.hpp"

#include "simplnx/Common/StringLiteralFormatting.hpp"

#include <fmt/core.h>
#include <nlohmann/json.hpp>

Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/Dream3dImportParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fmt/core.h>
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/DynamicTableParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DynamicTableParameter.hpp"

#include "simplnx/Common/Any.hpp"
#include "simplnx/Common/StringLiteralFormatting.hpp"
#include "simplnx/Utilities/StringUtilities.hpp"

#include <fmt/core.h>
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/FileSystemPathParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/GeneratedFileListParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fmt/core.h>
Expand Down
1 change: 1 addition & 0 deletions src/simplnx/Parameters/MultiArraySelectionParameter.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/simplnx/Parameters/MultiArraySelectionParameter.hpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -14,7 +15,7 @@ class SIMPLNX_EXPORT MultiArraySelectionParameter : public MutableDataParameter
public:
using ValueType = std::vector<DataPath>;
using AllowedTypes = std::set<IArray::ArrayType>;
using AllowedDataTypes = std::set<DataType>;
using AllowedDataTypes = nx::core::DataTypeSetType;
using AllowedComponentShapes = std::vector<IArray::ShapeType>;

MultiArraySelectionParameter() = delete;
Expand Down
Loading

0 comments on commit ef1448a

Please sign in to comment.