Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions share/multiom/generate_knowledge/GenerateCPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ def generateCPPEnumForCategory(categories, categoryName, setOfValues, namespace)
}}
}};

template <>
struct TypeToString<{namespace}::{enumName}> {{
std::string operator()() const {{ return "{namespace}::{enumName}"; }};
}};

}} // namespace multio::util


Expand Down Expand Up @@ -180,10 +175,6 @@ def generateCPPPDTCatRecord(
template<>
struct Print<{namespace}::{pdtCatName}>: multio::datamod::PrintRecord {{}};

template <>
struct TypeToString<{namespace}::{pdtCatName}> {{
std::string operator()() const {{ return "{namespace}::{pdtCatName}"; }};
}};
}}
"""

Expand Down Expand Up @@ -336,7 +327,6 @@ def filterSelector(sel):

#include "multio/util/Hash.h"
#include "multio/util/TypeTraits.h"
#include "multio/util/TypeToString.h"
#include "multio/util/Print.h"

#include "multio/datamod/core/EntryDef.h"
Expand Down
31 changes: 14 additions & 17 deletions src/multio/datamod/core/EntryDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
// Definitions to describe key-value pairs
//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

/// \defgroup datamod_core_entrydef EntryDef
/// \ingroup datamod_core
Expand Down Expand Up @@ -102,9 +102,9 @@ namespace multio::datamod {
// Forward declaration
enum class EntryTag : std::uint64_t
{
Required, // Strictly required and can not be defaulted or conditionally depending on other keys
Defaulted, // Can be missing after reading from container but then may be defaulted through a custom alter function
Optional, // Can be missing after validation
Required, // Strictly required and can not be defaulted or conditionally depending on other keys
Defaulted, // Can be missing after reading from container but then may be defaulted through a custom alter function
Optional, // Can be missing after validation
Disallowed, // Must be missing after validation
};

Expand Down Expand Up @@ -235,10 +235,7 @@ struct BaseEntryDef {

const std::optional<std::string_view>& description() const noexcept { return description_; }

std::string keyInfo() const {
return std::string(key()) + std::string(" (") + util::typeToString<ValueType>() + std::string(", ")
+ toString(tag) + std::string{")"};
}
std::string keyInfo() const { return std::string(key()) + std::string(" (") + toString(tag) + std::string{")"}; }

// Functions to create Entries

Expand Down Expand Up @@ -461,7 +458,7 @@ struct EntryDef : BaseEntryDef<ValueType_, Mapper_, tag_> {
};


//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

template <typename T>
struct IsBaseEntryDefinition : std::false_type {};
Expand All @@ -475,7 +472,7 @@ inline constexpr bool IsBaseEntryDefinition_v = IsBaseEntryDefinition<T>::value;
// template <typename T>
// concept BaseEntryDefinitionType = IsBaseEntryDefinition<std::remove_cvref_t<T>>::value;

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

template <typename T>
struct IsEntryDefinition : std::false_type {};
Expand All @@ -489,15 +486,15 @@ inline constexpr bool IsEntryDefinition_v = IsEntryDefinition<T>::value;
// template <typename T>
// concept EntryDefinitionType = IsEntryDefinition<std::remove_cvref_t<T>>::value;

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

template <typename T>
using EntryType_t = typename std::decay_t<T>::EntryType;

template <typename T>
using EntryValueType_t = typename std::decay_t<T>::ValueType;

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

/// Implicit EntryDefs are the usual way how to use "reflections" to model data structures.
/// However, given that in ECMWF MARS and GRIB keys are are often used key by key, there is a need
Expand All @@ -508,7 +505,7 @@ using EntryValueType_t = typename std::decay_t<T>::ValueType;

template <typename T, typename M>
struct PointerToMemberAccessor {
M T::*member;
M T::* member;

template <typename U>
decltype(auto) operator()(U&& obj) const {
Expand All @@ -518,7 +515,7 @@ struct PointerToMemberAccessor {
};

template <typename T, typename M>
constexpr auto entryDef(std::string_view key, M T::*member) {
constexpr auto entryDef(std::string_view key, M T::* member) {
static_assert(IsEntry_v<M>);
using ValueType = typename M::ValueType;
using Mapper = typename M::Mapper;
Expand All @@ -527,7 +524,7 @@ constexpr auto entryDef(std::string_view key, M T::*member) {
}


//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

// NOTE: This may be removed once the metadata is cleaned up again. We probably will use nested metadata instead of
// having prefixes (too cumbersome)
Expand Down Expand Up @@ -644,6 +641,6 @@ ScopedEntryDef<EntryDef_> scopedEntryDef(const EntryDef_& entryDef, const std::s
template <typename EntryDef_>
struct IsEntryDefinition<ScopedEntryDef<EntryDef_>> : std::true_type {};

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

} // namespace multio::datamod
1 change: 0 additions & 1 deletion src/multio/datamod/types/LevType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,3 @@ void util::Print<datamod::LevType>::print(PrintStream& ps, const datamod::LevTyp
}

} // namespace multio::util

10 changes: 1 addition & 9 deletions src/multio/datamod/types/LevType.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
#include "multio/datamod/core/TypeParserDumper.h"

#include "multio/util/Print.h"
#include "multio/util/TypeToString.h"



namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------


// To be renamed and kept internal -
Expand Down Expand Up @@ -55,11 +53,6 @@ struct Print<datamod::LevType> {
static void print(PrintStream& ps, const datamod::LevType& v);
};

template <>
struct TypeToString<datamod::LevType> {
std::string operator()() const { return "datamod::LevType"; };
};

} // namespace multio::util

namespace multio::datamod {
Expand All @@ -77,4 +70,3 @@ struct ParseType<LevType> {


} // namespace multio::datamod

9 changes: 1 addition & 8 deletions src/multio/datamod/types/Repres.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
#include "multio/datamod/core/TypeParserDumper.h"

#include "multio/util/Print.h"
#include "multio/util/TypeToString.h"

#include <string>


namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

// To be renamed and kept internal -
enum class Repres : std::size_t
Expand All @@ -42,11 +41,6 @@ struct Print<datamod::Repres> {
static void print(PrintStream& ps, const datamod::Repres& v);
};

template <>
struct TypeToString<datamod::Repres> {
std::string operator()() const { return "datamod::Repres"; };
};

} // namespace multio::util

namespace multio::datamod {
Expand All @@ -66,4 +60,3 @@ struct ParseType<Repres> {
Repres represFromGrid(const std::string& grid);

} // namespace multio::datamod

1 change: 0 additions & 1 deletion src/multio/datamod/types/StatType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,3 @@ void util::Print<datamod::StatType>::print(PrintStream& ps, const datamod::StatT
}

} // namespace multio::util

9 changes: 1 addition & 8 deletions src/multio/datamod/types/StatType.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

#include "multio/util/Hash.h"
#include "multio/util/Print.h"
#include "multio/util/TypeToString.h"


namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------


enum class StatTypeDuration : std::size_t
Expand Down Expand Up @@ -98,11 +97,6 @@ struct Print<datamod::StatType> {
static void print(PrintStream& ps, const datamod::StatType& v);
};

template <>
struct TypeToString<datamod::StatType> {
std::string operator()() const { return "datamod::StatType"; };
};

} // namespace multio::util

namespace multio::datamod {
Expand Down Expand Up @@ -156,4 +150,3 @@ struct ParseType<StatType> {


} // namespace multio::datamod

1 change: 0 additions & 1 deletion src/multio/datamod/types/TimeDuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,3 @@ void util::Print<datamod::TimeDuration>::print(PrintStream& ps, const datamod::T


} // namespace multio::util

11 changes: 2 additions & 9 deletions src/multio/datamod/types/TimeDuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "multio/util/Hash.h"
#include "multio/util/Print.h"
#include "multio/util/TypeToString.h"

#include <chrono>
#include <string>
Expand All @@ -23,7 +22,7 @@

namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

using IntOrString = std::variant<std::int64_t, std::string>;

Expand Down Expand Up @@ -70,7 +69,7 @@ struct variant_alternative<I, multio::datamod::TimeDuration>
: variant_alternative<I, multio::datamod::TimeDurationVariant> {};
} // namespace std

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

namespace multio::util {

Expand All @@ -79,12 +78,6 @@ struct Print<datamod::TimeDuration> {
static void print(PrintStream& ps, const datamod::TimeDuration& v);
};


template <>
struct TypeToString<datamod::TimeDuration> {
std::string operator()() const { return "datamod::TimeDuration"; };
};

} // namespace multio::util

namespace multio::datamod {
Expand Down
1 change: 0 additions & 1 deletion src/multio/datamod/types/TypeOfLevel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,3 @@ void util::Print<datamod::TypeOfLevel>::print(PrintStream& ps, const datamod::Ty
}

} // namespace multio

8 changes: 1 addition & 7 deletions src/multio/datamod/types/TypeOfLevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

#include "multio/datamod/core/TypeParserDumper.h"
#include "multio/util/Print.h"
#include "multio/util/TypeToString.h"


namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------


enum class TypeOfLevel : std::size_t
Expand Down Expand Up @@ -132,10 +131,6 @@ struct Print<datamod::TypeOfLevel> {
static void print(PrintStream&, const datamod::TypeOfLevel&);
};

template <>
struct TypeToString<datamod::TypeOfLevel> {
std::string operator()() const { return "datamod::TypeOfLevel"; };
};
} // namespace multio::util

namespace multio::datamod {
Expand All @@ -154,4 +149,3 @@ struct ParseType<TypeOfLevel> {


} // namespace multio::datamod

1 change: 0 additions & 1 deletion src/multio/datamod/types/TypeOfStatisticalProcessing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,3 @@ void util::Print<datamod::TypeOfStatisticalProcessing>::print(PrintStream& ps,
}

} // namespace multio

8 changes: 1 addition & 7 deletions src/multio/datamod/types/TypeOfStatisticalProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

#include "multio/datamod/core/TypeParserDumper.h"
#include "multio/util/Print.h"
#include "multio/util/TypeToString.h"


namespace multio::datamod {

//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------

// TypeOfStatisticalProcessing defined with official integer representation in GRIB 4.10 code table
// https://codes.ecmwf.int/grib/format/grib2/ctables/4/10/
Expand Down Expand Up @@ -52,10 +51,6 @@ struct Print<datamod::TypeOfStatisticalProcessing> {
static void print(PrintStream&, const datamod::TypeOfStatisticalProcessing&);
};

template <>
struct TypeToString<datamod::TypeOfStatisticalProcessing> {
std::string operator()() const { return "datamod::TypeOfStatisticalProcessing"; };
};
} // namespace multio::util


Expand All @@ -81,4 +76,3 @@ struct ParseType<TypeOfStatisticalProcessing> {


} // namespace multio::datamod

6 changes: 3 additions & 3 deletions src/multio/mars2grib/EncoderCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class EncoderCache {
std::unique_ptr<util::MioGribHandle> preparedSample;
};

CacheEntry& makeOrGetEntry(const dm::FullMarsRecord& marsKeys, const MultIOMDict& marsDict, const MultIOMDict& parDict,
const MultIOMDict& geoDict);
CacheEntry& makeOrGetEntry(const dm::FullMarsRecord& marsKeys, const MultIOMDict& marsDict,
const MultIOMDict& parDict, const MultIOMDict& geoDict);

std::unordered_map<PrehashedMarsKeys, CacheEntry> cache_{};
};


//---------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------


} // namespace multio::mars2grib
Loading
Loading