00001 // vil_nitf2: Written by Harry Voorhees (hlv@) and Rob Radtke (rob@) of 00002 // Stellar Science Ltd. Co. (stellarscience.com) for 00003 // Air Force Research Laboratory, 2005. 00004 00005 #ifndef VIL_NITF2_FIELD_H 00006 #define VIL_NITF2_FIELD_H 00007 00008 #include <vcl_vector.h> 00009 #include <vcl_iostream.h> 00010 // not used? #include <vcl_sstream.h> 00011 #include <vcl_string.h> 00012 00013 class vil_nitf2_date_time; 00014 class vil_nitf2_location; 00015 class vil_nitf2_field_definition; 00016 class vil_nitf2_field_formatter; 00017 class vil_nitf2_index_vector; 00018 class vil_nitf2_scalar_field; 00019 class vil_nitf2_array_field; 00020 00021 #include "vil_nitf2.h" 00022 00023 //----------------------------------------------------------------------------- 00024 // vil_nitf2_field is an instance of a single NITF field (or sequence of repeating 00025 // fields), including its definition and value, as read from (or to be written 00026 // to) a NITF file. 00027 00028 // Abstract base class for scalar and array-valued fields, as read from 00029 // or to be written to a NITF file. This class includes its definition 00030 // information, value information is stored in subclasses. 00031 // 00032 class vil_nitf2_field 00033 { 00034 public: 00035 // Return my identifier 00036 vcl_string tag() const; 00037 00038 // Return my descriptive name 00039 vcl_string pretty_name() const; 00040 00041 // Return my description 00042 vcl_string description() const; 00043 00044 // Return number of dimensions: 0 for scalar fields, positive for array fields 00045 virtual int num_dimensions() const = 0; 00046 00047 // Downcast methods 00048 vil_nitf2_scalar_field* scalar_field(); 00049 vil_nitf2_array_field* array_field(); 00050 00051 // Destructor 00052 virtual ~vil_nitf2_field() {} 00053 00054 // Output to stream (required overload as a reminder to implement operator <<) 00055 virtual vcl_ostream& output(vcl_ostream& os) const = 0; 00056 00057 // Return my element data type 00058 vil_nitf2::enum_field_type type() const; 00059 00060 // Description of the field and pointers to the descriptions 00061 // of child nodes in the true 00062 class field_tree { 00063 public: 00064 vcl_vector< vcl_string > columns; 00065 vcl_vector< field_tree* > children; 00066 ~field_tree(); 00067 }; 00068 00069 // Returns a field tree, which caller owns 00070 virtual field_tree* get_tree() const; 00071 00072 protected: 00073 // Default constructor 00074 vil_nitf2_field(vil_nitf2_field_definition* definition) : m_definition(definition) {} 00075 00076 // Members 00077 vil_nitf2_field_definition* m_definition; 00078 }; 00079 00080 // Output operator 00081 vcl_ostream& operator << (vcl_ostream& os, const vil_nitf2_field& field); 00082 00083 #endif // VIL_NITF2_FIELD_H