Main MRPT website > C++ reference for MRPT 1.9.9
xsushortvector.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef XSUSHORTVECTOR_H
10 #define XSUSHORTVECTOR_H
11 
12 #ifndef __cplusplus
13 #define XSUSHORTVECTOR_INITIALIZER \
14  { \
15  { \
16  0, 0, 0 \
17  } \
18  }
19 #else
20 #include "xstypedefs.h"
21 #endif
22 
23 /*! \brief A vector containing 3 short values. */
25 {
26 #ifdef __cplusplus
27  //! \brief Constructor that creates the vector with all components set to 0
28  inline XsUShortVector()
29  {
30  m_data[0] = 0;
31  m_data[1] = 0;
32  m_data[2] = 0;
33  }
34 
35  //! \brief Constructor that creates the vector with all components set to
36  //! given values \a v1 \a v2 and \a v3
37  inline XsUShortVector(
38  unsigned short v1, unsigned short v2, unsigned short v3)
39  {
40  m_data[0] = v1;
41  m_data[1] = v2;
42  m_data[2] = v3;
43  }
44 
45  //! \brief Constructor that creates the vector with all components set to
46  //! values in array \a a
47  inline explicit XsUShortVector(const unsigned short* a)
48  {
49  m_data[0] = a[0];
50  m_data[1] = a[1];
51  m_data[2] = a[2];
52  }
53 
54  //! \brief Constructor that creates the vector and initializes it with data
55  //! from the \a other vector
56  inline XsUShortVector(const XsUShortVector& other)
57  {
58  m_data[0] = other.m_data[0];
59  m_data[1] = other.m_data[1];
60  m_data[2] = other.m_data[2];
61  }
62 
63  //! \brief Assignment operator copies the data from the \a other vector to
64  //! this vector
65  inline const XsUShortVector& operator=(const XsUShortVector& other)
66  {
67  if (this != &other)
68  {
69  m_data[0] = other.m_data[0];
70  m_data[1] = other.m_data[1];
71  m_data[2] = other.m_data[2];
72  }
73  return *this;
74  }
75 
76  //! \brief Comparison operator, returns true if the contents of the \a other
77  //! vector match those of this vector
78  inline bool operator==(const XsUShortVector& other) const
79  {
80  return m_data[0] == other.m_data[0] && m_data[1] == other.m_data[1] &&
81  m_data[2] == other.m_data[2];
82  }
83 
84  //! \brief Return the size of the vector (always 3)
85  inline XsSize size() const { return 3; }
86  //! \brief Return a value from the vector (needed to allow generated C#
87  //! access to these elements)
88  inline unsigned short at(int index) { return m_data[index]; }
89  //! \brief Returns the \a index'th item in the vector
90  inline unsigned short operator[](XsSize index) const
91  {
92  assert(index < 3);
93  return m_data[index];
94  }
95 
96  //! \brief Returns a reference the \a index'th item in the vector
97  inline unsigned short& operator[](XsSize index)
98  {
99  assert(index < 3);
100  return m_data[index]; // lint !e1536
101  }
102 
103  private:
104 #endif
105 
106  /** vector component storage */
107  unsigned short m_data[3];
108 };
109 
111 
112 #endif // XSUSHORTVECTOR_H
XsUShortVector
struct XsUShortVector XsUShortVector
Definition: xsushortvector.h:110
mrpt::containers::operator[]
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
Definition: ts_hash_map.h:199
xstypedefs.h
mrpt::img::operator==
bool operator==(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
Definition: TCamera.cpp:201
v1
GLfloat GLfloat v1
Definition: glext.h:4105
XsUShortVector
A vector containing 3 short values.
Definition: xsushortvector.h:24
v2
GLfloat GLfloat GLfloat v2
Definition: glext.h:4107
XsUShortVector::m_data
unsigned short m_data[3]
vector component storage
Definition: xsushortvector.h:107
index
GLuint index
Definition: glext.h:4054
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:4109
size
GLsizeiptr size
Definition: glext.h:3923
a
GLubyte GLubyte GLubyte a
Definition: glext.h:6279



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST