Observation
|
00001 /* HiRISE Line Cache 00002 00003 PIRL CVS ID: Line_Cache.hh,v 1.8 2020/02/14 01:17:18 schaller Exp 00004 00005 Copyright (C) 2005-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 _HiRISE_Line_Cache_ 00020 #define _HiRISE_Line_Cache_ 00021 00022 // UA::HiRISE 00023 #include "Image_Line.hh" 00024 00025 // PIRL 00026 #include "Cache.hh" 00027 00028 #include <iosfwd> 00029 #include <sstream> 00030 #include <string> 00031 00032 namespace UA 00033 { 00034 namespace HiRISE 00035 { 00036 /******************************************************************************* 00037 Line_Cache 00038 */ 00080 class Line_Cache 00081 : public Image_Line, 00082 public PIRL::Cache 00083 { 00084 public: 00085 /*============================================================================== 00086 Constants: 00087 */ 00089 static const char* const 00090 ID; 00091 00092 /*============================================================================== 00093 Constructors 00094 */ 00100 Line_Cache 00101 ( 00102 Image_Line& image_line, 00103 std::istream& stream 00104 ); 00105 00106 private: 00107 Line_Cache (); 00108 Line_Cache (const Line_Cache&); 00109 Line_Cache& operator= (const Line_Cache&); 00110 00111 public: 00112 /*============================================================================== 00113 Accessors 00114 */ 00120 virtual unsigned long long bytes_read () const 00121 {return Cache::bytes_read ();} 00122 00136 unsigned long long source_bytes () const 00137 {return Data_Bytes;} 00138 00143 virtual bool compressed_data () const 00144 {return false;} 00145 00150 virtual unsigned long long compressed_bytes () const 00151 {return 0;} 00152 00157 virtual unsigned long long decompressed_bytes () const 00158 {return 0;} 00159 00174 unsigned int count () const 00175 {return Line_Count;} 00176 00186 virtual Line_Cache& source (std::istream& stream); 00187 00192 virtual std::istream& source () const 00193 {return Cache::source ();} 00194 00202 std::string bad_line_description () const; 00203 00220 bool synchronization_lost () 00221 {return Synchronization_Lost;} 00222 00223 /*============================================================================== 00224 Manipulators 00225 */ 00292 bool next_line (); 00293 00301 virtual bool refill (unsigned long max_amount = (unsigned long)-1); 00302 00310 virtual void reset (); 00311 00312 /*============================================================================== 00313 Helpers 00314 */ 00315 private: 00338 char* patch 00339 (char* begin = NULL, char* end = NULL); 00340 00341 protected: 00342 00350 unsigned long long offset (char* location) const 00351 {return bytes_read () - amount_used () + location - start ();} 00352 00353 /*============================================================================== 00354 Cache Management 00355 */ 00356 protected: 00357 00359 Image_Line 00360 *Line; 00361 00366 unsigned long long 00367 Data_Bytes; 00368 00370 unsigned int 00371 Line_Count; 00372 00374 unsigned int 00375 Next_Line_Number; 00376 00378 bool 00379 Synchronization_Lost; 00380 00389 std::ostringstream 00390 Bad_Line_Description; 00391 00400 std::string 00401 Next_Bad_Line_Description; 00402 00403 }; // class Line_Cache 00404 00405 } // namespace HiRISE 00406 } // namespace UA 00407 #endif