quad_index.hpp
Go to the documentation of this file.
1 /*
2 ** TP CPE Lyon
3 ** Copyright (C) 2014 Damien Rohmer
4 **
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 #pragma once
21 
22 #ifndef QUAD_INDEX_HPP
23 #define QUAD_INDEX_HPP
24 
25 namespace cpe
26 {
28 {
29  public:
30 
31  // ********************************************* //
32  // ********************************************* //
33  // CONSTRUCTORS
34  // ********************************************* //
35  // ********************************************* //
36 
38  quad_index();
40  quad_index(unsigned int u0,unsigned int u1,unsigned int u2,unsigned int u3);
41 
42  // ********************************************* //
43  // ********************************************* //
44  // Data access
45  // ********************************************* //
46  // ********************************************* //
47 
49  unsigned int u0() const;
51  unsigned int u1() const;
53  unsigned int u2() const;
55  unsigned int u3() const;
56 
58  unsigned int& u0();
60  unsigned int& u1();
62  unsigned int& u2();
64  unsigned int& u3();
65 
67  unsigned int operator[](unsigned int k_index) const;
69  unsigned int& operator[](unsigned int k_index);
70 
71 
73  const unsigned int* pointer() const;
74 
75  private:
76 
78  void assert_size(unsigned int k) const;
79 
81  unsigned int internal_u[4];
82 };
83 }
84 
85 #endif
quad_index()
empty constructor
Definition: quad_index.cpp:26
unsigned int u2() const
Access third component.
Definition: quad_index.cpp:42
unsigned int u1() const
Access second component.
Definition: quad_index.cpp:41
Definition: quad_index.hpp:27
unsigned int u3() const
Access fourth component.
Definition: quad_index.cpp:43
void assert_size(unsigned int k) const
assert that a size_t belongs to [[0,3]]
Definition: quad_index.cpp:58
unsigned int internal_u[4]
internal storage of 4 components = indices of the quad
Definition: quad_index.hpp:81
const unsigned int * pointer() const
Get pointer.
Definition: quad_index.cpp:67
unsigned int u0() const
Access first component.
Definition: quad_index.cpp:40
unsigned int operator[](unsigned int k_index) const
Access component k (0<=k<4) component.
Definition: quad_index.cpp:48