OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
olb::cpu::sisd::Column< T > Class Template Referencefinal

Plain column for SISD CPU targets (default) More...

#include <column.h>

+ Inheritance diagram for olb::cpu::sisd::Column< T >:
+ Collaboration diagram for olb::cpu::sisd::Column< T >:

Public Types

using value_t = T
 
- Public Types inherited from olb::AbstractColumn< T >
using value_type = T
 

Public Member Functions

 Column (std::size_t count)
 
 Column ()
 
 Column (Column< T > &&rhs)
 
 Column (const Column< T > &rhs)
 
virtual ~Column ()=default
 
void resize (std::size_t count)
 
const T & operator[] (std::size_t i) const override
 
T & operator[] (std::size_t i) override
 
std::size_t size () const
 
const T * data () const
 
T * data ()
 
void setProcessingContext (ProcessingContext)
 
std::size_t getNblock () const override
 Number of data blocks for the serializable interface.
 
std::size_t getSerializableSize () const override
 Binary size for the serializer.
 
bool * getBlock (std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
 Return a pointer to the memory of the current block and its size for the serializable interface.
 
- Public Member Functions inherited from olb::Serializable
virtual ~Serializable ()=default
 
template<bool includeLogOutputDir = true>
bool save (std::string fileName="", const bool enforceUint=false)
 Save Serializable into file fileName
 
template<bool includeLogOutputDir = true>
bool load (std::string fileName="", const bool enforceUint=false)
 Load Serializable from file fileName
 
bool save (std::uint8_t *buffer)
 Save Serializable into buffer of length getSerializableSize
 
bool load (const std::uint8_t *buffer)
 Load Serializable from buffer of length getSerializableSize
 
virtual void postLoad ()
 

Additional Inherited Members

- Protected Member Functions inherited from olb::Serializable
template<typename DataType >
void registerVar (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, const DataType &data, const size_t arrayLength=1) const
 Register primitive data types (int, double, ...) or arrays of those.
 
template<typename DataType >
void registerSerializableOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
 Register Serializable object of constant size.
 
template<typename DataType >
void registerSerializablesOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType *data, const size_t arrayLength, const bool loadingMode=false)
 Register an array of Serializable objects of constant size.
 

Detailed Description

template<typename T>
class olb::cpu::sisd::Column< T >

Plain column for SISD CPU targets (default)

Definition at line 44 of file column.h.

Member Typedef Documentation

◆ value_t

template<typename T >
using olb::cpu::sisd::Column< T >::value_t = T

Definition at line 51 of file column.h.

Constructor & Destructor Documentation

◆ Column() [1/4]

template<typename T >
olb::cpu::sisd::Column< T >::Column ( std::size_t count)
inline

Definition at line 53 of file column.h.

53 :
54 _count(count),
55 _data(new T[count] {})
56 { }

◆ Column() [2/4]

template<typename T >
olb::cpu::sisd::Column< T >::Column ( )
inline

Definition at line 58 of file column.h.

58 :
59 Column(0)
60 { }

◆ Column() [3/4]

template<typename T >
olb::cpu::sisd::Column< T >::Column ( Column< T > && rhs)
inline

Definition at line 62 of file column.h.

62 :
63 _count(rhs._count),
64 _data(rhs._data.release())
65 { }

◆ Column() [4/4]

template<typename T >
olb::cpu::sisd::Column< T >::Column ( const Column< T > & rhs)
inline

Definition at line 67 of file column.h.

67 :
68 _count(rhs._count),
69 _data(new T[_count] {})
70 {
71 std::copy(rhs._data.get(),
72 rhs._data.get() + _count,
73 _data.get());
74 }

◆ ~Column()

template<typename T >
virtual olb::cpu::sisd::Column< T >::~Column ( )
virtualdefault

Member Function Documentation

◆ data() [1/2]

template<typename T >
T * olb::cpu::sisd::Column< T >::data ( )
inline

Definition at line 106 of file column.h.

107 {
108 return _data.get();
109 }

◆ data() [2/2]

template<typename T >
const T * olb::cpu::sisd::Column< T >::data ( ) const
inline

Definition at line 101 of file column.h.

102 {
103 return _data.get();
104 }
+ Here is the caller graph for this function:

◆ getBlock()

template<typename T >
bool * olb::cpu::sisd::Column< T >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
overridevirtual

Return a pointer to the memory of the current block and its size for the serializable interface.

Implements olb::Serializable.

Definition at line 51 of file column.hh.

52{
53 std::size_t currentBlock = 0;
54 bool* dataPtr = nullptr;
55
56 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _count);
57 if (loadingMode && iBlock == 1) {
58 resize(_count);
59 }
60 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *data(), _count);
61
62 return dataPtr;
63}
void registerVar(const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, const DataType &data, const size_t arrayLength=1) const
Register primitive data types (int, double, ...) or arrays of those.
Definition serializer.h:212
const T * data() const
Definition column.h:101
void resize(std::size_t count)
Definition column.h:78

◆ getNblock()

template<typename T >
std::size_t olb::cpu::sisd::Column< T >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 39 of file column.hh.

40{
41 return 2;
42}

◆ getSerializableSize()

template<typename T >
std::size_t olb::cpu::sisd::Column< T >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 45 of file column.hh.

46{
47 return _count * sizeof(T) + sizeof(std::size_t);
48}

◆ operator[]() [1/2]

template<typename T >
const T & olb::cpu::sisd::Column< T >::operator[] ( std::size_t i) const
inlineoverridevirtual

Implements olb::AbstractColumn< T >.

Definition at line 86 of file column.h.

87 {
88 return _data[i];
89 }

◆ operator[]() [2/2]

template<typename T >
T & olb::cpu::sisd::Column< T >::operator[] ( std::size_t i)
inlineoverridevirtual

Implements olb::AbstractColumn< T >.

Definition at line 91 of file column.h.

92 {
93 return _data[i];
94 }

◆ resize()

template<typename T >
void olb::cpu::sisd::Column< T >::resize ( std::size_t count)
inline

Definition at line 78 of file column.h.

79 {
80 std::unique_ptr<T[]> data = std::unique_ptr<T[]>(new T[count] { });
81 std::copy(_data.get(), _data.get() + std::min(_count, count), data.get());
82 _data.swap(data);
83 _count = count;
84 }

References olb::cpu::sisd::Column< T >::data().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setProcessingContext()

template<typename T >
void olb::cpu::sisd::Column< T >::setProcessingContext ( ProcessingContext )
inline

Definition at line 111 of file column.h.

111{ };

◆ size()

template<typename T >
std::size_t olb::cpu::sisd::Column< T >::size ( ) const
inline

Definition at line 96 of file column.h.

97 {
98 return _count;
99 }
+ Here is the caller graph for this function:

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