OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
AlosPalsarRecordHeader.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 // "Copyright Centre for Remote Imaging, Sensing and Processing"
5 //
6 // License: LGPL
7 //
8 // See LICENSE.txt file in the top level directory for more details.
9 //
10 //----------------------------------------------------------------------------
11 // $Id$
12 
14 
15 namespace ossimplugins
16 {
17 
18 
20 {
21 }
22 
24 {
25 }
26 
28 {
29  os << "record_sequence_number:" << data._rec_seq << std::endl;
30  os << "first_record_sub-type:" << (int)data._rec_sub1 << std::endl;
31  os << "record_type_code:" << (int)data._rec_type << std::endl;
32  os << "second_record_sub-type:" << (int)data._rec_sub2 << std::endl;
33  os << "third_record_sub-type:" << (int)data._rec_sub3 << std::endl;
34  os << "length:" << data._length << std::endl;
35  return os;
36 }
37 
39 {
40  is.read((char*)&(data._rec_seq), 4); // TODO Change dangerous C-style cast to static cast.
41  data.SwitchEndian(data._rec_seq);
42  is.read((char*)&(data._rec_sub1), 1);
43  is.read((char*)&(data._rec_type), 1);
44  is.read((char*)&(data._rec_sub2), 1);
45  is.read((char*)&(data._rec_sub3), 1);
46  is.read((char*)&(data._length), 4);
47  data.SwitchEndian(data._length);
48  return is;
49 }
50 
52  _rec_seq(rhs._rec_seq),
53  _rec_sub1(rhs._rec_sub1),
54  _rec_type(rhs._rec_type),
55  _rec_sub2(rhs._rec_sub2),
56  _rec_sub3(rhs._rec_sub3)
57 {
58 }
59 
61 {
62  _rec_seq = rhs._rec_seq;
63  _rec_sub1 = rhs._rec_sub1;
64  _rec_type = rhs._rec_type;
65  _rec_sub2 = rhs._rec_sub2;
66  _rec_sub3 = rhs._rec_sub3;
67  return *this;
68 }
69 
70 void AlosPalsarRecordHeader::SwitchEndian(unsigned int& value)
71 {
72  char buffer[4];
73  char res[4];
74 
75  memcpy(buffer, &value, 4);
76  res[0] = buffer[3];
77  res[1] = buffer[2];
78  res[2] = buffer[1];
79  res[3] = buffer[0];
80 
81  memcpy(&value, res, 4);
82 }
83 }
unsigned char _rec_sub1
First record sub-type code.
This class is able to read a record header.
unsigned char _rec_sub2
Second record sub-type code.
void SwitchEndian(unsigned int &value)
This function switch the LSB value and the MSB value of the parameter.
unsigned char _rec_sub3
Third record sub-type code.
unsigned int _length
Length of this record (in bytes)
AlosPalsarRecordHeader & operator=(const AlosPalsarRecordHeader &rhs)
Copy operator.
unsigned int _rec_seq
Record sequence number.
std::ostream & operator<<(std::ostream &os, const AlosPalsarData &data)
unsigned char _rec_type
Record type code.
std::istream & operator>>(std::istream &is, AlosPalsarData &data)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23