PDI 1.6.0

the PDI data interface

PDI::Array_datatype Class Reference

an Array_datatype is a Datatype that represents an array: i.e storage of multiple elements of the same type continuously in memory. More...

Inheritance diagram for PDI::Array_datatype:
PDI::Datatype PDI::Datatype_template

Public Member Functions

Datatype_sptr subtype () const
 Type of the elements contained in the array.
 
size_t size () const
 Number of elements the array can store.
 
size_t start () const
 id of the first actual element of the array
 
size_t subsize () const
 Number of actual elements in the array.
 
Datatype_sptr densify () const override
 Creates a new datatype as the dense copy of this one.
 
Datatype_sptr evaluate (Context &) const override
 Creates a new datatype by resolving the value of all metadata references.
 
bool dense () const override
 Indicate if the datatype is dense or not.
 
size_t datasize () const override
 Computes the data size of a type, excluding potentially unused memory from a sparse type.
 
size_t buffersize () const override
 Computes the data size of a type, including potentially unused memory from a sparse type.
 
size_t alignment () const override
 Returns the required alignment for a type.
 
bool simple () const override
 Tells if data can be copied as bytes (if type is dense) and doesn't need a destroyer.
 
void * data_to_dense_copy (void *, const void *) const override
 Creates a dense deep copy of data.
 
void * data_from_dense_copy (void *, const void *) const override
 Creates a sparse deep copy of dense data.
 
Datatype_sptr index (size_t index) const override
 Access the type of the element at the provided index.
 
std::pair< void *, Datatype_sptrindex (size_t index, void *data) const override
 Access the type and value of the element at the provided index.
 
Datatype_sptr slice (size_t start_index, size_t end_index) const override
 Access the type of the elements slice between the provided indices.
 
std::pair< void *, Datatype_sptrslice (size_t start_index, size_t end_index, void *data) const override
 Access the type and value of the elements slice between the provided indices.
 
void destroy_data (void *) const override
 Delete data whose type is described by the Datatype.
 
std::string debug_string () const override
 Returns the datatype yaml representation as a string.
 
bool operator== (const Datatype &) const override
 Test for equality.
 
- Public Member Functions inherited from PDI::Datatype
 Datatype (const Attributes_map &attributes={})
 Creates a new datatype.
 
 ~Datatype () override
 
virtual bool operator== (const Datatype &other) const =0
 Test for equality.
 
bool operator!= (const Datatype &other) const
 Test for inequality.
 
virtual Datatype_sptr densify () const =0
 Creates a new datatype as the dense copy of this one.
 
virtual bool dense () const =0
 Indicate if the datatype is dense or not.
 
virtual size_t datasize () const =0
 Computes the data size of a type, excluding potentially unused memory from a sparse type.
 
virtual size_t buffersize () const =0
 Computes the data size of a type, including potentially unused memory from a sparse type.
 
virtual size_t alignment () const =0
 Returns the required alignment for a type.
 
virtual bool simple () const =0
 Tells if data can be copied as bytes (if type is dense) and doesn't need a destroyer.
 
virtual void * data_to_dense_copy (void *to, const void *from) const =0
 Creates a dense deep copy of data.
 
virtual void * data_from_dense_copy (void *to, const void *from) const =0
 Creates a sparse deep copy of dense data.
 
virtual Datatype_sptr index (size_t index) const
 Access the type of the element at the provided index.
 
virtual std::pair< void *, Datatype_sptrindex (size_t index, void *data) const
 Access the type and value of the element at the provided index.
 
virtual Datatype_sptr slice (size_t start_index, size_t end_index) const
 Access the type of the elements slice between the provided indices.
 
virtual std::pair< void *, Datatype_sptrslice (size_t start_index, size_t end_index, void *data) const
 Access the type and value of the elements slice between the provided indices.
 
virtual Datatype_sptr member (const char *name) const
 Access the type of the member with the provided name.
 
virtual std::pair< void *, Datatype_sptrmember (const char *name, void *data) const
 Access the type and value of the member with the provided name.
 
