Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: EnumStrings.hpp from codingUtilities to common/format #3267

Merged
merged 47 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e797afb
Merge branch 'develop' into fileIO-refactor-start
MelReyCG Jul 22, 2024
117ff6b
todos
MelReyCG Jul 23, 2024
4e16a41
DataTypes.hpp now only manage static types
MelReyCG Jul 26, 2024
99c20c8
generated files
MelReyCG Jul 26, 2024
d0c8bbb
Merge remote-tracking branch 'origin/develop' into fileIO-refactor-ba…
MelReyCG Jul 26, 2024
008f8e8
sharper todos
MelReyCG Jul 26, 2024
56a4db2
more todo
MelReyCG Jul 26, 2024
fb447b8
removing common -> fileIO
MelReyCG Jul 26, 2024
78afee2
last common->fileIO ref
MelReyCG Jul 26, 2024
675f6a6
removing common->codingUtilities
MelReyCG Jul 26, 2024
ef68fd0
logger has now a dedicated folder for upcoming files (future PRs)
MelReyCG Jul 26, 2024
71d9dbc
🐛 compil fix (dynamicCast)
MelReyCG Jul 29, 2024
e660950
📝 missed docs (where not previously catched by the CI)
MelReyCG Jul 29, 2024
df1be47
🐛 compil fix fix (dynamicCast)
MelReyCG Jul 29, 2024
9bb911a
📝 docs fix
MelReyCG Jul 29, 2024
4388b5d
Merge branch 'develop' into feature/rey/remove-circular-fileIO&common…
MelReyCG Jul 29, 2024
6981b3b
Merge remote-tracking branch 'origin/develop' into feature/rey/remove…
MelReyCG Jul 31, 2024
4084a46
Merge remote-tracking branch 'origin/develop' into feature/rey/remove…
MelReyCG Aug 2, 2024
9cc8eba
Merge branch 'feature/rey/remove-circular-fileIO&common-dependancies'…
MelReyCG Aug 2, 2024
75b6156
Moving EnumStrings.hpp from codingUtilities to common/format
MelReyCG Aug 2, 2024
8d673e6
moving the regex in codingUtilities as it is related to rtTypes / reg…
MelReyCG Aug 2, 2024
bb14d9a
adding docs
MelReyCG Aug 2, 2024
9ab5f99
removing dependency with TypeName<T>
MelReyCG Aug 2, 2024
de439f4
uncrustify
MelReyCG Aug 2, 2024
8950ad2
docs bugfix
MelReyCG Aug 2, 2024
d87eae3
"@example" is not supported?
MelReyCG Aug 19, 2024
d91a573
Merge remote-tracking branch 'origin/develop' into feature/rey/refact…
MelReyCG Aug 19, 2024
355eda6
forgotten impacted files PR ##3278
MelReyCG Aug 20, 2024
50415a4
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Aug 22, 2024
af62b51
removing schema call
MelReyCG Aug 27, 2024
099df43
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Aug 27, 2024
1e2756d
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
rrsettgast Aug 28, 2024
7bb2533
Merge remote-tracking branch 'origin/develop' into feature/rey/refact…
MelReyCG Sep 5, 2024
126a36a
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Sep 9, 2024
40bc327
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Sep 10, 2024
fe036e6
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Sep 11, 2024
757ede1
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Sep 12, 2024
431b3c8
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Sep 25, 2024
f4da742
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Oct 3, 2024
57600ea
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Oct 16, 2024
6c80ad3
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Oct 17, 2024
f6c4a9d
Merge commit 'b43e001aec954f266662b787ea32250b4aaec396' into feature/…
MelReyCG Oct 21, 2024
8f7cb28
merge fix
MelReyCG Oct 21, 2024
e6c1d6d
Merge remote-tracking branch 'origin/develop' into feature/rey/refact…
MelReyCG Nov 8, 2024
7f5220f
generated schema
MelReyCG Nov 8, 2024
a5b55c9
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Nov 8, 2024
9a6a78b
Merge branch 'develop' into feature/rey/refactor-stringenums-to-common
MelReyCG Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/coreComponents/codingUtilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Specify all headers
#
set( codingUtilities_headers
EnumStrings.hpp
RTTypes.hpp
Parsing.hpp
SFINAE_Macros.hpp
Expand Down
26 changes: 25 additions & 1 deletion src/coreComponents/codingUtilities/RTTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define GEOS_CODINGUTILITIES_RTTYPES_HPP

#include "common/DataTypes.hpp"
#include "common/format/EnumStrings.hpp"
#include "common/format/Format.hpp"
#include "common/logger/Logger.hpp"

Expand Down Expand Up @@ -232,7 +233,30 @@ struct TypeName
}
};

}
/**
* @brief Base types TypeRegex specializations
*/
///@{

