icedb  version 0.5.1
Snow particle scattering database API
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
icedb::Attributes::Attribute< DataType > Class Template Reference

This class defines an attribute. More...

#include <Attribute.hpp>

Collaboration diagram for icedb::Attributes::Attribute< DataType >:
Collaboration graph
[legend]

Public Types

typedef DataType type
 

Public Member Functions

bool isArray () const
 Does this attribute span more than one dimension? More...
 
 Attribute (const std::string &name)
 Create an empty attribute. More...
 
 Attribute (const std::string &name, DataType val)
 Create a zero-dimensional attribute with pre-populated data. More...
 
 Attribute (const std::string &name, std::initializer_list< size_t > dims, std::initializer_list< DataType > data)
 Create a multi-dimensional attribute with pre-populated data. More...
 

Public Attributes

std::vector< DataType > data
 
std::string name
 The name of the attribute. More...
 
std::vector< size_t > dimensionality
 The attribute's dimensional span. NetCDF only accepts one-dimensional attributes. More...
 

Protected Member Functions

 Attribute ()
 

Detailed Description

template<class DataType>
class icedb::Attributes::Attribute< DataType >

This class defines an attribute.

Attributes provide "additional information" to a table or a group. They have a type and a size, and are read and written as complete objects.

Attributes must be explicitly written to an object inheriting from CanHaveAttributes.

See also
Attributes for usage instructions
CanHaveAttributes

Definition at line 23 of file Attribute.hpp.

Member Typedef Documentation

◆ type

template<class DataType>
typedef DataType icedb::Attributes::Attribute< DataType >::type

Definition at line 27 of file Attribute.hpp.

Constructor & Destructor Documentation

◆ Attribute() [1/4]

template<class DataType>
icedb::Attributes::Attribute< DataType >::Attribute ( )
inlineprotected

Definition at line 25 of file Attribute.hpp.

25 : Attribute("", {}, {}) {}

◆ Attribute() [2/4]

template<class DataType>
icedb::Attributes::Attribute< DataType >::Attribute ( const std::string &  name)
inline

Create an empty attribute.

Definition at line 42 of file Attribute.hpp.

42 : Attribute(name, {}, {}) {}
std::string name
The name of the attribute.
Definition: Attribute.hpp:32

◆ Attribute() [3/4]

template<class DataType>
icedb::Attributes::Attribute< DataType >::Attribute ( const std::string &  name,
DataType  val 
)
inline

Create a zero-dimensional attribute with pre-populated data.

Definition at line 44 of file Attribute.hpp.

45  : Attribute(name, { 1 }, { val }) {}
std::string name
The name of the attribute.
Definition: Attribute.hpp:32

◆ Attribute() [4/4]

template<class DataType>
icedb::Attributes::Attribute< DataType >::Attribute ( const std::string &  name,
std::initializer_list< size_t >  dims,
std::initializer_list< DataType >  data 
)
inline

Create a multi-dimensional attribute with pre-populated data.

Definition at line 47 of file Attribute.hpp.

48  : name{ name }, dimensionality{ dims }, data{ data }
49  {
50  static_assert(icedb::Data_Types::Is_Valid_Data_Type<DataType>() == true,
51  "Attributes must be a valid data type");
52 
53  //size_t sz = 1;
54  //for (const auto &d : dims) sz *= d;
55  //Expects(data.size() == sz);
56  }
std::vector< size_t > dimensionality
The attribute&#39;s dimensional span. NetCDF only accepts one-dimensional attributes. ...
Definition: Attribute.hpp:34
std::string name
The name of the attribute.
Definition: Attribute.hpp:32
std::vector< DataType > data
Definition: Attribute.hpp:30

Member Function Documentation

◆ isArray()

template<class DataType>
bool icedb::Attributes::Attribute< DataType >::isArray ( ) const
inline

Does this attribute span more than one dimension?

Definition at line 36 of file Attribute.hpp.

36  {
37  if (dimensionality.size() > 1) return true;
38  return false;
39  }
std::vector< size_t > dimensionality
The attribute&#39;s dimensional span. NetCDF only accepts one-dimensional attributes. ...
Definition: Attribute.hpp:34

Member Data Documentation

◆ data

template<class DataType>
std::vector<DataType> icedb::Attributes::Attribute< DataType >::data

The data contained in the attribute. The size of this data must match the number of elements defined by the attribute's dimensionality.

Definition at line 30 of file Attribute.hpp.

Referenced by icedb::Attributes::CanHaveAttributes::isAttributeOfType(), icedb::Shapes::Shape::isShape(), main(), icedb::Attributes::CanHaveAttributes::readAttribute(), and icedb::Attributes::CanHaveAttributes::writeAttribute().

◆ dimensionality

template<class DataType>
std::vector<size_t> icedb::Attributes::Attribute< DataType >::dimensionality

The attribute's dimensional span. NetCDF only accepts one-dimensional attributes.

Definition at line 34 of file Attribute.hpp.

Referenced by icedb::Attributes::CanHaveAttributes::readAttribute(), and icedb::Attributes::CanHaveAttributes::writeAttribute().

◆ name

template<class DataType>
std::string icedb::Attributes::Attribute< DataType >::name

The name of the attribute.

Definition at line 32 of file Attribute.hpp.

Referenced by icedb::Attributes::CanHaveAttributes::writeAttribute().


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