virtual Datatype_sptr dereference () const
 Access the type referenced by this.
 
virtual std::pair< void *, Datatype_sptrdereference (void *data) const
 Access the type and value referenced by this.
 
virtual void destroy_data (void *ptr) const =0
 Delete data whose type is described by the Datatype.
 
virtual std::string debug_string () const =0
 Returns the datatype yaml representation as a string.
 
- Public Member Functions inherited from PDI::Datatype_template
 Datatype_template (const Attributes_map &attributes={})
 Creates datatype template with given attributes.
 
 Datatype_template (PC_tree_t datatype_tree)
 Creates datatype template.
 
virtual ~Datatype_template ()
 Destroys the template.
 
virtual Datatype_sptr evaluate (Context &ctx) const =0
 Creates a new datatype by resolving the value of all metadata references.
 
Expression attribute (const std::string &attribute_name) const
 Returns attribute of given name as Expression.
 
const Attributes_mapattributes () const
 Returns all attributes as a unordered map.
 

Static Public Member Functions

static std::shared_ptr< Array_datatypemake (Datatype_sptr subtype, size_t size, size_t start, size_t subsize, const Attributes_map &attributes={})
 Construct a new partially filled Array_datatype.
 
static std::shared_ptr< Array_datatypemake (Datatype_sptr subtype, size_t size, const Attributes_map &attributes={})
 Construct a new completely filled Array_datatype.
 
- Static Public Member Functions inherited from PDI::Datatype_template
static void load_basic_datatypes (Context &ctx)
 Adds to the context the basic Array, Record, C and Fortran datatypes.
 
static void load_user_datatypes (Context &ctx, PC_tree_t types_tree)
 Adds to the context the user defined datatypes.
 

Additional Inherited Members

- Protected Attributes inherited from PDI::Datatype_template
Attributes_map m_attributes
 

Detailed Description

an Array_datatype is a Datatype that represents an array: i.e storage of multiple elements of the same type continuously in memory.

Member Function Documentation

◆ subtype()

Datatype_sptr PDI::Array_datatype::subtype ( ) const

Type of the elements contained in the array.

Returns
the type of the elements contained in the array

◆ size()

size_t PDI::Array_datatype::size ( ) const

Number of elements the array can store.

Returns
the number of elements the array can store

◆ start()

size_t PDI::Array_datatype::start ( ) const

id of the first actual element of the array

Returns
the id of the first actual element of the array

◆ subsize()

size_t PDI::Array_datatype::subsize ( ) const

Number of actual elements in the array.

Returns
the number of actual elements in the array

◆ densify()

Datatype_sptr PDI::Array_datatype::densify ( ) const
overridevirtual

Creates a new datatype as the dense copy of this one.

Returns
the type that is produced

Implements PDI::Datatype.

◆ evaluate()

Datatype_sptr PDI::Array_datatype::evaluate ( Context ctx) const
overridevirtual

Creates a new datatype by resolving the value of all metadata references.

Parameters
ctxthe context in which to evaluate this template
Returns
the evaluated type that is produced

Implements PDI::Datatype_template.

◆ dense()

bool PDI::Array_datatype::dense ( ) const
overridevirtual

Indicate if the datatype is dense or not.

Returns
whether the datatype is dense

Implements PDI::Datatype.

◆ datasize()

size_t PDI::Array_datatype::datasize ( ) const
overridevirtual

Computes the data size of a type, excluding potentially unused memory from a sparse type.

Returns
the size in bytes

Implements PDI::Datatype.

◆ buffersize()

size_t PDI::Array_datatype::buffersize ( ) const
overridevirtual

Computes the data size of a type, including potentially unused memory from a sparse type.

Returns
the size in bytes

Implements PDI::Datatype.

◆ alignment()

size_t PDI::Array_datatype::alignment ( ) const
overridevirtual

Returns the required alignment for a type.

Returns
the size in bytes

Implements PDI::Datatype.

◆ simple()

bool PDI::Array_datatype::simple ( ) const
overridevirtual

