SOIL C++
C++ Unified Device Interface
SOIL::Container< T, x, y > Class Template Reference

Data Container. More...

#include <Container.h>

Public Member Functions

 Container ()
 Empty constructor. More...
 
 Container (const std::vector< std::vector< T > > &value)
 Data copy constructor. More...
 
 Container (HTTP::Json json)
 JSON Constructor. More...
 
std::vector< std::vector< T > > operator* (void) const
 Deferencing operator. More...
 
bool is_null (void) const
 Is Null? More...
 
void set_null (bool _null=true)
 Set null. More...
 
HTTP::Json wjson (void)
 WJSON representation. More...
 
bool check_range (Range< T > range) const
 Check range. More...
 
T & at (int i, int j)
 Data Accessor. More...
 
std::vector< unsigned char > serialize_value (void) const
 Serialize value. More...
 
std::vector< unsigned char > serialize_dimensions (void) const
 Serialize dimensions. More...
 

Detailed Description

template<typename T, int x = -1, int y = -1>
class SOIL::Container< T, x, y >

Container class to manage multidmensional data of (nearly) arbitrary type. The data can be scalar, 1D or 2D while the size of dimensions is a priori unknown. This class then provides an abstratcion layer to the other elements of SOIL to allow for consistent implementation. Therefor it makes heavy use of templates, which are specialized for certain cases where x and/or y are -1 and for special types.

Template Parameters
TType of the data.
xFirst dimension of the data. -1 means unused, 0 means arbitray size. Cannot be -1 if y is not -1.
ySecond dimension of the data. -1 means unused, 0 means arbitray size. Must be -1 for x to be -1.

Definition at line 21 of file Container.h.

Constructor & Destructor Documentation

◆ Container() [1/3]

template<typename T >
SOIL::Container< T >::Container

Constructs an empty container. _null will be set to true as no data has been added.

Exceptions
std::runtime_errorAn exception is thrown if an invalid combination of template parameters is used.

Definition at line 196 of file Container.h.

◆ Container() [2/3]

template<typename T , int x, int y>
SOIL::Container< T, x, y >::Container ( const std::vector< std::vector< T > > &  value)

Constructor that initializes the data with the given value.

Parameters
[in]valueData for initialization, wich must match in type and dimension

Definition at line 210 of file Container.h.

◆ Container() [3/3]

template<typename T >
SOIL::Container< T >::Container ( HTTP::Json  json)

Constructor that takes dimension and value from an JSON representation adhering to the SOIL nomenclature.

Parameters
[in]jsonJSON object to parse

Definition at line 231 of file Container.h.

Member Function Documentation

◆ at()

template<typename T , int x, int y>
T & SOIL::Container< T >::at ( int  i,
int  j 
)

STL-style data accesor retrieving a a single element from multidimensional-data.

Parameters
[in]iIndex position along first dimension
[in]jIndex position along second dimension
Returns
Data value of type T

Definition at line 313 of file Container.h.

◆ check_range()

template<typename T >
bool SOIL::Container< T >::check_range ( Range< T >  range) const

Check whether the data of the container lies within the specified range. In the case of multidimensional data, this check is carried out on all elememts and only returns true if it is applicable to all.

Parameters
[in]rangeRange for which to check
Returns
Check result as boolean

Definition at line 293 of file Container.h.

◆ is_null()

template<typename T , int x = -1, int y = -1>
bool SOIL::Container< T, x, y >::is_null ( void  ) const
inline

Function that returns true if the current data is set to null and false else.

Returns
Null flag

Definition at line 79 of file Container.h.

◆ operator*()

template<typename T >
T SOIL::Container< T >::operator* ( void  ) const

Return a copy of the raw data, similar to other uses of * in the standard library.

Returns
Copy of underlying data.

Definition at line 263 of file Container.h.

◆ serialize_dimensions()

template<typename T >
std::vector< unsigned char > SOIL::Container< T >::serialize_dimensions ( void  ) const

Serialize the dimensions to a bytestring for hashing purposes

Returns
Bytestring of serialization

Definition at line 350 of file Container.h.

◆ serialize_value()

template<typename T >
std::vector< unsigned char > SOIL::Container< T >::serialize_value ( void  ) const

Serialize the value to a bytestring for hashing purposes

Returns
Bytestring of serialization

Definition at line 323 of file Container.h.

◆ set_null()

template<typename T , int x = -1, int y = -1>
void SOIL::Container< T, x, y >::set_null ( bool  _null = true)
inline

Function to set the null status of the data container

Parameters
[in]_nullBoolean state flag

Definition at line 87 of file Container.h.

◆ wjson()

template<typename T >
HTTP::Json SOIL::Container< T >::wjson ( void  )

Get a JSON object respresentation of the container's current data. The naming wjson() is chosen as it is consistently used through the library when using wide-string JSON as introduced by cpprestsdk.

Returns
JSON object.

Definition at line 269 of file Container.h.


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