Fast Research Interface Library  Manual and Documentation
include/TypeIRMLVector.h
Go to the documentation of this file.
00001 //  ---------------------- Doxygen info ----------------------
00057 //  ----------------------------------------------------------
00058 //   For a convenient reading of this file's source code,
00059 //   please use a tab width of four characters.
00060 //  ----------------------------------------------------------
00061 #ifndef __TypeIRMLVector__
00062 #define __TypeIRMLVector__
00063 
00064 
00065 #include <string.h>
00066 
00067 //  ---------------------- Doxygen info ----------------------
00084 //  ----------------------------------------------------------
00085 template <class T = double>
00086 class TypeIRMLVector
00087 {
00088 public:
00089 
00090 //  ---------------------- Doxygen info ----------------------
00102 //  ----------------------------------------------------------
00103     TypeIRMLVector(const TypeIRMLVector<T> &Vector)
00104     {
00105         this->VectorDimension       =   Vector.GetVecDim()              ;
00106         this->VecData               =   new T[this->VectorDimension]    ;// REMOVE for debug purposes
00107         *this                       =   Vector                          ;       
00108     }
00109 
00110 
00111 //  ---------------------- Doxygen info ----------------------
00124 //  ----------------------------------------------------------
00125     TypeIRMLVector(const unsigned int Size)
00126     {
00127 
00128         this->VectorDimension       =   Size                            ;
00129         this->VecData               =   new T[this->VectorDimension]    ;// REMOVE for debug purposes
00130 
00131         memset(     this->VecData
00132                 ,   0x0
00133                 ,   (this->VectorDimension * sizeof(T)) );
00134     }
00135 
00136 
00137 //  ---------------------- Doxygen info ----------------------
00152 //  ----------------------------------------------------------
00153     TypeIRMLVector(     const T &Component0
00154                 ,   const T &Component1 )
00155     {
00156         this->VectorDimension       =   2                                   ;
00157         this->VecData               =   (T*) new T[this->VectorDimension]   ;// REMOVE for debug purposes
00158 
00159         this->VecData[0]            =   Component0                          ;
00160         this->VecData[1]            =   Component1                          ;
00161     }
00162 
00163 
00164 //  ---------------------- Doxygen info ----------------------
00182 //  ----------------------------------------------------------
00183     TypeIRMLVector(     const T &Component0
00184                 ,   const T &Component1
00185                 ,   const T &Component2 )
00186     {
00187         this->VectorDimension       =   3                                   ;
00188         this->VecData               =   (T*) new T[this->VectorDimension]   ;// REMOVE for debug purposes
00189 
00190         this->VecData[0]            =   Component0                          ;
00191         this->VecData[1]            =   Component1                          ;
00192         this->VecData[2]            =   Component2                          ;
00193     }
00194 
00195 
00196 //  ---------------------- Doxygen info ----------------------
00217 //  ----------------------------------------------------------
00218     TypeIRMLVector(     const T &Component0
00219                 ,   const T &Component1
00220                 ,   const T &Component2
00221                 ,   const T &Component3 )
00222     {
00223         this->VectorDimension       =   4                                   ;
00224         this->VecData               =   (T*) new T[this->VectorDimension]   ;// REMOVE for debug purposes
00225 
00226         this->VecData[0]            =   Component0                          ;
00227         this->VecData[1]            =   Component1                          ;
00228         this->VecData[2]            =   Component2                          ;
00229         this->VecData[3]            =   Component3                          ;
00230     }
00231 
00232 
00233 //  ---------------------- Doxygen info ----------------------
00256 //  ----------------------------------------------------------
00257     TypeIRMLVector(     const T &Component0
00258                 ,   const T &Component1
00259                 ,   const T &Component2
00260                 ,   const T &Component3
00261                 ,   const T &Component4 )
00262     {
00263         this->VectorDimension       =   5                                   ;
00264         this->VecData               =   (T*) new T[this->VectorDimension]   ;// REMOVE for debug purposes
00265 
00266         this->VecData[0]            =   Component0                          ;
00267         this->VecData[1]            =   Component1                          ;
00268         this->VecData[2]            =   Component2                          ;
00269         this->VecData[3]            =   Component3                          ;
00270         this->VecData[4]            =   Component4                          ;
00271     }
00272 
00273 
00274 //  ---------------------- Doxygen info ----------------------
00301 //  ----------------------------------------------------------
00302     TypeIRMLVector(     const T &Component0
00303                 ,   const T &Component1
00304                 ,   const T &Component2
00305                 ,   const T &Component3
00306                 ,   const T &Component4
00307                 ,   const T &Component5 )
00308     {
00309         this->VectorDimension       =   6                                   ;
00310         this->VecData               =   (T*) new T[this->VectorDimension]   ;// REMOVE for debug purposes
00311 
00312         this->VecData[0]            =   Component0                          ;
00313         this->VecData[1]            =   Component1                          ;
00314         this->VecData[2]            =   Component2                          ;
00315         this->VecData[3]            =   Component3                          ;
00316         this->VecData[4]            =   Component4                          ;
00317         this->VecData[5]            =   Component5                          ;
00318     }
00319 
00320 
00321 //  ---------------------- Doxygen info ----------------------
00351 //  ----------------------------------------------------------
00352     TypeIRMLVector(     const T &Component0
00353                 ,   const T &Component1
00354                 ,   const T &Component2
00355                 ,   const T &Component3
00356                 ,   const T &Component4
00357                 ,   const T &Component5
00358                 ,   const T &Component6 )
00359     {
00360         this->VectorDimension       =   7                                   ;
00361         this->VecData               =   (T*) new T[this->VectorDimension]   ;// REMOVE for debug purposes
00362 
00363         this->VecData[0]            =   Component0                          ;
00364         this->VecData[1]            =   Component1                          ;
00365         this->VecData[2]            =   Component2                          ;
00366         this->VecData[3]            =   Component3                          ;
00367         this->VecData[4]            =   Component4                          ;
00368         this->VecData[5]            =   Component5                          ;
00369         this->VecData[6]            =   Component6                          ;
00370     }
00371 
00372 
00373 //  ---------------------- Doxygen info ----------------------
00378 //  ----------------------------------------------------------
00379     ~TypeIRMLVector(void)
00380     {
00381         delete[] this->VecData;// REMOVE for debug purposes
00382     }
00383 
00384 
00385 //  ---------------------- Doxygen info ----------------------
00392 //  ----------------------------------------------------------
00393     inline void Set(const T Value)
00394     {
00395         unsigned int i;
00396 
00397         for( i = 0; i < this->VectorDimension; i++)
00398         {
00399             this->VecData[i] = Value;
00400         }
00401     }
00402 
00403 
00404 //  ---------------------- Doxygen info ----------------------
00412 //  ----------------------------------------------------------
00413     inline TypeIRMLVector &operator = (const TypeIRMLVector<T>& Vector)
00414     {
00415         memcpy(     (void*)(this->VecData)
00416                 ,   (void*)(Vector.VecData)
00417                 ,   (this->VectorDimension * sizeof(T)) );
00418 
00419         return(*this);
00420     }
00421 
00422 
00423 //  ---------------------- Doxygen info ----------------------
00434 //  ----------------------------------------------------------
00435     inline T& operator [] (const int Index)
00436     {
00437         return(this->VecData[Index]);
00438     }
00439 
00440 
00441 //  ---------------------- Doxygen info ----------------------
00452 //  ----------------------------------------------------------
00453     inline const T& operator [] (const int Index) const
00454     {
00455         return(this->VecData[Index]);
00456     }
00457 
00458 
00459 //  ---------------------- Doxygen info ----------------------
00467 //  ----------------------------------------------------------
00468     inline bool operator == (const TypeIRMLVector<T> &Vector) const
00469     {
00470         unsigned int i;
00471 
00472         for( i = 0; i < this->VectorDimension; i++)
00473         {
00474             if( (*this)[i] != Vector[i] )
00475             {
00476                 return(false); // vector components !=
00477             }
00478         }
00479         return(true); // all vector components ==
00480     }
00481 
00482 
00483 //  ---------------------- Doxygen info ----------------------
00490 //  ----------------------------------------------------------
00491     inline bool operator != (const TypeIRMLVector<T> &Vector) const
00492     {
00493         return(!(*this == Vector));
00494     }
00495 
00496 
00497 //  ---------------------- Doxygen info ----------------------
00505 //  ----------------------------------------------------------
00506     inline unsigned int GetVecDim(void) const
00507     {
00508         return(this->VectorDimension);
00509     }
00510 
00511 //  ---------------------- Doxygen info ----------------------
00519 //  ----------------------------------------------------------
00520     inline T* GetReference(void) const
00521     {
00522         return((T*)VecData);//Uncomment for debug purposes
00523         //return((T*)(&(this->VecData[0])));
00524     }
00525 
00526 
00527 //  ---------------------- Doxygen info ----------------------
00533 //  ----------------------------------------------------------
00534     T               *VecData;   // REMOVE for debug purposes
00535     //T             VecData[20];//Uncomment for debug purposes
00536     
00537     
00538 //  ---------------------- Doxygen info ----------------------
00543 //  ----------------------------------------------------------
00544     unsigned int    VectorDimension;
00545 
00546 
00547 
00548 };  // class TypeIRMLVector
00549 
00550 
00551 //  ---------------------- Doxygen info ----------------------
00558 //  ----------------------------------------------------------
00559 typedef TypeIRMLVector<double>  TypeIRMLDoubleVector;
00560 
00561 
00562 //  ---------------------- Doxygen info ----------------------
00569 //  ----------------------------------------------------------
00570 typedef TypeIRMLVector<int>     TypeIRMLIntVector;
00571 
00572 
00573 //  ---------------------- Doxygen info ----------------------
00580 //  ----------------------------------------------------------
00581 typedef TypeIRMLVector<bool>    TypeIRMLBoolVector;
00582 
00583 
00584 
00585 #endif
This document was generated with Doxygen on Thu Apr 12 2012 11:18:54. User documentation of the Fast Research Interface Library for the KUKA Lightweight Robot IV by the Stanford Robotics Research Group. Copyright 2010–2012.