vil_nitf2_classification.cxx
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 
6 
10 
11 #include <cassert>
12 #ifdef _MSC_VER
13 # include <vcl_msvc_warnings.h>
14 #endif
15 
16 
18 {
20  {
21  public:
23  {
24  for (auto & it : *this)
25  {
26  delete it.second;
27  }
28  }
29  };
30  static type_field_defs_map_t field_definitions;
31  return field_definitions;
32 }
33 
36  std::string tag_prefix, std::string pretty_name_prefix)
37 {
38  vil_nitf2_field_definitions* field_defs = nullptr;
39  if (version == V_NITF_20 || version == V_NITF_21) {
41  std::make_pair(version, std::make_pair(tag_prefix, pretty_name_prefix));
42  type_field_defs_map::const_iterator map_entry = s_field_definitions().find(key);
43  if (map_entry != s_field_definitions().end()) {
44  field_defs = map_entry->second;
45  } else {
46  field_defs = new vil_nitf2_field_definitions();
47  add_field_defs(field_defs, version, tag_prefix, pretty_name_prefix);
48  s_field_definitions().insert(std::make_pair(key, field_defs));
49  }
50  }
51  else
52  assert(!"vil_nitf2_classification::get_field_definitions() called with unsupported version!");
53  return field_defs;
54 }
55 
58  std::string tag_prefix, const std::string& pretty_name_prefix)
59 {
60  const std::string& tp = tag_prefix;
61  const std::string np = pretty_name_prefix + " ";
62  switch (version)
63  {
64  case V_NITF_20:
65  (*defs)
66  .field(tp+"SCLAS", np+"Security Classification",
68  .value("T", "Top Secret")
69  .value("S", "Secret")
70  .value("C", "Confidential")
71  .value("R", "Restricted")
72  .value("U", "Unclassified")),
73  false, nullptr, nullptr)
74  .field(tp+"SCODE", np+"Codewords", NITF_STR_ECSA(40), true, nullptr, nullptr)
75  .field(tp+"SCTLH", np+"Control and Handling", NITF_STR_ECSA(40), true, nullptr, nullptr)
76  .field(tp+"SREL", np+"Releasing Instructions", NITF_STR_ECSA(40), true, nullptr, nullptr)
77  .field(tp+"SCAUT", np+"Classification Authority", NITF_STR_ECSA(20), true, nullptr, nullptr)
78  .field(tp+"SCTLN", np+"Security Control Number", NITF_STR_ECSA(20), true, nullptr, nullptr)
79  .field(tp+"SDWNG", np+"Security Downgrade", NITF_STR_ECSA(6), true, nullptr, nullptr)
80  .field(tp+"SDEVT", np+"Downgrading Event", NITF_STR_ECSA(40), true, nullptr,
81  new vil_nitf2_field_value_one_of<std::string>(tp+"SDWNG", "999998"));
82  break;
83  case V_NITF_21:
84  (*defs)
85  .field(tp+"SCLAS", np+"Security Classification",
87  .value("T", "Top Secret")
88  .value("S", "Secret")
89  .value("C", "Confidential")
90  .value("R", "Restricted")
91  .value("U", "Unclassified")),
92  false, nullptr, nullptr)
93  .field(tp+"SCLSY", np+"Security Classification System", NITF_STR_ECSA(2), true, nullptr, nullptr)
94  .field(tp+"SCODE", np+"Codewords", NITF_STR_ECSA(11), true, nullptr, nullptr)
95  .field(tp+"SCTLH", np+"Control and Handling", NITF_STR_ECSA(2), true, nullptr, nullptr)
96  .field(tp+"SREL", np+"Releasing Instructions", NITF_STR_ECSA(20), true, nullptr, nullptr)
97  //TODO: should this be an enum that accepts only DD, DE, GD, GE, 0, X and <blank>?
98  .field(tp+"SDCTP", np+"Declassification Type", NITF_STR_ECSA(2), true, nullptr, nullptr)
99  //this field def is only used for NITF2.1, so we can use NitfDT
100  .field(tp+"SDCDT", np+"Declassification Date", NITF_DAT(8), true, nullptr, nullptr)
101  //TODO: Should this instead be a NitfEnum that accepts only [X1-X8] and [x251-X259]??
102  .field(tp+"SDCXM", np+"Declassification Exemption", NITF_STR_ECSA(4), true, nullptr, nullptr)
103  .field(tp+"SDG", np+"Downgrade",
105  .value("S", "Secret")
106  .value("C", "Confidential")
107  .value("R", "Restricted")),
108  true, nullptr, nullptr)
109  //this field def is only used for NITF2.1, so we can use NitfDT
110  .field(tp+"SDGDT", np+"Downgrade Date", NITF_DAT(8), true, nullptr, nullptr)
111  .field(tp+"SCLTX", np+"Classification Text", NITF_STR_ECSA(43), true, nullptr, nullptr)
112  .field(tp+"SCATP", np+"Classification Authority Type",
114  .value("O", "Original classification authority")
115  .value("D", "Derivative from a single source")
116  .value("M", "Derivative from multiple sources")),
117  true, nullptr, nullptr)
118  .field(tp+"SCAUT", np+"Classification Authority", NITF_STR_ECSA(40), true, nullptr, nullptr)
119  .field(tp+"SCRSN", np+"Classification Reason",
121  .value("A", "Military plans, weapons systems, or operations")
122  .value("B", "Foreign government information")
123  .value("C", "Intelligence activities (including special activities), intelligence sources or methods, or cryptology")
124  .value("D", "Foreign relations or foreign activities of the United States, including confidential sources")
125  .value("E", "Scientific, technological, or economic matters relating to national security")
126  .value("F", "United States Government programs for safeguarding nuclear materials or facilities")
127  .value("G", "Vulnerabilities or capabilities of systems, installations, projects or plans relating to the national security")),
128  true, nullptr, nullptr)
129  //order of data/time depends on NITF2.1 or NITF2.0, so just read in as string for now
130  .field(tp+"SSRDT", np+"Security Source Date", NITF_DAT(8), true, nullptr, nullptr)
131  .field(tp+"SCTLN", np+"Security Control Number", NITF_STR_ECSA(15), true, nullptr, nullptr);
132  break;
133  default:
134  assert(!"vil_nitf2_classification::add_field_defs() called with unsupported version!");
135  }
136 }
Functor vil_nitf2_field_value_one_of defines a predicate that sets its out parameter to true iff the ...
std::pair< file_version, std::pair< std::string, std::string > > type_field_defs_key
#define NITF_DAT
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)
#define NITF_STR_ECSA(LEN)
#define NITF_ENUM