vil_nitf2_des.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_DES_H
6 #define VIL_NITF2_DES_H
7 
9 class vil_stream;
10 #include <map>
13 
14 #ifdef _MSC_VER
15 # include <vcl_msvc_warnings.h>
16 #endif
17 
18 // Class for representing a single data extension segment (DES) in
19 // a NITF 2.x file. This class can handle TRE overflow DES (DESID=TRE_OVERFLOW)
20 // as well as custom defined data extension segments (DESID=<something else>). Use
21 // the static define() function to tell this class about custom DES' that you want
22 // to support.
23 // It does not,however, handle streaming DES' (DESID=STREAMING_FILE_HEADER). I'm not
24 // sure that those des' are relevant to the nitf files that vil supports
26 {
27 public:
28  vil_nitf2_des( vil_nitf2_classification::file_version version, int data_width );
29  ///read the des starting at stream's current position
30  ///returns false if failed
31  virtual bool read( vil_stream* stream );
32  //virtual bool write( vil_stream* stream );
33 
34  virtual ~vil_nitf2_des();
35 
36  // Sets out_value to the value of field specified by tag.
37  // Returns 0 if such a field is not found or is of the wrong type.
38  template< class T >
39  bool get_property(std::string tag, T& out_value) const
40  {
41  if ( ! m_field_sequence1->get_value( tag, out_value ) && m_field_sequence2 ){
42  return m_field_sequence2->get_value( tag, out_value );
43  }
44  }
45 
46  // Sets out_value to the value of std::vector field element specified by tag and index.
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, int i, T& out_value) const
50  {
51  if( ! m_field_sequence1->get_value( tag, i, out_value ) && m_field_sequence2 ){
52  return m_field_sequence2->get_value( tag, i, out_value );
53  }
54  }
55 
56  // I allocate the return value, but you own it after I return it to you
57  // so you need to delete it.
58  virtual vil_nitf2_field::field_tree* get_tree( int i = 0 ) const;
59 
60  // Call this function to register a DES with this class. Once you've
61  // done this, then this class will be able to parse your custom DES.
62  static vil_nitf2_field_definitions& define( std::string desId );
63 protected:
64  typedef std::map<std::string, vil_nitf2_field_definitions*>
67 
69  static void add_shared_field_defs_2( vil_nitf2_field_definitions* defs, int data_width );
71 
74 };
75 
76 #endif //VIL_NITF2_DES_H
static vil_nitf2_field_definitions & define(std::string desId)
static field_definition_map & all_definitions()
vil_nitf2_field_sequence * m_field_sequence2
Definition: vil_nitf2_des.h:73
static void add_shared_field_defs_1(vil_nitf2_field_definitions *defs)
static void add_shared_field_defs_2(vil_nitf2_field_definitions *defs, int data_width)
bool get_property(std::string tag, T &out_value) const
Definition: vil_nitf2_des.h:39
virtual vil_nitf2_field::field_tree * get_tree(int i=0) const
vil_nitf2_field_sequence * m_field_sequence1
Definition: vil_nitf2_des.h:72
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
vil_nitf2_des(vil_nitf2_classification::file_version version, int data_width)
bool get_property(std::string tag, int i, T &out_value) const
Definition: vil_nitf2_des.h:49
virtual bool read(vil_stream *stream)
read the des starting at stream's current position returns false if failed
virtual ~vil_nitf2_des()
static vil_nitf2_field_definitions * create_field_definitions(vil_nitf2_classification::file_version ver, int data_width)
bool get_value(std::string tag, int &out_value) const
std::map< std::string, vil_nitf2_field_definitions * > field_definition_map
Definition: vil_nitf2_des.h:65