vil_nitf2_classification.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_CLASSIFICATION_H
6 #define VIL_NITF2_CLASSIFICATION_H
7 
8 #include <string>
9 #include <map>
10 #include <utility>
11 #include "vil_nitf2.h"
12 
13 #ifdef _MSC_VER
14 # include <vcl_msvc_warnings.h>
15 #endif
16 
18 
19 // A purely static class that generates classification field definitions.
20 // Use \sa get_field_definitions() to get a field definition that will
21 // parse either a nitf 2.1 or nitf 2.0 stream. Note that the two are
22 // very different, so be sure to ask for the right one. They don't even
23 // have the same field width. In NITF 2.1, the classification string is
24 // fixed at 205 characters. In NITF 2.0, it can either be 167 or 207
25 // characters depending on whether the conditional field SDEVT is present
26 // or not. The field names also vary according to the type of header
27 // that contains them.
28 //
30 {
31 public:
32 
33  // NITF file version
35  {
37  // If you weren't confused enough already, now we're telling you
38  // that NSIF 1.0 is the same as NITF 2.1. It's true though.
40  };
41 
42  // Classification fields are used in a number of places with slightly
43  // different tag names and pretty names. In the file header the first
44  // classification field is "FSCLAS" ("File Security Classification");
45  // in the image subheader, the corresponding field is "ISCLAS"
46  // ("Image Security Classification"). Fortunately, these differences
47  // are consistent, so all tag names in one context can be generated by
48  // prepending the same string to the base tag name; similarly for
49  // the fields' pretty names. The tag_prefix and pretty_name_prefix
50  // argument below allow the caller to generate the field definitions
51  // appropriate to the context, e.g., "F" and "File", respectively,
52  // in the case of a file header.
54  const file_version& version,
55  std::string tag_prefix, std::string pretty_name_prefix );
56 
57  // Like get_field_defintions(), but appends fields to defs instead
58  // of returning them.
59  static void add_field_defs(
60  vil_nitf2_field_definitions* defs, const file_version& version,
61  std::string prefix, const std::string& pretty_name_prefix);
62 
63 private:
64  // Purely static class; don't instantiate.
65  vil_nitf2_classification() = delete;
66 
67  // A cache of field definitions, indexed by version, tag_prefix and
68  // pretty_name_prefix.
69  typedef std::pair< file_version, std::pair< std::string, std::string> >
71  typedef std::map< type_field_defs_key, vil_nitf2_field_definitions*>
74 
75  // so these static members can be cleaned up when the program is done
76  // using nitf files
77  friend class type_field_defs_map_t;
78 };
79 
80 #endif //VIL_NITF2_CLASSIFICATION_H
std::pair< file_version, std::pair< std::string, std::string > > type_field_defs_key
static void add_field_defs(vil_nitf2_field_definitions *defs, const file_version &version, std::string prefix, const std::string &pretty_name_prefix)
static type_field_defs_map & s_field_definitions()
std::map< type_field_defs_key, vil_nitf2_field_definitions * > type_field_defs_map
static const vil_nitf2_field_definitions * get_field_definitions(const file_version &version, std::string tag_prefix, std::string pretty_name_prefix)