Tells if data can be copied as bytes (if type is dense) and doesn't need a destroyer.

Returns
true if data has trivial copier and destroyer, false otherwise

Implements PDI::Datatype.

◆ data_to_dense_copy()

void * PDI::Array_datatype::data_to_dense_copy ( void *  to,
const void *  from 
) const
overridevirtual

Creates a dense deep copy of data.

Parameters
[in]tothe pointer to the allocated memory to fill (dense data)
[in]fromthe pointer to the copied data (size of buffersize)
Returns
updated ‘to’ pointer

Implements PDI::Datatype.

◆ data_from_dense_copy()

void * PDI::Array_datatype::data_from_dense_copy ( void *  to,
const void *  from 
) const
overridevirtual

Creates a sparse deep copy of dense data.

Parameters
[in]tothe pointer to the allocated memory to fill (size of buffersize)
[in]fromthe pointer to the copied data (dense data)
Returns
updated ‘to’ pointer

Implements PDI::Datatype.

◆ index() [1/2]

Datatype_sptr PDI::Array_datatype::index ( size_t  index) const
overridevirtual

Access the type of the element at the provided index.

Parameters
indexthe index where to look
Returns
the Datatype of the indexed sub-element

Reimplemented from PDI::Datatype.

◆ index() [2/2]

std::pair< void *, Datatype_sptr > PDI::Array_datatype::index ( size_t  index,
void *  data 
) const
overridevirtual

Access the type and value of the element at the provided index.

Parameters
indexthe index where to look
datathe address of the element to index
Returns
the Datatype and address of the indexed sub-element

Reimplemented from PDI::Datatype.

◆ slice() [1/2]

Datatype_sptr PDI::Array_datatype::slice ( size_t  start_index,
size_t  end_index 
) const
overridevirtual

Access the type of the elements slice between the provided indices.

Parameters
start_indexthe index where to start
end_indexthe index where to end
Returns
the Datatype of the slice

Reimplemented from PDI::Datatype.

◆ slice() [2/2]

std::pair< void *, Datatype_sptr > PDI::Array_datatype::slice ( size_t  start_index,
size_t  end_index,
void *  data 
) const
overridevirtual

Access the type and value of the elements slice between the provided indices.

Parameters
start_indexthe index where to start
end_indexthe index where to end
datathe address of the element to slice
Returns
the Datatype and address of the slice

Reimplemented from PDI::Datatype.

◆ destroy_data()

void PDI::Array_datatype::destroy_data ( void *  ptr) const
overridevirtual

Delete data whose type is described by the Datatype.

This does not deallocate the buffer used to store the data.

Parameters
[in]ptrto the data to free

Implements PDI::Datatype.

◆ debug_string()

std::string PDI::Array_datatype::debug_string ( ) const
overridevirtual

Returns the datatype yaml representation as a string.

Returns
the datatype yaml representation as a string

Implements PDI::Datatype.

◆ operator==()

bool PDI::Array_datatype::operator== ( const Datatype other) const
overridevirtual

Test for equality.

Parameters
otherthe Datatype to compare
Returns
true if the Datatype's are equal

Implements PDI::Datatype.

◆ make() [1/2]

static std::shared_ptr< Array_datatype > PDI::Array_datatype::make ( Datatype_sptr  subtype,
size_t  size,
size_t  start,
size_t  subsize,
const Attributes_map attributes = {} 
)
static

Construct a new partially filled Array_datatype.

Parameters
[in]subtypethe type of the elements contained in the array
sizethe number of elements the array can store
startthe id of the first actual element of the array
subsizethe number of actual elements in the array
attributesattributes of the array

◆ make() [2/2]

static std::shared_ptr< Array_datatype > PDI::Array_datatype::make ( Datatype_sptr  subtype,
size_t  size,
const Attributes_map attributes = {} 
)
static

Construct a new completely filled Array_datatype.

Parameters
subtypethe type of the elements contained in the array
sizethe number of elements the array can store
attributesattributes of the array

The documentation for this class was generated from the following file: