29 #ifndef TYPES_BASIC_HPP 30 #define TYPES_BASIC_HPP 74 virtual size_t length()
const = 0;
76 virtual size_t size()
const = 0;
78 virtual void fill(T val) = 0;
80 virtual T *
data() = 0;
82 virtual const T *
data()
const = 0;
109 virtual void init(
size_t length, T initVal) = 0;
114 virtual const T &
operator() (
size_t index)
const = 0;
140 virtual size_t cols()
const = 0;
142 virtual size_t rows()
const = 0;
147 virtual void init(
size_t cols,
size_t rows, T initVal) = 0;
150 virtual T &
operator() (
size_t col,
size_t row) = 0;
152 virtual const T &
operator() (
size_t col,
size_t row)
const = 0;
204 virtual void fill(T val) = 0;
230 (*this).fill(initVal);
237 m_data = std::move(other.m_data);
259 }
catch (std::bad_alloc & e) {
271 (*this).fill(initVal);
320 m_vector = std::move(other.m_vector);
virtual void init(size_t cols, size_t rows, T initVal)
Initializes the matrix with a specified number of cols and rows and fills it with 'val'.
Definition: types_basic.hpp:337
virtual ~VectorType()
Empty destructor.
Definition: types_basic.hpp:105
Vector< T > m_vector
A Matrix is composed using a large Vector.
Definition: types_basic.hpp:359
virtual T * data()
Returns a pointer to the contained data.
Definition: types_basic.hpp:343
VectorType()
Protected constructor.
Definition: types_basic.hpp:119
T & operator()(size_t index)
Accesses an element in the vector. Doesn't check for bounds.
Definition: types_basic.hpp:282
StructuredType()
Protected constructor.
Definition: types_basic.hpp:179
Matrix(size_t cols, size_t rows, T initVal)
Constructs a Matrix with 'cols' * 'rows' elements and fills it with 'initVal'.
Definition: types_basic.hpp:314
An abstract class, representing all the matrix-like data types.
Definition: types_basic.hpp:132
virtual size_t size() const =0
Returns the size of the contained data (i.e. length * sizeof(T))
Matrix(size_t cols, size_t rows)
Constructs a Matrix with 'cols' * 'rows' elements.
Definition: types_basic.hpp:312
A class representing a vector, stored in the machine's free space.
Definition: types_basic.hpp:217
virtual size_t rows() const
Returns number of rows.
Definition: types_basic.hpp:330
This header file contains exceptions.
virtual ~ArrayType()
Empty destructor.
Definition: types_basic.hpp:72
virtual T * data()=0
Returns a pointer to the contained data.
Matrix(Matrix &&other)
Move constructor.
Definition: types_basic.hpp:317
virtual const T * data() const
Returns a const pointer to the contained data.
Definition: types_basic.hpp:280
virtual ~Vector()
Empty destructor.
Definition: types_basic.hpp:243
ComputationalContext()
Protected constructor.
Definition: types_basic.hpp:197
Matrix & operator=(Matrix &&other)
Move assignment operator.
Definition: types_basic.hpp:319
A base abstract class, representing all the data types.
Definition: types_basic.hpp:44
virtual ~StructuredType()
Empty destructor.
Definition: types_basic.hpp:174
Vector(Vector &&other)
Move constructor.
Definition: types_basic.hpp:234
Vector & operator=(Vector &&other)
Move assignment operator.
Definition: types_basic.hpp:236
virtual void init(size_t length)=0
Initializes the vector with a specified number of elements.
An abstract class, representing all the structured data types.
Definition: types_basic.hpp:169
virtual ~ComputationalContext()
Empty destructor.
Definition: types_basic.hpp:202
Vector(size_t length)
Constructs a Vector with 'length' elements.
Definition: types_basic.hpp:224
virtual void init(size_t cols, size_t rows)=0
Initializes the matrix with a specified number of cols and rows.
virtual size_t length() const
Returns number of elements in the container.
Definition: types_basic.hpp:245
Matrix()
Constructs an empty Matrix with no elements. Needs to be initialized first (init).
Definition: types_basic.hpp:310
virtual size_t size() const
Returns the size of the contained data (i.e. length * sizeof(T))
Definition: types_basic.hpp:247
virtual ~DataType()
Empty destructor.
Definition: types_basic.hpp:49
virtual size_t length() const =0
Returns number of elements in the container.
virtual T * data()
Returns a pointer to the contained data.
Definition: types_basic.hpp:278
Vector()
Constructs an empty Vector with no elements. Needs to be initialized first (init).
Definition: types_basic.hpp:222
virtual ~MatrixType()
Empty destructor.
Definition: types_basic.hpp:137
size_t m_length
The number of elements in the vector.
Definition: types_basic.hpp:291
virtual T & operator()(size_t col, size_t row)
Accesses an element in the matrix. Doesn't check for bounds.
Definition: types_basic.hpp:353
virtual T & operator()(size_t col, size_t row)=0
Accesses an element in the matrix. Doesn't check for bounds.
virtual void fill(T val)=0
Fills the container with the 'val'.
virtual size_t rows() const =0
Returns number of rows.
virtual void init(size_t length)
Initializes the vector with a specified number of elements.
Definition: types_basic.hpp:249
virtual const T * data() const
Returns a const pointer to the contained data.
Definition: types_basic.hpp:344
MatrixType()
Protected constructor.
Definition: types_basic.hpp:157
A class representing a matrix, stored in the machine's free space.
Definition: types_basic.hpp:305
size_t m_rows
Number of rows.
Definition: types_basic.hpp:363
Vector(size_t length, T initVal)
Constructs a Vector with 'length' elements and fills it with 'initVal'.
Definition: types_basic.hpp:228
DataType()
Protected constructor.
Definition: types_basic.hpp:54
virtual size_t cols() const =0
Returns number of columns.
virtual void fill(T val)=0
Fills the context's containers (vectors, matrices,...) with the 'val'.
size_t m_cols
Number of columns.
Definition: types_basic.hpp:361
An abstract class, representing all the vector-like data types.
Definition: types_basic.hpp:100
virtual void init(size_t length, T initVal)
Initializes the vector with a specified number of elements and fills it with 'val'.
Definition: types_basic.hpp:269
virtual T & operator()(size_t index)=0
Accesses an element in the vector. Doesn't check for bounds.
An abstract class, representing all the computational contexts.
Definition: types_basic.hpp:192
virtual void fill(T val)
Fills the container with the 'val'.
Definition: types_basic.hpp:274
virtual void init(size_t cols, size_t rows)
Initializes the matrix with a specified number of cols and rows.
Definition: types_basic.hpp:332
ArrayType()
Protected constructor.
Definition: types_basic.hpp:87
An exception which cannot be directly influenced by the user, or predicted beforehand.
Definition: exceptions.hpp:76
virtual size_t length() const
Returns number of elements in the container.
Definition: types_basic.hpp:346
virtual void fill(T val)
Fills the container with the 'val'.
Definition: types_basic.hpp:349
std::unique_ptr< T[]> m_data
Unique_ptr holding the allocated space.
Definition: types_basic.hpp:289
virtual size_t size() const
Returns the size of the contained data (i.e. length * sizeof(T))
Definition: types_basic.hpp:347
virtual ~Matrix()
Empty destructor.
Definition: types_basic.hpp:327
virtual size_t cols() const
Returns number of columns.
Definition: types_basic.hpp:329
An abstract class, representing all the array-like data types.
Definition: types_basic.hpp:67