26#ifndef PDI_SCALAR_DATATYPE_H_
27#define PDI_SCALAR_DATATYPE_H_
33#include <pdi/pdi_fwd.h>
34#include <pdi/datatype.h>
41 struct Shared_enabler;
56 std::function<
void* (
void*,
const void*) > m_copy;
59 std::function<void(
void*) > m_destroy;
62 static std::shared_ptr<Scalar_datatype>
const cv_type_for_v;
67 if constexpr (std::is_integral<T>::value) {
68 if constexpr (std::is_signed<T>::value) {
69 return Scalar_kind::SIGNED;
71 return Scalar_kind::UNSIGNED;
72 }
else if constexpr (std::is_floating_point<T>::value) {
73 return Scalar_kind::FLOAT;
75 return Scalar_kind::UNKNOWN;
80 static constexpr auto kind_of_v = kind_of<std::remove_cv_t<T>>();
83 static constexpr auto const& type_for_v = cv_type_for_v<std::remove_cv_t<T>>;
145 std::function<
void* (
void*,
const void*) > copy,
146 std::function<
void(
void*) > destroy,
147 const Attributes_map& attributes = {}
178 static std::shared_ptr<Scalar_datatype>
make(
183 std::function<
void* (
void*,
const void*) > copy,
184 std::function<
void(
void*) > destroy,
191extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint8_t>;
193extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint16_t>;
195extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint32_t>;
197extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint64_t>;
199extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int8_t>;
201extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int16_t>;
203extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int32_t>;
205extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int64_t>;
207extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<bool>;
209extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<float>;
211extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<double>;
A Datatype is a Datatype_template that accepts no argument.
Definition: datatype.h:47
Definition: scalar_datatype.h:39
Datatype_sptr densify() const override
Creates a new datatype as the dense copy of this one.
void * data_from_dense_copy(void *to, const void *from) const override
Creates a sparse deep copy of dense data.
void destroy_data(void *ptr) const override
Delete data whose type is described by the Datatype.
size_t alignment() const override
Returns the required alignment for a type.
Scalar_kind kind() const
Interpretation of the content.
std::string debug_string() const override
Returns the datatype yaml representation as a string.
void * data_to_dense_copy(void *to, const void *from) const override
Creates a dense deep copy of data.
size_t buffersize() const override
Computes the data size of a type, including potentially unused memory from a sparse type.
static std::shared_ptr< Scalar_datatype > make(Scalar_kind kind, size_t size, const Attributes_map &attributes={})
Creates new scalar datatype.
bool dense() const override
Indicate if the datatype is dense or not.
static std::shared_ptr< Scalar_datatype > make(Scalar_kind kind, size_t size, size_t align, size_t dense_size, std::function< void *(void *, const void *) > copy, std::function< void(void *) > destroy, const Attributes_map &attributes={})
Creates new scalar datatype.
static std::shared_ptr< Scalar_datatype > make(Scalar_kind kind, size_t size, size_t align, const Attributes_map &attributes={})
Creates new scalar datatype.
bool simple() const override
Tells if data can be copied as bytes (if type is dense) and doesn't need a destroyer.
size_t datasize() const override
Computes the data size of a type, excluding potentially unused memory from a sparse type.
Datatype_sptr evaluate(Context &) const override
Creates a new datatype by resolving the value of all metadata references.
Definition: array_datatype.h:38
const auto UNDEF_TYPE
Definition: scalar_datatype.h:189
std::unordered_map< std::string, Expression > Attributes_map
Definition: datatype_template.h:40
Scalar_kind
Different possible interpretations for a scalar.
Definition: pdi_fwd.h:102
std::shared_ptr< const Datatype > Datatype_sptr
Definition: pdi_fwd.h:78