src/DataManager/utils/TableView/columns/ColumnTypeInfo.hpp
src/DataManager/utils/TableView/columns/ColumnTypeInfo.hpp
Classes
| Name | |
|---|---|
| struct | ColumnTypeInfo Runtime type information for table columns. |
| class | ColumnDataVisitor Visitor pattern for type-safe column data access. |
Types
| Name | |
|---|---|
| using std::tuple< float, double, int, int64_t, bool, std::vector< float >, std::vector< double >, std::vector< int >, std::vector< TimeFrameIndex > > | SupportedColumnElementTypes |
| using std::tuple< std::vector< float >, std::vector< double >, std::vector< int >, std::vector< int64_t >, std::vector< bool >, std::vector< TimeFrameIndex >, std::vector< std::vector< float > >, std::vector< std::vector< double > >, std::vector< std::vector< int > >, std::vector< std::vector< TimeFrameIndex > > > | SupportedColumnDataTypes |
| using SupportedColumnElementTypes | SupportedColumnTypes |
| using tuple_to_variant_t< SupportedColumnDataTypes > | ColumnDataVariant Variant type containing all possible column data types that TableView can return. |
| using tuple_to_variant_t< SupportedColumnElementTypes > | ColumnElementVariant |
Functions
| Name | |
|---|---|
| ColumnTypeInfo | ColumnTypeInfo::createTypeInfo< std::vector< float > >() |
| ColumnTypeInfo | ColumnTypeInfo::createTypeInfo< std::vector< double > >() |
| ColumnTypeInfo | ColumnTypeInfo::createTypeInfo< std::vector< int > >() |
| ColumnTypeInfo | ColumnTypeInfo::createTypeInfo< std::vector< TimeFrameIndex > >() |
| ColumnTypeInfo | ColumnTypeInfo::createTypeInfo< std::vector< bool > >() |
| template <typename Visitor > auto |
visitColumnData(ColumnDataVariant const & variant, Visitor && visitor) Apply a visitor to a ColumnDataVariant. |
Types Documentation
using SupportedColumnElementTypes
using SupportedColumnElementTypes = std::tuple<
float,
double,
int,
int64_t,
bool,
std::vector<float>,
std::vector<double>,
std::vector<int>,
std::vector<TimeFrameIndex>>;using SupportedColumnDataTypes
using SupportedColumnDataTypes = std::tuple<
std::vector<float>,
std::vector<double>,
std::vector<int>,
std::vector<int64_t>,
std::vector<bool>,
std::vector<TimeFrameIndex>,
std::vector<std::vector<float>>,
std::vector<std::vector<double>>,
std::vector<std::vector<int>>,
std::vector<std::vector<TimeFrameIndex>>>;using SupportedColumnTypes
using SupportedColumnTypes = SupportedColumnElementTypes;using ColumnDataVariant
using ColumnDataVariant = tuple_to_variant_t<SupportedColumnDataTypes>;Variant type containing all possible column data types that TableView can return.
This variant represents the complete set of types that getColumnDataVariant() can return. These are always vectors since getColumnValues
using ColumnElementVariant
using ColumnElementVariant = tuple_to_variant_t<SupportedColumnElementTypes>;Functions Documentation
function ColumnTypeInfo::createTypeInfo< std::vector< float > >
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo< std::vector< float > >()function ColumnTypeInfo::createTypeInfo< std::vector< double > >
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo< std::vector< double > >()function ColumnTypeInfo::createTypeInfo< std::vector< int > >
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo< std::vector< int > >()function ColumnTypeInfo::createTypeInfo< std::vector< TimeFrameIndex > >
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo< std::vector< TimeFrameIndex > >()function ColumnTypeInfo::createTypeInfo< std::vector< bool > >
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo< std::vector< bool > >()function visitColumnData
template <typename Visitor >
auto visitColumnData(
ColumnDataVariant const & variant,
Visitor && visitor
)Apply a visitor to a ColumnDataVariant.
Parameters:
- variant The column data variant
- visitor The visitor instance
Template Parameters:
- Visitor The visitor type
Return: The result of the visitor
Source code
#ifndef COLUMNTYPEINFO_HPP
#define COLUMNTYPEINFO_HPP
#include "TimeFrame/TimeFrameIndex.hpp"
#include "CoreUtilities/metaprogramming_utils.hpp"
#include <string>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <variant>
#include <vector>
// ==========================================
// Supported tableview column data types
// ==========================================
// Element types that can be stored in columns (what each row contains)
using SupportedColumnElementTypes = std::tuple<
float,
double,
int,
int64_t,
bool,
std::vector<float>,
std::vector<double>,
std::vector<int>,
std::vector<TimeFrameIndex>>;
// Data types that getColumnDataVariant() can return (always vectors)
using SupportedColumnDataTypes = std::tuple<
std::vector<float>,
std::vector<double>,
std::vector<int>,
std::vector<int64_t>,
std::vector<bool>,
std::vector<TimeFrameIndex>,
std::vector<std::vector<float>>,
std::vector<std::vector<double>>,
std::vector<std::vector<int>>,
std::vector<std::vector<TimeFrameIndex>>>;
// Backward compatibility alias
using SupportedColumnTypes = SupportedColumnElementTypes;
template<typename T>
concept SupportedColumnType = is_in_tuple_v<T, SupportedColumnTypes>;
using ColumnDataVariant = tuple_to_variant_t<SupportedColumnDataTypes>;
using ColumnElementVariant = tuple_to_variant_t<SupportedColumnElementTypes>;
struct ColumnTypeInfo {
std::type_index actualType;
std::type_index elementType;
bool isVectorType;
bool isNestedVector;
std::string typeName;
std::string elementTypeName;
ColumnTypeInfo()
: actualType(typeid(void)),
elementType(typeid(void)),
isVectorType(false),
isNestedVector(false),
typeName("void"),
elementTypeName("void") {}
ColumnTypeInfo(std::type_index actual_type, std::type_index element_type,
bool is_vector, bool is_nested,
std::string type_name, std::string element_name)
: actualType(actual_type),
elementType(element_type),
isVectorType(is_vector),
isNestedVector(is_nested),
typeName(std::move(type_name)),
elementTypeName(std::move(element_name)) {}
template<typename T>
static ColumnTypeInfo fromType() {
return createTypeInfo<T>();
}
template<typename T>
bool isType() const {
return actualType == typeid(T);
}
template<typename T>
bool hasElementType() const {
return elementType == typeid(T);
}
private:
template<typename T>
static ColumnTypeInfo createTypeInfo();
};
// Template specializations for createTypeInfo
// Scalar types (Column<T> where each row contains one T value)
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<float>() {
return ColumnTypeInfo(typeid(float), typeid(float),
false, false, "float", "float");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<double>() {
return ColumnTypeInfo(typeid(double), typeid(double),
false, false, "double", "double");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<int>() {
return ColumnTypeInfo(typeid(int), typeid(int),
false, false, "int", "int");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<int64_t>() {
return ColumnTypeInfo(typeid(int64_t), typeid(int64_t),
false, false, "int64_t", "int64_t");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<bool>() {
return ColumnTypeInfo(typeid(bool), typeid(bool),
false, false, "bool", "bool");
}
// Vector types (Column<std::vector<T>> where each row contains a vector of T values)
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<std::vector<float>>() {
return ColumnTypeInfo(typeid(std::vector<float>), typeid(float),
true, false, "std::vector<float>", "float");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<std::vector<double>>() {
return ColumnTypeInfo(typeid(std::vector<double>), typeid(double),
true, false, "std::vector<double>", "double");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<std::vector<int>>() {
return ColumnTypeInfo(typeid(std::vector<int>), typeid(int),
true, false, "std::vector<int>", "int");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<std::vector<TimeFrameIndex>>() {
return ColumnTypeInfo(typeid(std::vector<TimeFrameIndex>), typeid(TimeFrameIndex),
true, false, "std::vector<TimeFrameIndex>", "TimeFrameIndex");
}
template<>
inline ColumnTypeInfo ColumnTypeInfo::createTypeInfo<std::vector<bool>>() {
return ColumnTypeInfo(typeid(std::vector<bool>), typeid(bool),
true, false, "std::vector<bool>", "bool");
}
template<typename ReturnType = void>
class ColumnDataVisitor {
public:
virtual ~ColumnDataVisitor() = default;
// Scalar types
virtual ReturnType visit(float const & data) = 0;
virtual ReturnType visit(double const & data) = 0;
virtual ReturnType visit(int const & data) = 0;
virtual ReturnType visit(int64_t const & data) = 0;
virtual ReturnType visit(bool const & data) = 0;
// Vector types
virtual ReturnType visit(std::vector<float> const & data) = 0;
virtual ReturnType visit(std::vector<double> const & data) = 0;
virtual ReturnType visit(std::vector<int> const & data) = 0;
virtual ReturnType visit(std::vector<TimeFrameIndex> const & data) = 0;
};
template<typename Visitor>
auto visitColumnData(ColumnDataVariant const & variant, Visitor && visitor) {
return std::visit(std::forward<Visitor>(visitor), variant);
}
#endif// COLUMNTYPEINFO_HPPUpdated on 2026-11-13 at 20:25:43 +0000