Skip to content
Snippets Groups Projects
Commit f736df07 authored by Jakob Blomer's avatar Jakob Blomer Committed by Axel Naumann
Browse files

[forest] add support for std::int32_t

parent 49d6c56e
No related branches found
No related tags found
No related merge requests found
......@@ -133,6 +133,15 @@ public:
explicit RColumnElement(double* value) : RColumnElementBase(value, kSize, kIsMappable) {}
};
template <>
class ROOT::Experimental::Detail::RColumnElement<std::int32_t, ROOT::Experimental::EColumnType::kInt32>
: public ROOT::Experimental::Detail::RColumnElementBase {
public:
static constexpr bool kIsMappable = true;
static constexpr size_t kSize = sizeof(std::int32_t);
explicit RColumnElement(std::int32_t* value) : RColumnElementBase(value, kSize, kIsMappable) {}
};
template <>
class ROOT::Experimental::Detail::RColumnElement<std::uint32_t, ROOT::Experimental::EColumnType::kInt32>
: public ROOT::Experimental::Detail::RColumnElementBase {
......
......@@ -471,6 +471,45 @@ public:
size_t GetValueSize() const final { return sizeof(double); }
};
template <>
class ROOT::Experimental::RField<std::int32_t> : public ROOT::Experimental::Detail::RFieldBase {
public:
static std::string MyTypeName() { return "std::int32_t"; }
explicit RField(std::string_view name)
: Detail::RFieldBase(name, MyTypeName(), EForestStructure::kLeaf, true /* isSimple */) {}
RField(RField&& other) = default;
RField& operator =(RField&& other) = default;
~RField() = default;
RFieldBase* Clone(std::string_view newName) final { return new RField(newName); }
void DoGenerateColumns() final;
unsigned int GetNColumns() const final { return 1; }
std::int32_t* Map(ForestSize_t index) {
static_assert(Detail::RColumnElement<std::int32_t, EColumnType::kInt32>::kIsMappable,
"(std::int32_t, EColumnType::kInt32) is not identical on this platform");
return fPrincipalColumn->Map<std::int32_t, EColumnType::kInt32>(index, nullptr);
}
using Detail::RFieldBase::GenerateValue;
template <typename... ArgsT>
ROOT::Experimental::Detail::RFieldValueBase GenerateValue(void* where, ArgsT&&... args)
{
ROOT::Experimental::RFieldValue<std::int32_t> v(
Detail::RColumnElement<std::int32_t, EColumnType::kInt32>(static_cast<std::int32_t*>(where)),
this, static_cast<std::int32_t*>(where), std::forward<ArgsT>(args)...);
return v;
}
ROOT::Experimental::Detail::RFieldValueBase GenerateValue(void* where) final { return GenerateValue(where, 0); }
Detail::RFieldValueBase CaptureValue(void *where) final {
ROOT::Experimental::RFieldValue<std::int32_t> v(true,
Detail::RColumnElement<std::int32_t, EColumnType::kInt32>(static_cast<std::int32_t*>(where)),
this, static_cast<std::int32_t*>(where));
return v;
}
size_t GetValueSize() const final { return sizeof(std::int32_t); }
};
template <>
class ROOT::Experimental::RField<std::uint32_t> : public ROOT::Experimental::Detail::RFieldBase {
public:
......
......@@ -49,10 +49,13 @@ ROOT::Experimental::Detail::RFieldBase::Create(const std::string &fieldName, con
{
std::string normalizedType(typeName);
normalizedType.erase(remove_if(normalizedType.begin(), normalizedType.end(), isspace), normalizedType.end());
if (normalizedType == "Double_t") normalizedType = "double";
if (normalizedType == "Int_t") normalizedType = "std::int32_t";
if (normalizedType == "string") normalizedType = "std::string";
if (normalizedType.substr(0, 7) == "vector<") normalizedType = "std::" + normalizedType;
if (normalizedType == "ROOT::Experimental::ClusterSize_t") return new RField<ClusterSize_t>(fieldName);
if (normalizedType == "std::int32_t") return new RField<std::int32_t>(fieldName);
if (normalizedType == "std::uint32_t") return new RField<std::uint32_t>(fieldName);
if (normalizedType == "float") return new RField<float>(fieldName);
if (normalizedType == "double") return new RField<double>(fieldName);
......@@ -235,6 +238,15 @@ void ROOT::Experimental::RField<double>::DoGenerateColumns()
}
//------------------------------------------------------------------------------
void ROOT::Experimental::RField<std::int32_t>::DoGenerateColumns()
{
RColumnModel model(GetName(), EColumnType::kInt32, false /* isSorted*/);
fColumns.emplace_back(std::make_unique<Detail::RColumn>(model));
fPrincipalColumn = fColumns[0].get();
}
//------------------------------------------------------------------------------
void ROOT::Experimental::RField<std::uint32_t>::DoGenerateColumns()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment