| Line |  | 
|---|
| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | /*  Classe vecteurs de type non constant (template)     */ | 
|---|
| 3 | /*                    E. Aubourg, E. Lesquoy            */ | 
|---|
| 4 | /*        Modifs             R. Ansari 04/95            */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef RZVECT_SEEN | 
|---|
| 7 | #define RZVECT_SEEN | 
|---|
| 8 |  | 
|---|
| 9 | #include "machdefs.h" | 
|---|
| 10 | #include "pexceptions.h" | 
|---|
| 11 | #include "perrors.h" | 
|---|
| 12 |  | 
|---|
| 13 | template <class T> | 
|---|
| 14 | class RzVect EXC_AWARE { | 
|---|
| 15 | public: | 
|---|
| 16 | RzVect(int n, T* data); | 
|---|
| 17 | RzVect(int n); | 
|---|
| 18 | virtual           ~RzVect(); | 
|---|
| 19 | inline int&       NImgRef()         {return nImgRef;} | 
|---|
| 20 | inline int&       Shareable()       {return shareable;} | 
|---|
| 21 | inline T&         operator[](int i); | 
|---|
| 22 | inline const T&   operator[](int i) const; | 
|---|
| 23 | int               IElem(int k) const; | 
|---|
| 24 | float             FElem(int k) const; | 
|---|
| 25 | double            DElem(int k) const; | 
|---|
| 26 |  | 
|---|
| 27 | T*                p; | 
|---|
| 28 | int               nElt; | 
|---|
| 29 |  | 
|---|
| 30 | private: | 
|---|
| 31 | int           nImgRef;    // Combien d'images font reference au meme RzVect ? | 
|---|
| 32 | // Le constructeur le met a *** 1 *** | 
|---|
| 33 | // Donc une image doit le changer lorsqu'elle pointe sans allouer. | 
|---|
| 34 | int           shareable;  // Dit si le RzVect peut etre partage. Mis a 0 par exemple si | 
|---|
| 35 | // le tableau de nombres est en memoire partagee. | 
|---|
| 36 | int           ownTable;   // Dit si le RzVect peut faire delete du tableau. | 
|---|
| 37 | }; | 
|---|
| 38 |  | 
|---|
| 39 | template <class T> | 
|---|
| 40 | inline T& RzVect<T>::operator[](int i) | 
|---|
| 41 | { | 
|---|
| 42 | #ifdef RGCHECK | 
|---|
| 43 | if (i<0 || i>=nElt) THROW(rangeCheckErr); | 
|---|
| 44 | #endif | 
|---|
| 45 | return p[i]; | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 | template <class T> | 
|---|
| 49 | inline const T& RzVect<T>::operator[](int i) const | 
|---|
| 50 | { | 
|---|
| 51 | #ifdef RGCHECK | 
|---|
| 52 | if (i<0 || i>=nElt) THROW(rangeCheckErr); | 
|---|
| 53 | #endif | 
|---|
| 54 | return p[i]; | 
|---|
| 55 | } | 
|---|
| 56 |  | 
|---|
| 57 | template <class T> | 
|---|
| 58 | inline int RzVect<T>::IElem(int k) const | 
|---|
| 59 | { | 
|---|
| 60 | return (int) (*this)[k]; | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | template <class T> | 
|---|
| 64 | inline float RzVect<T>::FElem(int k) const | 
|---|
| 65 | { | 
|---|
| 66 | return (float) (*this)[k]; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | template <class T> | 
|---|
| 70 | inline double RzVect<T>::DElem(int k) const | 
|---|
| 71 | { | 
|---|
| 72 | return (double) (*this)[k]; | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | #endif | 
|---|
| 76 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.