matio-cpp  v0.2.5
A C++ wrapper of the matio library, with memory ownership handling, to read and write .mat files.
Element.h
Go to the documentation of this file.
1 #ifndef MATIOCPP_ELEMENT_H
2 #define MATIOCPP_ELEMENT_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/Variable.h>
14 
18 template<typename T>
20 {
21 
29  virtual bool checkCompatibility(const matvar_t* inputPtr, matioCpp::VariableType variableType, matioCpp::ValueType valueType) const final;
30 
31 public:
32 
33  using type = T;
35  using element_type = typename get_type<T>::type;
37  using value_type = std::remove_cv_t<element_type>;
49  Element();
50 
55  Element(const std::string& name);
56 
62  Element(const std::string& name, element_type inputValue);
63 
67  Element(const Element<T>& other);
68 
72  Element(Element<T>&& other);
73 
78  Element(const MatvarHandler& handler);
79 
83  ~Element();
84 
91  Element<T>& operator=(const Element<T>& other);
92 
100 
107 
112 
117 
123  bool setName(const std::string& newName);
124 
130 
135  value_type operator()() const;
136 
140  operator element_type() const;
141 
142 };
143 
144 #include "impl/Element.tpp"
145 
146 
147 #endif // MATIOCPP_ELEMENT_H
Element allows having a 1x1 variable (like double, int,..) castable to a primitive type.
Definition: Element.h:20
matioCpp::Span< element_type > toSpan()
Get this Vector as a Span.
Definition: Element.tpp:140
typename std::allocator_traits< std::allocator< element_type > >::const_pointer const_pointer
The pointer type.
Definition: Element.h:43
reference operator()()
Access the Element.
Definition: Element.tpp:158
Element()
The const pointer type.
Definition: Element.tpp:44
Element(const std::string &name, element_type inputValue)
Constructor.
element_type & reference
Defines the type of the Element.
Definition: Element.h:39
bool setName(const std::string &newName)
Change the name of the Variable.
Definition: Element.tpp:152
Element< T > & operator=(const Element< T > &other)
Assignement operator (copy) from another Element.
Definition: Element.tpp:119
typename std::allocator_traits< std::allocator< element_type > >::pointer pointer
The reference type.
Definition: Element.h:41
Element< T > & operator=(element_type value)
Assignement operator (copy) from an element of type T.
typename get_type< T >::type element_type
Defines the type specified in the template.
Definition: Element.h:35
std::remove_cv_t< element_type > value_type
Defines the type of the Element.
Definition: Element.h:37
~Element()
Destructor.
Definition: Element.tpp:113
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::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.