OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
EnvisatAsarRecord.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 //
5 // License: LGPL
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 #ifndef EnvisatAsarRecord_h
13 #define EnvisatAsarRecord_h
14 
15 #include <iostream>
16 #include <cstdlib>
17 #include <cstring>
18 #include <ossim/base/ossimCommon.h>
19 
20 namespace ossimplugins
21 {
31 {
32 public:
37  EnvisatAsarRecord(std::string mnemonic);
41  virtual ~EnvisatAsarRecord();
42 
47 
51  virtual EnvisatAsarRecord* Instanciate() =0;
52 
56  virtual EnvisatAsarRecord* Clone()=0;
57 
61  virtual void Read(std::istream& is) =0;
62 
66  virtual void Write(std::ostream& os)=0;
67 
71  std::string get_mnemonic()
72  {
73  return _mnemonic;
74  };
75 
76 
77 
78 protected:
82  template<typename T>
83  void SwitchEndian(T &value) {
84 
85  char *buffer;
86  char *res;
87  int nb_octets = sizeof(T);
88 
90  buffer = (char* )malloc(nb_octets);
91  res = (char* )malloc(nb_octets);
92 
93  memcpy(buffer,&value,nb_octets);
94 
95  for (int i=0; i<nb_octets/2; i++) {
96  res[i] = buffer[nb_octets-1-i];
97  res[nb_octets-1-i] = buffer[i];
98  }
99  memcpy(&value,res,nb_octets);
100 
101  free(buffer);
102  free(res);
103  }
104  }
105 
106 
107  std::string _mnemonic;
108 
109 private:
110 };
111 }
112 #endif
virtual ~EnvisatAsarRecord()
Destructor.
std::string get_mnemonic()
Returns the mnemonic of the record.
virtual EnvisatAsarRecord * Clone()=0
This function is able to create a new instance of the class initialised with the data of the calling ...
void SwitchEndian(T &value)
This function switches the LSB value and the MSB value of the parameter.
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
virtual void Read(std::istream &is)=0
Reads the class data from a stream.
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
virtual EnvisatAsarRecord * Instanciate()=0
This function is able to create a new instance of the class.
virtual void Write(std::ostream &os)=0
Writes the class to a stream.
This class is the base class of all the Envisat ASAR record classes.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
EnvisatAsarRecord(std::string mnemonic)
Constructor.