/**
* @brief Specialization of TypeRegex for enumeration types with strings attached (pun intended).
* @tparam ENUM the type of enumeration
*/
template< typename ENUM >
struct TypeRegex< ENUM, std::enable_if_t< internal::HasEnumStrings< ENUM > > >
{
/**
* @brief @return Regex for validating enumeration inputs for @p ENUM type.
*/
static Regex get()
{
return Regex( EnumStrings< ENUM >::concat( "|" ),
"Input value must be one of { " + EnumStrings< ENUM >::concat( ", " ) + " }." );
}
};

///@}

}

#endif /* GEOS_CODINGUTILITIES_RTTYPES_HPP */
1 change: 1 addition & 0 deletions src/coreComponents/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set( common_headers
format/table/TableLayout.hpp
format/table/TableFormatter.hpp
format/table/TableData.hpp
format/EnumStrings.hpp
format/Format.hpp
format/StringUtilities.hpp
logger/Logger.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
* of these strings, like stream insertion/extraction operators.
*/

#ifndef GEOS_CODINGUTILITIES_ENUMSTRINGS_HPP
#define GEOS_CODINGUTILITIES_ENUMSTRINGS_HPP
#ifndef GEOS_COMMON_FORMAT_ENUMSTRINGS_HPP
#define GEOS_COMMON_FORMAT_ENUMSTRINGS_HPP

#include "common/format/StringUtilities.hpp"
#include "codingUtilities/RTTypes.hpp"
// #include "codingUtilities/RTTypes.hpp"
#include "common/DataTypes.hpp"
#include "common/logger/Logger.hpp"
#include "common/format/Format.hpp"
Expand Down Expand Up @@ -66,6 +66,15 @@ constexpr int countArgs( ARGS ... )
* may be used to get access to strings at runtime. While not strictly necessary,
* it is recommended that macro call immediately follows the enum definition
* (or the class definition, if enum is defined inside a class).
*
* enum struct VTKOutputMode
* {
* BINARY,
* ASCII
* };
* ENUM_STRINGS( VTKOutputMode,
* "binary",
* "ascii" );
*/
#define ENUM_STRINGS( ENUM, ... ) \
inline auto const & getEnumStrings( ENUM const ) \
Expand All @@ -74,6 +83,11 @@ constexpr int countArgs( ARGS ... )
return ss; \
} \
\
inline auto const & getEnumTypeNameString( ENUM const ) \
{ \
return #ENUM; \
} \
\
inline std::ostream & operator<<( std::ostream & os, ENUM const e ) \
{ \
os << EnumStrings< ENUM >::toString( e ); \
Expand Down Expand Up @@ -139,7 +153,7 @@ struct EnumStrings
std::size_t size = std::distance( std::begin( strings ), std::end( strings ) );
base_type const index = static_cast< base_type >( e );
GEOS_THROW_IF( index >= LvArray::integerConversion< base_type >( size ),
"Invalid value " << index << " of type " << TypeName< ENUM >::brief() << ". Valid range is 0.." << size - 1,
"Invalid value " << index << " of type " << getEnumTypeNameString( enum_type{} ) << ". Valid range is 0.." << size - 1,
InputError );
return strings[ index ];
}
Expand All @@ -154,7 +168,7 @@ struct EnumStrings
auto const & strings = get();
auto const it = std::find( std::begin( strings ), std::end( strings ), s );
GEOS_THROW_IF( it == std::end( strings ),
"Invalid value '" << s << "' of type " << TypeName< enum_type >::brief() << ". Valid options are: " << concat( ", " ),
"Invalid value '" << s << "' of type " << getEnumTypeNameString( enum_type{} ) << ". Valid options are: " << concat( ", " ),
InputError );
enum_type const e = static_cast< enum_type >( LvArray::integerConversion< base_type >( std::distance( std::begin( strings ), it ) ) );
return e;
Expand All @@ -166,23 +180,6 @@ namespace internal
IS_VALID_EXPRESSION( HasEnumStrings, ENUM, getEnumStrings( std::declval< ENUM >() ) );
}

