PDI 1.0.1

Data exchange made easy

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

Classes

class  Index_accessor
 Accessor to get single element from array. More...
 
class  Slice_accessor
 Accessor to get a slice of an array, returns array of the same subtype. More...
 

Public Member Functions

 Array_datatype (Datatype_uptr subtype, size_t size, size_t start, size_t subsize)
 Construct a new partially filled Array_datatype. More...
 
 Array_datatype (Datatype_uptr subtype, size_t size)
 Construct a new completely filled Array_datatype. More...
 
const Datatypesubtype () const
 Type of the elements contained in the array. More...
 
size_t size () const
 Number of elements the array can store. More...
 
size_t start () const
 id of the first actual element of the array More...
 
size_t subsize () const
 Number of actual elements in the array. More...
 
Datatype_template_uptr clone () const override
 Creates a new datatype as an exact copy of this one. More...
 
Datatype_uptr clone_type () const override
 Creates a new datatype as an exact copy of this one. More...
 
Datatype_uptr densify () const override
 Creates a new datatype as the dense copy of this one. More...
 
Datatype_uptr evaluate (Context &) const override
 Creates a new datatype by resolving the value of all metadata references. More...
 
bool dense () const override
 Indicate if the datatype is dense or not. More...
 
size_t datasize () const override
 Computes the data size of a type, excluding potentially unused memory from a sparse type. More...
 
size_t buffersize () const override
 Computes the data size of a type, including potentially unused memory from a sparse type. More...
 
size_t alignment () const override
 Returns the required alignment for a type. More...
 
bool simple () const override
 Tells if data can be copied as bytes (if type is dense) and doesn't need a destroyer. More...
 
void * data_to_dense_copy (void *, const void *) const override
 Creates a dense deep copy of data. More...
 
void * data_from_dense_copy (void *, const void *) const override
 Creates a sparse deep copy of dense data. More...
 
std::pair< void *, Datatype_uptrsubaccess_by_iterators (void *from, std::vector< std::unique_ptr< Accessor_base >>::const_iterator remaining_begin, std::vector< std::unique_ptr< Accessor_base >>::const_iterator remaining_end) const override
 Creates datatype of subtype and returns it with a moved pointer. More...
 
void destroy_data (void *) const override
 Function used to delete the data behind the datatype. More...
 
std::string debug_string () const override
 Returns the datatype yaml representation as a string. More...
 
bool operator== (const Datatype &) const override
 Test for equality. More...
 
- Public Member Functions inherited from PDI::Datatype
 ~Datatype () override
 
bool operator!= (const Datatype &other) const
 Test for inequality. More...
 
std::pair< void *, Datatype_uptrsubaccess (void *from, const Accessor_base &accessor) const
 Creates datatype of subtype and returns it with a moved pointer. More...
 
std::pair< void *, Datatype_uptrsubaccess (void *from, const std::vector< std::unique_ptr< Accessor_base >> &accessors) const
 Creates datatype of subtype and returns it with a moved pointer. More...
 
- Public Member Functions inherited from PDI::Datatype_template
virtual ~Datatype_template ()
 Destroys the template. More...
 

Additional Inherited Members

- 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. More...
 

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.

Constructor & Destructor Documentation

◆ Array_datatype() [1/2]

PDI::Array_datatype::Array_datatype ( Datatype_uptr  subtype,
size_t  size,
size_t  start,
size_t  subsize 
)

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

◆ Array_datatype() [2/2]

PDI::Array_datatype::Array_datatype ( Datatype_uptr  subtype,
size_t  size 
)

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

Member Function Documentation

◆ subtype()

const Datatype& 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

◆ clone()

Datatype_template_uptr PDI::Array_datatype::clone ( ) const
overridevirtual

Creates a new datatype as an exact copy of this one.

Returns
the dense type that is produced

Implements PDI::Datatype_template.

◆ clone_type()

Datatype_uptr PDI::Array_datatype::clone_type ( ) const
overridevirtual

Creates a new datatype as an exact copy of this one.

Returns
the dense type that is produced

Implements PDI::Datatype.

◆ densify()

Datatype_uptr 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_uptr 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.

◆ subaccess_by_iterators()

std::pair<void*, Datatype_uptr> PDI::Array_datatype::subaccess_by_iterators ( void *  from,
std::vector< std::unique_ptr< Accessor_base >>::const_iterator  remaining_begin,
std::vector< std::unique_ptr< Accessor_base >>::const_iterator  remaining_end 
) const
overridevirtual

Creates datatype of subtype and returns it with a moved pointer.

Parameters
[in]fromthe pointer to the data
[in]remaining_beginiterator to the begin of remaining accessors
[in]remaining_enditerator to the end of remaining accessors
Returns
pointer moved by offset and new datatype

Reimplemented from PDI::Datatype.

◆ destroy_data()

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

Function used to delete the data behind the datatype.

This should not deallocate the memory.

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.


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