26#ifndef PDI_SCALAR_DATATYPE_H_
27#define PDI_SCALAR_DATATYPE_H_
33#include <pdi/pdi_fwd.h>
34#include <pdi/datatype.h>
43 struct Shared_enabler;
58 std::function<
void* (
void*,
const void* ) > m_copy;
61 std::function<void (
void* ) > m_destroy;
64 static std::shared_ptr<Scalar_datatype>
const cv_type_for_v;
69 if constexpr ( std::is_integral<T>::value ) {
70 if constexpr ( std::is_signed<T>::value ) {
74 }
else if constexpr ( std::is_floating_point<T>::value ) {
82 static constexpr auto kind_of_v = kind_of<std::remove_cv_t<T>>();
85 static constexpr auto const& type_for_v = cv_type_for_v<std::remove_cv_t<T>>;
113 bool operator== (
const Datatype& )
const override;
142 Scalar_datatype (
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 = {} );
172 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 = {} );
177extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint8_t>;
179extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint16_t>;
181extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint32_t>;
183extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<uint64_t>;
185extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int8_t>;
187extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int16_t>;
189extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int32_t>;
191extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<int64_t>;
193extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<bool>;
195extern template std::shared_ptr<Scalar_datatype>
const Scalar_datatype::cv_type_for_v<float>;
197extern 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:49
Definition: scalar_datatype.h:41
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:175
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:101
std::shared_ptr< const Datatype > Datatype_sptr
Definition: pdi_fwd.h:78