![]() |
Observation
|
00001 /* Label_Patcher 00002 00003 PIRL CVS ID: Label_Patcher.hh,v 1.5 2020/02/14 01:17:17 schaller Exp 00004 00005 Copyright (C) 2009-2020 Arizona Board of Regents on behalf of the Lunar and 00006 Planetary Laboratory at the University of Arizona. 00007 00008 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 00009 this file except in compliance with the License. You may obtain a copy of the 00010 License at 00011 00012 http://www.apache.org/licenses/LICENSE-2.0 00013 00014 Unless required by applicable law or agreed to in writing, software distributed 00015 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 CONDITIONS OF ANY KIND, either express or implied. See the License for the 00017 specific language governing permissions and limitations under the License. 00018 */ 00019 #ifndef _LABEL_PATCHER_ 00020 #define _LABEL_PATCHER_ 00021 00022 #include "PVL.hh" 00023 00024 #include <iosfwd> 00025 #include <string> 00026 00027 #ifndef MODULE_VERSION 00028 #define _VERSION_ " " 00029 #else 00030 #define _VERSION_ " v" MODULE_VERSION " " 00031 #endif 00032 00034 void usage (const char* const program); 00035 00036 00037 namespace UA 00038 { 00039 namespace HiRISE 00040 { 00041 class Label_Patcher 00042 { 00043 public: 00044 /*============================================================================== 00045 Constants: 00046 */ 00048 static const char* const 00049 ID; 00050 00052 static const char 00053 * const PDS_VERSION_ID_PARAMETER, 00054 * const OBSERVATION_ID_PARAMETER; 00055 00057 static const char 00058 * const LABEL_RECORDS_PARAMETER, 00059 DATA_LOCATION_PREFIX; 00060 00062 static const char 00063 * const LOOKUP_CONVERSION_TABLE; 00064 00066 static const char 00067 * const DATABASE_TYPE, 00068 * const TYPE_PARAMETER, 00069 * const SERVER_PARAMETER, 00070 * const HOST_PARAMETER, 00071 * const USER_PARAMETER, 00072 * const PASSWORD_PARAMETER, 00073 * const CATALOG_PARAMETER, 00074 * const TABLE_PARAMETER; 00075 00076 #ifndef DEFAULT_CONFIGURATION_FILENAME 00077 #define DEFAULT_CONFIGURATION_FILENAME "Database.conf" 00078 #endif 00079 00080 #ifndef DEFAULT_DATABASE_HOST 00081 #define DEFAULT_DATABASE_HOST "" 00082 #endif 00083 00084 #ifndef DEFAULT_DATABASE_CATALOG 00085 #define DEFAULT_DATABASE_CATALOG "HiRISE" 00086 #endif 00087 00088 #ifndef DEFAULT_DATABASE_TABLE 00089 #define DEFAULT_DATABASE_TABLE "EDR_Products" 00090 #endif 00091 00093 static const char 00094 * const OBSERVATION_ID_FIELD; 00095 00097 #ifndef BACKUP_FILENAME_SUFFIX 00098 #define BACKUP_FILENAME_SUFFIX "-backup" 00099 #endif 00100 00102 static const int 00103 SUCCESS, 00104 00105 // Command line syntax. 00106 BAD_SYNTAX, 00107 00108 // Configuration. 00109 CONFIGURATION_FAILURE, 00110 00111 // Database. 00112 DATABASE_ERROR, 00113 00114 // Software / data problem. 00115 INVALID_ARGUMENT, 00116 LENGTH_ERROR, 00117 UNDERFLOW_ERROR, 00118 OUT_OF_RANGE, 00119 LOGIC_ERROR, 00120 00121 // IO. 00122 NO_INPUT_FILE, 00123 NO_OUTPUT_FILE, 00124 NO_PVL_FILE, 00125 IO_FAILURE, 00126 00127 // PVL. 00128 PVL_ERROR, 00129 00130 // Unknown? 00131 UNKNOWN_ERROR; 00132 00133 /*============================================================================== 00134 Data members: 00135 */ 00136 bool 00137 Backup, 00138 Force, 00139 Verbose; 00140 00141 std::string 00142 Input_Pathname; 00143 std::ifstream 00144 *Input_File; 00145 00146 idaeim::PVL::Aggregate 00147 *PDS_Label; 00149 idaeim::PVL::Lister 00150 PDS_Label_Lister; 00151 idaeim::PVL::Parameter 00152 *Label_Size_Parameter; 00153 00155 std::string 00156 Observation_ID; 00157 00158 struct Database_Configuration 00159 { 00160 std::string 00161 Configuration_Pathname, 00162 Server, 00163 Host, 00164 User, 00165 Password, 00166 Catalog, 00167 Table; 00168 } 00169 Database_Configuration_Values; 00170 00171 /*============================================================================== 00172 Constructor 00173 */ 00174 Label_Patcher 00175 ( 00176 int count, 00177 char** arguments 00178 ); 00179 00180 private: 00181 Label_Patcher () {} 00182 00183 public: 00184 /*============================================================================== 00185 Manipulators 00186 */ 00187 idaeim::PVL::Parameter* 00188 label_parameter (const std::string& pathname); 00189 00190 void 00191 configure_database (); 00192 00193 void 00194 connect_to_database (); 00195 00196 std::string 00197 database_field_value (const std::string& field, const std::string& key, 00198 const std::string& table = ""); 00199 00200 std::string 00201 database_configuration_report (); 00202 00203 std::string 00204 database_connection_report (); 00205 00206 void 00207 disconnect_from_database (); 00208 00209 int 00210 apply_patch (); 00211 00212 }; // Class Label_Patcher 00213 00214 00215 } // namespace HiRISE 00216 } // namespace UA 00217 #endif