/**
* @brief Specialization of TypeRegex for enumeration types with strings attached (pun intended).
* @tparam ENUM the type of enumeration
*/
template< typename ENUM >
struct TypeRegex< ENUM, std::enable_if_t< internal::HasEnumStrings< ENUM > > >
{
/**
* @brief @return Regex for validating enumeration inputs for @p ENUM type.
*/
static Regex get()
{
return Regex( EnumStrings< ENUM >::concat( "|" ),
"Input value must be one of { " + EnumStrings< ENUM >::concat( ", " ) + " }." );
}
};

} // namespace geos

// Formatter specialization for enums
Expand All @@ -209,4 +206,4 @@ struct GEOS_FMT_NS::formatter< Enum, std::enable_if_t< std::is_enum< Enum >::val
}
};

#endif //GEOS_CODINGUTILITIES_ENUMSTRINGS_HPP
#endif //GEOS_COMMON_FORMAT_ENUMSTRINGS_HPP
2 changes: 1 addition & 1 deletion src/coreComponents/constitutive/ExponentialRelation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define GEOS_CONSITUTIVE_EXPONENTIALRELATION_HPP_

#include "common/DataTypes.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

#include <cmath>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "constitutive/capillaryPressure/CapillaryPressureBase.hpp"

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "functions/TableFunction.hpp"

namespace geos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_CO2BRINE_CO2BRINEFLUID_HPP_
#define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_CO2BRINE_CO2BRINEFLUID_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
#include "constitutive/fluid/multifluid/MultiFluidUtils.hpp"
#include "constitutive/fluid/multifluid/CO2Brine/PhaseModel.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "ModelParameters.hpp"
#include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
#include "dataRepository/InputFlags.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "FunctionBase.hpp"

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_CONSTITUTIVE_FLUID_REACTIVEBRINEFLUID_HPP_
#define GEOS_CONSTITUTIVE_FLUID_REACTIVEBRINEFLUID_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "constitutive/fluid/multifluid/reactive/ReactiveMultiFluid.hpp"
#include "constitutive/fluid/multifluid/MultiFluidUtils.hpp"
#include "constitutive/fluid/multifluid/CO2Brine/PhaseModel.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_REACTIVE_REACTIVEMULTIFLUID_HPP_


#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
#include "constitutive/fluid/multifluid/reactive/chemicalReactions/EquilibriumReactions.hpp"
#include "constitutive/fluid/multifluid/reactive/chemicalReactions/KineticReactions.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_CONSTITUTIVE_FLUID_SINGLEFLUID_PARTICLEFLUID_HPP_
#define GEOS_CONSTITUTIVE_FLUID_SINGLEFLUID_PARTICLEFLUID_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "constitutive/fluid/singlefluid/ParticleFluidBase.hpp"

namespace geos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "constitutive/ConstitutiveBase.hpp"
#include "constitutive/relativePermeability/layouts.hpp"
#include "common/GEOS_RAJA_Interface.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/dataRepository/ExecutableGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_DATAREPOSITORY_EXECUTABLEGROUP_HPP_
#define GEOS_DATAREPOSITORY_EXECUTABLEGROUP_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "common/DataTypes.hpp"
#include "Group.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <gtest/gtest.h>

