Changeset 2441 in Sophya for trunk/SophyaLib/BaseTools/ppersist.h


Ignore:
Timestamp:
Oct 3, 2003, 3:39:33 PM (22 years ago)
Author:
ansari
Message:

1) Premiere serie des modifications et ajout fonctionalites pour les PPersist:

  • Ecriture/lecture complex<> et tableaux de complex
  • Ecriture/lecture int_1, uint_1 et tableaux de
  • Tag de positionnement et table de tag de positionnement

2) Adaptation de Read/Write NDataBlock et suppression du fichier piocmplx.h

Reza 03/10/2003

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/ppersist.h

    r1202 r2441  
    1717#include <time.h>
    1818
     19#include <complex>
    1920#include <string>
    2021#include <map>
     
    9394    static void Initialize();   // Pour initialiser classList
    9495
     96    int    Version() {return version;}  // PIn/OutPersist version number
    9597    string FileName() { return filename; }   // Retourne le nom de fichier
    9698
     
    109111          PPS_OBJECT = 2,           // classId, data...
    110112          PPS_REFERENCE = 3,        // objectId
    111           PPS_TAG = 4,              // tag entries
     113          PPS_NAMETAG_TABLE = 4,    // Name tag table (Written at the end of file/stream)
    112114          PPS_EOF = 5,              // Just before tag infomation, offset to PPS_TAG
    113115          PPS_ENDOBJECT = 6,        // marks the end of a given object information
    114           PPS_TAG_MARK = 7,         // To have a name tag, position marker in a file
     116          PPS_NAMETAG_MARK = 7,     // To have a name tag, position marker in a file
     117          PPS_POSTAG_MARK = 8,      // Position tag mark + 8 bytes (=stream position)
     118          PPS_POSTAG_TABLE = 40,    // Position tag table + 8 bytes (=stream position)
    115119          PPS_SIMPLE = 16,          // 16 + number of bytes, up to 8 bytes
    116120          PPS_SIMPLE_ARRAY4 = 32,   // 32 + number of bytes, up to 8 bytes, then 4 bytes of length
     
    120124   enum  {PPS_DATATYPE_CHAR = 0,        // 0  : DataType=character
    121125          PPS_DATATYPE_FLOAT = 64,      // 64 : DataType=float
     126          PPS_DATATYPE_COMPLEX = 65,    // 65 : DataType=complex
    122127          PPS_DATATYPE_INTEGER = 128,   // 128 :DataType=integer
    123128          PPS_DATATYPE_UNSIGNED = 192   // 192 :DataType=Unsigned integer
     
    126131    map<string, int_8> tags;
    127132    string filename;
     133    int version;     // PPersist(In/Out) version
    128134  };
    129135
    130136
    131   // TBD : use hash tables instead of maps. Check hashtbl status in STL.
     137// TBD : use hash tables instead of maps. Check hashtbl status in STL.
    132138
    133139//! Input stream for PPersit objects.
     
    137143    ~PInPersist();
    138144
    139     bool   GotoTag(string const& name);
     145    // Gestion des tags
     146    bool   GotoPositionTag(int_8 pos);
     147    bool   GotoNameTag(string const& name);
     148    inline bool   GotoTag(string const& name) { return GotoNameTag(name); }
    140149    int    NbTags();
    141150    bool   GotoTagNum(int itag);  // 0..NbTags-1
     
    144153    vector<string> const &  GetTagNames(); 
    145154
     155    // Lecture donnees de base et tableaux de donnees de base
     156    // Basic data type (and corresponding arrays) reading
    146157    void   GetByte (char& c);
    147158    void   GetBytes(void* ptr, size_t bytes);
     
    150161    void   GetR8   (r_8&);
    151162    void   GetR8s  (r_8*, size_t);
     163    void   GetI1   (int_1&);
     164    void   GetI1s  (int_1*, size_t);
     165    void   GetU1   (uint_1&);
     166    void   GetU1s  (uint_1*, size_t);
    152167    void   GetI2   (int_2&);
    153168    void   GetI2s  (int_2*, size_t);
     
    164179    void   GetLine (char* ptr, size_t len);
    165180    void   GetStr  (string&);
    166 
    167     void   Get(char&   c) {GetByte(c);}
    168     void   Get(r_4&    x) {GetR4(x);}
    169     void   Get(r_8&    x) {GetR8(x);}
    170     void   Get(uint_2& x) {GetU2(x);}
    171     void   Get(int_2&  x) {GetI2(x);}
    172     void   Get(uint_4& x) {GetU4(x);}
    173     void   Get(int_4&  x) {GetI4(x);}
    174     void   Get(uint_8& x) {GetU8(x);}
    175     void   Get(int_8&  x) {GetI8(x);}
    176     void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
    177     void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
    178     void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
    179     void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
    180     void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
    181     void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
    182     void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
    183     void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
    184     void   Get(string& x) {GetStr(x);}
    185  
     181    void   GetZ4   (complex<r_4> &);
     182    void   GetZ4s  (complex<r_4> *, size_t);
     183    void   GetZ8   (complex<r_8> &);
     184    void   GetZ8s  (complex<r_8> *, size_t);
     185
     186    inline void   Get(char&   c) {GetByte(c);}
     187    inline void   Get(r_4&    x) {GetR4(x);}
     188    inline void   Get(r_8&    x) {GetR8(x);}
     189    inline void   Get(uint_1& x) {GetU1(x);}
     190    inline void   Get(int_1&  x) {GetI1(x);}
     191    inline void   Get(uint_2& x) {GetU2(x);}
     192    inline void   Get(int_2&  x) {GetI2(x);}
     193    inline void   Get(uint_4& x) {GetU4(x);}
     194    inline void   Get(int_4&  x) {GetI4(x);}
     195    inline void   Get(uint_8& x) {GetU8(x);}
     196    inline void   Get(int_8&  x) {GetI8(x);}
     197    inline void   Get(complex<r_4> & x) {GetZ4(x);}
     198    inline void   Get(complex<r_8> & x) {GetZ8(x);}
     199
     200    inline void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
     201    inline void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
     202    inline void   Get(uint_1* x, size_t n) {GetU1s(x,n);}
     203    inline void   Get(int_1*  x, size_t n) {GetI1s(x,n);}
     204    inline void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
     205    inline void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
     206    inline void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
     207    inline void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
     208    inline void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
     209    inline void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
     210    inline void   Get(string& x) {GetStr(x);}
     211    inline void   Get(complex<r_4> * x, size_t n) { GetZ4s(x, n); }
     212    inline void   Get(complex<r_8> * x, size_t n) { GetZ8s(x, n); }
     213
     214    // Reading a list (table) of position tags
     215    void    GetPosTagTable(int_8*, size_t);
     216    void    GetPosTagTable(vector<int_8>&);
     217
    186218    //   Object Reading
    187219    PPersist*  ReadObject();
     
    190222    PPersist*  GetPPObject(AnyDataObj * po=NULL);
    191223
    192     int    Version() {return version;}
    193224    time_t CreationDate() { return creationdate; }
    194225    string CreationDateStr();
     
    219250
    220251    bool bigEndian;
    221     int version;
    222252
    223253    time_t creationdate;
     
    237267    ~POutPersist();
    238268
    239     void WriteTag(string const& name);
     269    // Ecriture de tags
     270    int_8 WritePositionTag();
     271    void  WriteNameTag(string const& name);
     272    inline void WriteTag(string const& name) { WriteNameTag(name); }
    240273 
    241274    void PutByte (char c);
     
    245278    void PutR8   (r_8);
    246279    void PutR8s  (r_8 const*, size_t);
     280    void PutI1   (int_1);
     281    void PutI1s  (int_1 const*, size_t);
     282    void PutU1   (uint_1);
     283    void PutU1s  (uint_1 const*, size_t);
    247284    void PutI2   (int_2);
    248285    void PutI2s  (int_2 const*, size_t);
     
    259296    void PutLine (char const* ptr, size_t len=0); // deprecated ?
    260297    void PutStr  (string const&);
    261     void PutPPObject (PPersist const*); // Like doing Write(stream) on PPersist object
    262 
    263     void PutObject(AnyDataObj & o);   // Creates the corresponding PPersist Object and call Write()
    264     void PutObject(AnyDataObj & o, string tagname);
     298    void PutZ4   (complex<r_4>);
     299    void PutZ4s  (complex<r_4> const*, size_t);
     300    void PutZ8   (complex<r_8>);
     301    void PutZ8s  (complex<r_8> const*, size_t);
     302
    265303
    266304    void   Put(char   c) {PutByte(c);}
    267305    void   Put(r_4    x) {PutR4(x);}
    268306    void   Put(r_8    x) {PutR8(x);}
     307    void   Put(complex<r_4>   x) {PutZ4(x);}
     308    void   Put(complex<r_8>   x) {PutZ8(x);}
     309    void   Put(uint_1 x) {PutU1(x);}
     310    void   Put(int_1  x) {PutI1(x);}
    269311    void   Put(uint_2 x) {PutU2(x);}
    270312    void   Put(int_2  x) {PutI2(x);}
     
    275317    void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
    276318    void   Put(r_8 const*    x, size_t n) {PutR8s(x,n);}
     319    void   Put(complex<r_4> const*    x, size_t n) {PutZ4s(x,n);}
     320    void   Put(complex<r_8> const*    x, size_t n) {PutZ8s(x,n);}
     321    void   Put(uint_1 const* x, size_t n) {PutU1s(x,n);}
     322    void   Put(int_1 const*  x, size_t n) {PutI1s(x,n);}
    277323    void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
    278324    void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
     
    283329    void   Put(string const& s) {PutStr(s);}
    284330    void   Put(PPersist const* x) {PutPPObject(x);}
     331
     332    // Writing a list of position tag table
     333    void   PutPosTagTable(int_8 const *, size_t);
     334    void   PutPosTagTable(vector<int_8> const&);
     335
     336    // Objet Write - Ecriture des objets
     337    void PutPPObject (PPersist const*); // Like doing Write(stream) on PPersist object
     338
     339    void PutObject(AnyDataObj & o);   // Creates the corresponding PPersist Object and call Write()
     340    void PutObject(AnyDataObj & o, string tagname);
    285341
    286342
     
    310366  };
    311367 
    312  
     368
     369// Le macro suivant permettent de simplifier la declaration
     370// des operateurs >> << sur les POutPersist et  PInPersist
    313371#define RAWPERSISTIO(_Type_,_xtyp_)                                             \
    314372  inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
     
    324382  }                                                                               
    325383
     384// On utilise le macro RAWPERSISTIO pour declarer POutPersist << et PInPersist >>
     385// pour les types de base r_4 r_8 int_4 int_8 ...
    326386  RAWPERSISTIO(int_4,I4);
    327387  RAWPERSISTIO(uint_4,U4);
     
    331391  RAWPERSISTIO(r_4,R4);
    332392  RAWPERSISTIO(r_8,R8);
     393  RAWPERSISTIO(complex<r_4>,Z4);
     394  RAWPERSISTIO(complex<r_8>,Z8);
     395  RAWPERSISTIO(string,Str);
    333396 
    334397#if 0
Note: See TracChangeset for help on using the changeset viewer.