Reflexxes Motion Libraries  Manual and Documentation (Type II, Version 1.2.6)
include/RMLVector.h
Go to the documentation of this file.
00001 //  ---------------------- Doxygen info ----------------------
00046 //  ----------------------------------------------------------
00047 //   For a convenient reading of this file's source code,
00048 //   please use a tab width of four characters.
00049 //  ----------------------------------------------------------
00050
00051
00052 #ifndef __RMLVector__
00053 #define __RMLVector__
00054 
00055
00056 #include <string.h>
00057
00058 //  ---------------------- Doxygen info ----------------------
00075 //  ----------------------------------------------------------
00076 template <class T = double>
00077 class RMLVector
00078 {
00079 public:
00080
00081 //  ---------------------- Doxygen info ----------------------
00093 //  ----------------------------------------------------------
00094     RMLVector(const RMLVector<T> &Vector)
00095     {
00096         this->VectorDimension       =   Vector.GetVecDim()              ;
00097         this->VecData               =   new T[this->VectorDimension]    ;
00098         *this                       =   Vector                          ;
00099     }
00100
00101
00102 //  ---------------------- Doxygen info ----------------------
00115 //  ----------------------------------------------------------
00116     RMLVector(const unsigned int Size)
00117     {
00118
00119         this->VectorDimension       =   Size                            ;
00120         this->VecData               =   new T[this->VectorDimension]    ;
00121
00122         memset(     this->VecData
00123                 ,   0x0
00124                 ,   (this->VectorDimension * sizeof(T)) );
00125     }
00126
00127
00128 //  ---------------------- Doxygen info ----------------------
00143 //  ----------------------------------------------------------
00144     RMLVector(      const T &Component0
00145                 ,   const T &Component1 )
00146     {
00147         this->VectorDimension       =   2                                   ;
00148         this->VecData               =   (T*) new T[this->VectorDimension]   ;
00149
00150         this->VecData[0]            =   Component0                          ;
00151         this->VecData[1]            =   Component1                          ;
00152     }
00153
00154
00155 //  ---------------------- Doxygen info ----------------------
00173 //  ----------------------------------------------------------
00174     RMLVector(      const T &Component0
00175                 ,   const T &Component1
00176                 ,   const T &Component2 )
00177     {
00178         this->VectorDimension       =   3                                   ;
00179         this->VecData               =   (T*) new T[this->VectorDimension]   ;
00180
00181         this->VecData[0]            =   Component0                          ;
00182         this->VecData[1]            =   Component1                          ;
00183         this->VecData[2]            =   Component2                          ;
00184     }
00185
00186
00187 //  ---------------------- Doxygen info ----------------------
00208 //  ----------------------------------------------------------
00209     RMLVector(      const T &Component0
00210                 ,   const T &Component1
00211                 ,   const T &Component2
00212                 ,   const T &Component3 )
00213     {
00214         this->VectorDimension       =   4                                   ;
00215         this->VecData               =   (T*) new T[this->VectorDimension]   ;
00216
00217         this->VecData[0]            =   Component0                          ;
00218         this->VecData[1]            =   Component1                          ;
00219         this->VecData[2]            =   Component2                          ;
00220         this->VecData[3]            =   Component3                          ;
00221     }
00222
00223
00224 //  ---------------------- Doxygen info ----------------------
00247 //  ----------------------------------------------------------
00248     RMLVector(      const T &Component0
00249                 ,   const T &Component1
00250                 ,   const T &Component2
00251                 ,   const T &Component3
00252                 ,   const T &Component4 )
00253     {
00254         this->VectorDimension       =   5                                   ;
00255         this->VecData               =   (T*) new T[this->VectorDimension]   ;
00256
00257         this->VecData[0]            =   Component0                          ;
00258         this->VecData[1]            =   Component1                          ;
00259         this->VecData[2]            =   Component2                          ;
00260         this->VecData[3]            =   Component3                          ;
00261         this->VecData[4]            =   Component4                          ;
00262     }
00263
00264
00265 //  ---------------------- Doxygen info ----------------------
00292 //  ----------------------------------------------------------
00293     RMLVector(      const T &Component0
00294                 ,   const T &Component1
00295                 ,   const T &Component2
00296                 ,   const T &Component3
00297                 ,   const T &Component4
00298                 ,   const T &Component5 )
00299     {
00300         this->VectorDimension       =   6                                   ;
00301         this->VecData               =   (T*) new T[this->VectorDimension]   ;
00302
00303         this->VecData[0]            =   Component0                          ;
00304         this->VecData[1]            =   Component1                          ;
00305         this->VecData[2]            =   Component2                          ;
00306         this->VecData[3]            =   Component3                          ;
00307         this->VecData[4]            =   Component4                          ;
00308         this->VecData[5]            =   Component5                          ;
00309     }
00310
00311
00312 //  ---------------------- Doxygen info ----------------------
00342 //  ----------------------------------------------------------
00343     RMLVector(      const T &Component0
00344                 ,   const T &Component1
00345                 ,   const T &Component2
00346                 ,   const T &Component3
00347                 ,   const T &Component4
00348                 ,   const T &Component5
00349                 ,   const T &Component6 )
00350     {
00351         this->VectorDimension       =   7                                   ;
00352         this->VecData               =   (T*) new T[this->VectorDimension]   ;
00353
00354         this->VecData[0]            =   Component0                          ;
00355         this->VecData[1]            =   Component1                          ;
00356         this->VecData[2]            =   Component2                          ;
00357         this->VecData[3]            =   Component3                          ;
00358         this->VecData[4]            =   Component4                          ;
00359         this->VecData[5]            =   Component5                          ;
00360         this->VecData[6]            =   Component6                          ;
00361     }
00362
00363
00364 //  ---------------------- Doxygen info ----------------------
00369 //  ----------------------------------------------------------
00370     ~RMLVector(void)
00371     {
00372         delete[] this->VecData;
00373     }
00374
00375
00376 //  ---------------------- Doxygen info ----------------------
00383 //  ----------------------------------------------------------
00384     inline void Set(const T Value)
00385     {
00386         unsigned int i;
00387
00388         for( i = 0; i < this->VectorDimension; i++)
00389         {
00390             this->VecData[i] = Value;
00391         }
00392     }
00393
00394
00395 //  ---------------------- Doxygen info ----------------------
00403 //  ----------------------------------------------------------
00404     inline RMLVector &operator = (const RMLVector<T>& Vector)
00405     {
00406         memcpy(     (void*)(this->VecData)
00407                 ,   (void*)(Vector.VecData)
00408                 ,   (this->VectorDimension * sizeof(T)) );
00409
00410         return(*this);
00411     }
00412
00413
00414 //  ---------------------- Doxygen info ----------------------
00425 //  ----------------------------------------------------------
00426     inline T& operator [] (const int Index)
00427     {
00428         return(this->VecData[Index]);
00429     }
00430
00431
00432 //  ---------------------- Doxygen info ----------------------
00443 //  ----------------------------------------------------------
00444     inline const T& operator [] (const int Index) const
00445     {
00446         return(this->VecData[Index]);
00447     }
00448
00449
00450 //  ---------------------- Doxygen info ----------------------
00458 //  ----------------------------------------------------------
00459     inline bool operator == (const RMLVector<T> &Vector) const
00460     {
00461         unsigned int i;
00462
00463         for( i = 0; i < this->VectorDimension; i++)
00464         {
00465             if( (*this)[i] != Vector[i] )
00466             {
00467                 return(false); // vector components !=
00468             }
00469         }
00470         return(true); // all vector components ==
00471     }
00472
00473
00474 //  ---------------------- Doxygen info ----------------------
00481 //  ----------------------------------------------------------
00482     inline bool operator != (const RMLVector<T> &Vector) const
00483     {
00484         return(!(*this == Vector));
00485     }
00486
00487
00488 //  ---------------------- Doxygen info ----------------------
00496 //  ----------------------------------------------------------
00497     inline unsigned int GetVecDim(void) const
00498     {
00499         return(this->VectorDimension);
00500     }
00501
00502 //  ---------------------- Doxygen info ----------------------
00510 //  ----------------------------------------------------------
00511     inline T* GetReference(void) const
00512     {
00513         return((T*)(&(this->VecData[0])));
00514     }
00515
00516
00517 //  ---------------------- Doxygen info ----------------------
00523 //  ----------------------------------------------------------
00524     T               *VecData;
00525
00526
00527 //  ---------------------- Doxygen info ----------------------
00532 //  ----------------------------------------------------------
00533     unsigned int    VectorDimension;
00534
00535
00536
00537 };  // class RMLVector
00538
00539
00540 //  ---------------------- Doxygen info ----------------------
00547 //  ----------------------------------------------------------
00548 typedef RMLVector<double>   RMLDoubleVector;
00549
00550
00551 //  ---------------------- Doxygen info ----------------------
00558 //  ----------------------------------------------------------
00559 typedef RMLVector<int>      RMLIntVector;
00560
00561
00562 //  ---------------------- Doxygen info ----------------------
00569 //  ----------------------------------------------------------
00570 typedef RMLVector<bool>     RMLBoolVector;
00571
00572
00573
00574 #endif
User documentation of the Reflexxes Motion Libraries by Reflexxes GmbH (Company Information, Impressum). This document was generated with Doxygen on Mon Jul 7 2014 13:21:08. Copyright 2010–2014.