matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
MultiDimensionalArray.h
Go to the documentation of this file.
1 #ifndef MATIOCPP_MULTIDIMENSIONALARRAY_H
2 #define MATIOCPP_MULTIDIMENSIONALARRAY_H
3 
4 /*
5  * Copyright (C) 2020 Fondazione Istituto Italiano di Tecnologia
6  *
7  * This software may be modified and distributed under the terms of the
8  * BSD-2-Clause license (https://opensource.org/licenses/BSD-2-Clause).
9  */
10 
13 #include <matioCpp/Span.h>
14 #include <matioCpp/Variable.h>
15 
20 template<typename T>
22 {
23 
31  virtual bool checkCompatibility(const matvar_t* inputPtr, matioCpp::VariableType variableType, matioCpp::ValueType valueType) const final;
32 
33 public:
34 
35  using type = T;
37  using element_type = typename get_type<T>::type;
39  using value_type = std::remove_cv_t<element_type>;
43  using index_type = size_t;
56 
62 
69 
77 
82 
87 
92  MultiDimensionalArray(const MatvarHandler& handler);
93 
98 
106 
114 
123 
136 
144  bool indicesFromRawIndex(size_t rawIndex, std::vector<index_type>& el) const;
145 
150 
155 
161  bool setName(const std::string& newName);
162 
169  void resize(const std::vector<index_type>& newDimensions);
170 
174  void clear();
175 
181  pointer data();
182 
188  const_pointer data() const;
189 
195 
203 
211 
218 
225 
233 
241 
248 
255 };
256 
258 
259 #endif // MATIOCPP_MULTIDIMENSIONALARRAY_H
MultiDimensionalArray is a particular type of Variable specialized for multidimensional arrays of a g...
index_type numberOfElements() const
Get the total number of elements in the array.
reference operator[](const std::vector< index_type > &el)
Access specified element.
matioCpp::Span< element_type > toSpan()
Get this MultiDimensionalArray as a Span.
value_type operator()(const std::vector< index_type > &el) const
Access specified element.
reference operator()(index_type el)
Access specified element.
MultiDimensionalArray()
The const pointer type.
value_type operator[](index_type el) const
Access specified element.
typename std::allocator_traits< std::allocator< element_type > >::const_pointer const_pointer
The pointer type.
MultiDimensionalArray< T > & operator=(const MultiDimensionalArray< T > &other)
Assignement operator (copy) from another MultiDimensionalArray.
reference operator[](index_type el)
Access specified element.
value_type operator()(index_type el) const
Access specified element.
bool setName(const std::string &newName)
Change the name of the Variable.
bool fromVectorizedArray(const std::vector< index_type > &dimensions, const_pointer inputVector)
Set from a vectorized array.
value_type operator[](const std::vector< index_type > &el) const
Access specified element.
bool indicesFromRawIndex(size_t rawIndex, std::vector< index_type > &el) const
Get the indices given the raw index.
typename get_type< T >::type element_type
Defines the type specified in the template.
reference operator()(const std::vector< index_type > &el)
Access specified element.
MultiDimensionalArray(const std::string &name, const std::vector< index_type > &dimensions)
Constructor.
void clear()
Clear the multidimensional array.
void resize(const std::vector< index_type > &newDimensions)
Resize the vector.
pointer data()
Direct access to the underlying array.
MultiDimensionalArray(const std::string &name, const std::vector< index_type > &dimensions, const_pointer inputVector)
Constructor.
size_t index_type
Defines how to allocate T.
typename std::allocator_traits< std::allocator< element_type > >::pointer pointer
The reference type.
element_type & reference
The type used for indices.
std::remove_cv_t< element_type > value_type
Defines the type of an element of the MultiDimensionalArray.
index_type rawIndexFromIndices(const std::vector< index_type > &el) const
Get the index in the vectorized array corresponding to the provided indices.
The matioCpp::Variable class is the equivalent of matvar_t in matio.
Definition: Variable.h:23
std::string name() const
Get the name of the Variable.
Definition: Variable.cpp:494
matioCpp::Span< const size_t > dimensions() const
Get the dimensions of this object.
Definition: Variable.cpp:528
matioCpp::VariableType variableType() const
Get the VariableType.
Definition: Variable.cpp:506
matioCpp::ValueType valueType() const
Get the ValueType.
Definition: Variable.cpp:511
VariableType
Define the type of variable.
ValueType
The list of types for an element of a certain variable type.
Utility metafunction to get the ValueType from a given primitive type.