00001 // vil_nitf2: Written by Rob Radtke (rob@) and Harry Voorhees (hlv@) of 00002 // Stellar Science Ltd. Co. (stellarscience.com) for 00003 // Air Force Research Laboratory, 2005. 00004 00005 #ifndef VIL_NITF2_CLASSIFICATION_H 00006 #define VIL_NITF2_CLASSIFICATION_H 00007 00008 #include "vil_nitf2.h" 00009 00010 #include <vcl_string.h> 00011 #include <vcl_map.h> 00012 #include <vcl_utility.h> // vcl_pair 00013 00014 class vil_nitf2_field_definitions; 00015 00016 // A purely static class that generates classification field definitions. 00017 // Use \sa get_field_definitions() to get a field definition that will 00018 // parse either a nitf 2.1 or nitf 2.0 stream. Note that the two are 00019 // very different, so be sure to ask for the right one. They don't even 00020 // have the same field width. In NITF 2.1, the classification string is 00021 // fixed at 205 characters. In NITF 2.0, it can either be 167 or 207 00022 // characters depending on whether the conditional field SDEVT is present 00023 // or not. The field names also vary according to the type of header 00024 // that contains them. 00025 // 00026 class vil_nitf2_classification 00027 { 00028 public: 00029 00030 // NITF file version 00031 enum file_version 00032 { 00033 V_UNKNOWN, V_NITF_10, V_NITF_20, V_NITF_21, 00034 // If you weren't confused enough already, now we're telling you 00035 // that NSIF 1.0 is the same as NITF 2.1. It's true though. 00036 V_NSIF_10 = V_NITF_21 00037 }; 00038 00039 // Classification fields are used in a number of places with slightly 00040 // different tag names and pretty names. In the file header the first 00041 // classification field is "FSCLAS" ("File Security Classification"); 00042 // in the image subheader, the corresponding field is "ISCLAS" 00043 // ("Image Security Classification"). Fortunately, these differences 00044 // are consistent, so all tag names in one context can be generated by 00045 // prepending the same string to the base tag name; similarly for 00046 // the fields' pretty names. The tag_prefix and pretty_name_prefix 00047 // argument below allow the caller to generate the field definitions 00048 // appropriate to the context, e.g., "F" and "File", respectively, 00049 // in the case of a file header. 00050 static const vil_nitf2_field_definitions* get_field_definitions( 00051 const file_version& version, 00052 vcl_string tag_prefix, vcl_string pretty_name_prefix ); 00053 00054 // Like get_field_defintions(), but appends fields to defs instead 00055 // of returning them. 00056 static void add_field_defs( 00057 vil_nitf2_field_definitions* defs, const file_version& version, 00058 vcl_string prefix, vcl_string pretty_name_prefix); 00059 00060 private: 00061 // Purely static class; don't instantiate. 00062 vil_nitf2_classification(); 00063 00064 // A cache of field definitions, indexed by version, tag_prefix and 00065 // pretty_name_prefix. 00066 typedef vcl_pair< file_version, vcl_pair< vcl_string, vcl_string> > 00067 type_field_defs_key; 00068 typedef vcl_map< type_field_defs_key, vil_nitf2_field_definitions*> 00069 type_field_defs_map; 00070 static type_field_defs_map & s_field_definitions(); 00071 00072 // so these static members can be cleaned up when the program is done 00073 // using nitf files 00074 friend class type_field_defs_map_t; 00075 }; 00076 00077 #endif //VIL_NITF2_CLASSIFICATION_H