RMLVector.h
Go to the documentation of this file.
1 // ---------------------- Doxygen info ----------------------
46 // ----------------------------------------------------------
47 // For a convenient reading of this file's source code,
48 // please use a tab width of four characters.
49 // ----------------------------------------------------------
50 
51 
52 #ifndef __RMLVector__
53 #define __RMLVector__
54 
55 
56 #include <string.h>
57 
58 // ---------------------- Doxygen info ----------------------
75 // ----------------------------------------------------------
76 template <class T = double>
77 class RMLVector
78 {
79 public:
80 
81 // ---------------------- Doxygen info ----------------------
93 // ----------------------------------------------------------
94  RMLVector(const RMLVector<T> &Vector)
95  {
96  this->VectorDimension = Vector.GetVecDim() ;
97  this->VecData = new T[this->VectorDimension] ;
98  *this = Vector ;
99  }
100 
101 
102 // ---------------------- Doxygen info ----------------------
115 // ----------------------------------------------------------
116  RMLVector(const unsigned int Size)
117  {
118 
119  this->VectorDimension = Size ;
120  this->VecData = new T[this->VectorDimension] ;
121 
122  memset( this->VecData
123  , 0x0
124  , (this->VectorDimension * sizeof(T)) );
125  }
126 
127 
128 // ---------------------- Doxygen info ----------------------
143 // ----------------------------------------------------------
144  RMLVector( const T &Component0
145  , const T &Component1 )
146  {
147  this->VectorDimension = 2 ;
148  this->VecData = (T*) new T[this->VectorDimension] ;
149 
150  this->VecData[0] = Component0 ;
151  this->VecData[1] = Component1 ;
152  }
153 
154 
155 // ---------------------- Doxygen info ----------------------
173 // ----------------------------------------------------------
174  RMLVector( const T &Component0
175  , const T &Component1
176  , const T &Component2 )
177  {
178  this->VectorDimension = 3 ;
179  this->VecData = (T*) new T[this->VectorDimension] ;
180 
181  this->VecData[0] = Component0 ;
182  this->VecData[1] = Component1 ;
183  this->VecData[2] = Component2 ;
184  }
185 
186 
187 // ---------------------- Doxygen info ----------------------
208 // ----------------------------------------------------------
209  RMLVector( const T &Component0
210  , const T &Component1
211  , const T &Component2
212  , const T &Component3 )
213  {
214  this->VectorDimension = 4 ;
215  this->VecData = (T*) new T[this->VectorDimension] ;
216 
217  this->VecData[0] = Component0 ;
218  this->VecData[1] = Component1 ;
219  this->VecData[2] = Component2 ;
220  this->VecData[3] = Component3 ;
221  }
222 
223 
224 // ---------------------- Doxygen info ----------------------
247 // ----------------------------------------------------------
248  RMLVector( const T &Component0
249  , const T &Component1
250  , const T &Component2
251  , const T &Component3
252  , const T &Component4 )
253  {
254  this->VectorDimension = 5 ;
255  this->VecData = (T*) new T[this->VectorDimension] ;
256 
257  this->VecData[0] = Component0 ;
258  this->VecData[1] = Component1 ;
259  this->VecData[2] = Component2 ;
260  this->VecData[3] = Component3 ;
261  this->VecData[4] = Component4 ;
262  }
263 
264 
265 // ---------------------- Doxygen info ----------------------
292 // ----------------------------------------------------------
293  RMLVector( const T &Component0
294  , const T &Component1
295  , const T &Component2
296  , const T &Component3
297  , const T &Component4
298  , const T &Component5 )
299  {
300  this->VectorDimension = 6 ;
301  this->VecData = (T*) new T[this->VectorDimension] ;
302 
303  this->VecData[0] = Component0 ;
304  this->VecData[1] = Component1 ;
305  this->VecData[2] = Component2 ;
306  this->VecData[3] = Component3 ;
307  this->VecData[4] = Component4 ;
308  this->VecData[5] = Component5 ;
309  }
310 
311 
312 // ---------------------- Doxygen info ----------------------
342 // ----------------------------------------------------------
343  RMLVector( const T &Component0
344  , const T &Component1
345  , const T &Component2
346  , const T &Component3
347  , const T &Component4
348  , const T &Component5
349  , const T &Component6 )
350  {
351  this->VectorDimension = 7 ;
352  this->VecData = (T*) new T[this->VectorDimension] ;
353 
354  this->VecData[0] = Component0 ;
355  this->VecData[1] = Component1 ;
356  this->VecData[2] = Component2 ;
357  this->VecData[3] = Component3 ;
358  this->VecData[4] = Component4 ;
359  this->VecData[5] = Component5 ;
360  this->VecData[6] = Component6 ;
361  }
362 
363 
364 // ---------------------- Doxygen info ----------------------
369 // ----------------------------------------------------------
371  {
372  delete[] this->VecData;
373  }
374 
375 
376 // ---------------------- Doxygen info ----------------------
383 // ----------------------------------------------------------
384  inline void Set(const T Value)
385  {
386  unsigned int i;
387 
388  for( i = 0; i < this->VectorDimension; i++)
389  {
390  this->VecData[i] = Value;
391  }
392  }
393 
394 
395 // ---------------------- Doxygen info ----------------------
403 // ----------------------------------------------------------
404  inline RMLVector &operator = (const RMLVector<T>& Vector)
405  {
406  memcpy( (void*)(this->VecData)
407  , (void*)(Vector.VecData)
408  , (this->VectorDimension * sizeof(T)) );
409 
410  return(*this);
411  }
412 
413 
414 // ---------------------- Doxygen info ----------------------
425 // ----------------------------------------------------------
426  inline T& operator [] (const int Index)
427  {
428  return(this->VecData[Index]);
429  }
430 
431 
432 // ---------------------- Doxygen info ----------------------
443 // ----------------------------------------------------------
444  inline const T& operator [] (const int Index) const
445  {
446  return(this->VecData[Index]);
447  }
448 
449 
450 // ---------------------- Doxygen info ----------------------
458 // ----------------------------------------------------------
459  inline bool operator == (const RMLVector<T> &Vector) const
460  {
461  unsigned int i;
462 
463  for( i = 0; i < this->VectorDimension; i++)
464  {
465  if( (*this)[i] != Vector[i] )
466  {
467  return(false); // vector components !=
468  }
469  }
470  return(true); // all vector components ==
471  }
472 
473 
474 // ---------------------- Doxygen info ----------------------
481 // ----------------------------------------------------------
482  inline bool operator != (const RMLVector<T> &Vector) const
483  {
484  return(!(*this == Vector));
485  }
486 
487 
488 // ---------------------- Doxygen info ----------------------
496 // ----------------------------------------------------------
497  inline unsigned int GetVecDim(void) const
498  {
499  return(this->VectorDimension);
500  }
501 
502 // ---------------------- Doxygen info ----------------------
510 // ----------------------------------------------------------
511  inline T* GetReference(void) const
512  {
513  return((T*)(&(this->VecData[0])));
514  }
515 
516 
517 // ---------------------- Doxygen info ----------------------
523 // ----------------------------------------------------------
525 
526 
527 // ---------------------- Doxygen info ----------------------
532 // ----------------------------------------------------------
533  unsigned int VectorDimension;
534 
535 
536 
537 }; // class RMLVector
538 
539 
540 // ---------------------- Doxygen info ----------------------
547 // ----------------------------------------------------------
549 
550 
551 // ---------------------- Doxygen info ----------------------
558 // ----------------------------------------------------------
560 
561 
562 // ---------------------- Doxygen info ----------------------
569 // ----------------------------------------------------------
571 
572 
573 
574 #endif
RMLVector< double > RMLDoubleVector
Type definition for vectors of double elements.
Definition: RMLVector.h:548
void Set(const T Value)
Sets all elements of a vector of double elements to one specific value.
Definition: RMLVector.h:384
T * VecData
Pointer to the actual vector data, that is, an array of type T objects.
Definition: RMLVector.h:524
RMLVector< int > RMLIntVector
Type definition for vectors of int elements.
Definition: RMLVector.h:559
RMLVector(const RMLVector< T > &Vector)
Copy constructor of class RMLVector.
Definition: RMLVector.h:94
RMLVector(const T &Component0, const T &Component1, const T &Component2, const T &Component3, const T &Component4, const T &Component5)
Special 6D constructor.
Definition: RMLVector.h:293
bool operator!=(const RMLVector< T > &Vector) const
Unequal operator.
Definition: RMLVector.h:482
RMLVector(const unsigned int Size)
Constructor of class RMLVector, allocates memory for a given number of double elements.
Definition: RMLVector.h:116
RMLVector & operator=(const RMLVector< T > &Vector)
Copy operator.
Definition: RMLVector.h:404
RMLVector(const T &Component0, const T &Component1, const T &Component2, const T &Component3, const T &Component4)
Special 5D constructor.
Definition: RMLVector.h:248
unsigned int VectorDimension
Contains the number of vector elements.
Definition: RMLVector.h:533
RMLVector(const T &Component0, const T &Component1, const T &Component2, const T &Component3)
Special 4D constructor.
Definition: RMLVector.h:209
RMLVector(const T &Component0, const T &Component1, const T &Component2)
Special 3D constructor.
Definition: RMLVector.h:174
T & operator[](const int Index)
Bracket operator, gives access to a single vector element.
Definition: RMLVector.h:426
RMLVector(const T &Component0, const T &Component1, const T &Component2, const T &Component3, const T &Component4, const T &Component5, const T &Component6)
Special 7D constructor.
Definition: RMLVector.h:343
bool operator==(const RMLVector< T > &Vector) const
Equal operator.
Definition: RMLVector.h:459
~RMLVector(void)
Destructor of class RMLVector.
Definition: RMLVector.h:370
T * GetReference(void) const
Returns the data pointer of the vector object (not the pointer to the object)
Definition: RMLVector.h:511
RMLVector< bool > RMLBoolVector
Type definition for vectors of bool elements.
Definition: RMLVector.h:570
unsigned int GetVecDim(void) const
Returns the dimension of the vector.
Definition: RMLVector.h:497
This is a minimalistic dynamic vector class implementation used for the Reflexxes Motion Libraries...
Definition: RMLVector.h:77
RMLVector(const T &Component0, const T &Component1)
Special 2D constructor.
Definition: RMLVector.h:144


libreflexxestype2
Author(s):
autogenerated on Sat Nov 21 2020 03:17:34