Skip to content

Commit

Permalink
Add DataTypeUtilities class.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Sep 10, 2024
1 parent e8e6b91 commit 0b8dc45
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/Utilities/ClusteringUtilities.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/MontageUtilities.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/SIMPLConversion.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/DataTypeUtilities.hpp

${SIMPLNX_SOURCE_DIR}/Utilities/Math/GeometryMath.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.hpp
Expand Down Expand Up @@ -720,6 +721,7 @@ set(SIMPLNX_SRCS
${SIMPLNX_SOURCE_DIR}/Utilities/SampleSurfaceMesh.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/MontageUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/TimeUtilities.cpp
${SIMPLNX_SOURCE_DIR}/Utilities/DataTypeUtilities.cpp

${SIMPLNX_SOURCE_DIR}/Utilities/Parsing/DREAM3D/Dream3dIO.cpp

Expand Down
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
3 changes: 2 additions & 1 deletion src/simplnx/Parameters/ArraySelectionParameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "simplnx/DataStructure/IArray.hpp"
#include "simplnx/Filter/MutableDataParameter.hpp"
#include "simplnx/Filter/ParameterTraits.hpp"
#include "simplnx/Utilities/DataTypeUtilities.hpp"
#include "simplnx/simplnx_export.hpp"

#include <set>
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
3 changes: 2 additions & 1 deletion src/simplnx/Parameters/MultiArraySelectionParameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "simplnx/DataStructure/IArray.hpp"
#include "simplnx/Filter/MutableDataParameter.hpp"
#include "simplnx/Filter/ParameterTraits.hpp"
#include "simplnx/Utilities/DataTypeUtilities.hpp"

namespace nx::core
{
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
28 changes: 28 additions & 0 deletions src/simplnx/Utilities/DataTypeUtilities.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#include "DataTypeUtilities.hpp"

namespace nx::core
{
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;
}

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;
}

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
28 changes: 28 additions & 0 deletions src/simplnx/Utilities/DataTypeUtilities.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "simplnx/Common/Types.hpp"
#include "simplnx/simplnx_export.hpp"

#include <set>

namespace nx::core
{

using DataTypeSetType = std::set<DataType>;

/**
* @brief
*/
SIMPLNX_EXPORT const DataTypeSetType& GetAllDataTypes();

/**
* @brief
*/
SIMPLNX_EXPORT const DataTypeSetType& GetAllNumericTypes();

/**
* @brief
*/
SIMPLNX_EXPORT const DataTypeSetType& GetIntegerDataTypes();

}; // namespace nx::core
2 changes: 1 addition & 1 deletion test/DataArrayTest.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#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"
#include "simplnx/Core/Application.hpp"

#include <catch2/catch.hpp>

Expand Down

0 comments on commit 0b8dc45

Please sign in to comment.