#include "dataRepository/xmlWrapper.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

using namespace geos;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "dataRepository/Wrapper.hpp"
#include "fileIO/vtk/VTKPVDWriter.hpp"
#include "fileIO/vtk/VTKVTMWriter.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

class vtkUnstructuredGrid;
class vtkPointData;
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/finiteElement/PDEUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_FINITEELEMENT_PDEUTILITIES_HPP_
#define GEOS_FINITEELEMENT_PDEUTILITIES_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "FunctionBase.hpp"

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "LvArray/src/tensorOps.hpp"

namespace geos
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/functions/TableFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "FunctionBase.hpp"

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "LvArray/src/tensorOps.hpp"
#include "common/format/table/TableFormatter.hpp"
#include "common/Units.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_LINEARALGEBRA_UTILITIES_LINEARSOLVERPARAMETERS_HPP_
#define GEOS_LINEARALGEBRA_UTILITIES_LINEARSOLVERPARAMETERS_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/ElementType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_MESH_ELEMENTTYPE_HPP
#define GEOS_MESH_ELEMENTTYPE_HPP

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/MeshObjectPath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define GEOS_MESH_MESHOBJECTPATH_HPP_


#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "MeshLevel.hpp"

namespace geos
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/ParticleType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_MESH_PARTICLETYPE_HPP
#define GEOS_MESH_PARTICLETYPE_HPP

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/SurfaceElementRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define GEOS_MESH_SURFACEELEMENTREGION_HPP_

#include "ElementRegionBase.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_MESH_GENERATORS_INTERNALMESHGENERATOR_HPP
#define GEOS_MESH_GENERATORS_INTERNALMESHGENERATOR_HPP

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "mesh/generators/MeshGeneratorBase.hpp"
#include "mesh/generators/CellBlockManager.hpp"
#include "mesh/mpiCommunications/SpatialPartition.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_MESHUTILITIES_INTERNALWELLBOREGENERATOR_HPP
#define GEOS_MESHUTILITIES_INTERNALWELLBOREGENERATOR_HPP

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "dataRepository/Group.hpp"
#include "InternalMeshGenerator.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "mesh/generators/MeshGeneratorBase.hpp"

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef GEOS_PHYSICSSOLVERS_NONLINEARSOLVERPARAMETERS_HPP_
#define GEOS_PHYSICSSOLVERS_NONLINEARSOLVERPARAMETERS_HPP_

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "dataRepository/Group.hpp"
#include "physicsSolvers/PhysicsSolverBaseKernels.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef GEOS_PHYSICSSOLVERS_SOLVERBASEKERNELS_HPP
#define GEOS_PHYSICSSOLVERS_SOLVERBASEKERNELS_HPP

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "common/DataTypes.hpp"
#include "common/MpiWrapper.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define GEOS_PHYSICSSOLVERS_CONTACT_CONTACTFIELDS_HPP_

#include "mesh/MeshFields.hpp"
#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"

namespace geos
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
#define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP

#include "codingUtilities/EnumStrings.hpp"
#include "common/format/EnumStrings.hpp"
#include "dataRepository/Group.hpp"
#include "functions/TableFunction.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef GEOS_PHYSICSSOLVERS_SIMPLEPDE_LAPLACE_BASE_HPP
#define GEOS_PHYSICSSOLVERS_SIMPLEPDE_LAPLACE_BASE_HPP

#include "codingUtilities/EnumStrings.hpp" // facilities for enum-string conversion (for reading enum values from XML input)
#include "common/format/EnumStrings.hpp" // facilities for enum-string conversion (for reading enum values from XML input)
#include "physicsSolvers/PhysicsSolverBase.hpp" // an abstraction class shared by all physics solvers
#include "fieldSpecification/FieldSpecificationManager.hpp" // a manager that can access and set values on the discretized domain

Expand Down
Loading
Loading