vil_nitf2_header.h
Go to the documentation of this file.
1 // vil_nitf2: Written by Rob Radtke (rob@) and Harry Voorhees (hlv@) of
2 // Stellar Science Ltd. Co. (stellarscience.com) for
3 // Air Force Research Laboratory, 2005.
4 
5 #ifndef VIL_NITF2_HEADER_H
6 #define VIL_NITF2_HEADER_H
7 
10 #include "vil_nitf2.h"
11 
12 class vil_stream;
13 
14 
15 /// Parses a NITF 2.1 file header for vil_nitf2_image.
16 /// Use get_property() to get a field value.
17 //
19 {
20 public:
22 
23  virtual ~vil_nitf2_header();
24 
25  enum portion_type {
28  };
29  enum section_type {
37  };
38  static std::string section_num_tag(section_type sec);
39  static std::string section_len_header_tag(section_type sec);
40  static std::string section_len_data_tag(section_type sec);
41 
42  // Read the image header starting at stream's current position. Return success.
43  virtual bool read( vil_stream* stream );
44  //virtual bool write( vil_stream* stream );
45 
46  // Sets out_value to the value of field specified by tag.
47  // Returns 0 if such a field is not found or is of the wrong type.
48  template< class T >
49  bool get_property(std::string tag, T& out_value) const
50  {
51  if ( m_field_sequence_classification && m_field_sequence_classification->get_value(tag, out_value) ) return true;
52  else if ( m_field_sequence2 && m_field_sequence2->get_value(tag, out_value) ) return true;
53  else return m_field_sequence1.get_value(tag, out_value);
54  }
55 
56  // Sets out_value to the value of std::vector field element specified by tag and index.
57  // Returns 0 if such a field is not found or is of the wrong type.
58  template< class T >
59  bool get_property(std::string tag, int i, T& out_value) const
60  {
61  if ( m_field_sequence_classification && m_field_sequence_classification->get_value(tag, i, out_value) ) return true;
62  else if ( m_field_sequence2 && m_field_sequence2->get_value(tag, i, out_value) ) return true;
63  else return m_field_sequence1.get_value(tag, i, out_value);
64  }
65 
67 
68  // I allocate the return value, but you own it after I return it to you
69  // so you need to delete it.
70  virtual vil_nitf2_field::field_tree* get_tree() const;
71 
72 protected:
73  // Field sequences for different parts of this header.
77 
78  // Returns field definitions, which I own, for different parts of the header.
81 
82 private:
86 
87  // so these static members can be cleaned up when the program is done
88  // using nitf files
90 };
91 
92 #endif // VIL_NITF2_HEADER_H
static vil_nitf2_field_definitions * s_field_definitions_21
static vil_nitf2_field_definitions * get_field_definitions_2(vil_nitf2_classification::file_version version)
static vil_nitf2_field_definitions * s_field_definitions_1
vil_nitf2_classification::file_version file_version() const
static std::string section_len_data_tag(section_type sec)
virtual vil_nitf2_field::field_tree * get_tree() const
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
virtual bool read(vil_stream *stream)
vil_nitf2_field_sequence * m_field_sequence_classification
virtual ~vil_nitf2_header()
bool get_property(std::string tag, int i, T &out_value) const
vil_nitf2_field_sequence * m_field_sequence2
Parses a NITF 2.1 file header for vil_nitf2_image.
static std::string section_len_header_tag(section_type sec)
static vil_nitf2_field_definitions * s_field_definitions_20
bool get_value(std::string tag, int &out_value) const
static std::string section_num_tag(section_type sec)
static void cleanup_static_members()
Call this function to flush all of the nitf2 classes statically allocated memory.
Definition: vil_nitf2.cxx:14
bool get_property(std::string tag, T &out_value) const
vil_nitf2_field_sequence m_field_sequence1
static vil_nitf2_field_definitions * get_field_definitions_1()