HiRISE
 Observation

Line_Cache.hh
Go to the documentation of this file.
1 /* HiRISE Line Cache
2 
3 PIRL CVS ID: Line_Cache.hh,v 1.8 2020/02/14 01:17:18 schaller Exp
4 
5 Copyright (C) 2005-2020 Arizona Board of Regents on behalf of the Lunar and
6 Planetary Laboratory at the University of Arizona.
7 
8 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
9 this file except in compliance with the License. You may obtain a copy of the
10 License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14 Unless required by applicable law or agreed to in writing, software distributed
15 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16 CONDITIONS OF ANY KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations under the License.
18 */
19 #ifndef _HiRISE_Line_Cache_
20 #define _HiRISE_Line_Cache_
21 
22 // UA::HiRISE
23 #include "Image_Line.hh"
24 
25 // PIRL
26 #include "Cache.hh"
27 
28 #include <iosfwd>
29 #include <sstream>
30 #include <string>
31 
32 namespace UA
33 {
34 namespace HiRISE
35 {
36 /*******************************************************************************
37  Line_Cache
38 */
81 : public Image_Line,
82  public PIRL::Cache
83 {
84 public:
85 /*==============================================================================
86  Constants:
87 */
89 static const char* const
90  ID;
91 
92 /*==============================================================================
93  Constructors
94 */
101  (
102  Image_Line& image_line,
103  std::istream& stream
104  );
105 
106 private:
107 Line_Cache ();
108 Line_Cache (const Line_Cache&);
109 Line_Cache& operator= (const Line_Cache&);
110 
111 public:
112 /*==============================================================================
113  Accessors
114 */
120 virtual unsigned long long bytes_read () const
121  {return Cache::bytes_read ();}
122 
136 unsigned long long source_bytes () const
137  {return Data_Bytes;}
138 
143 virtual bool compressed_data () const
144  {return false;}
145 
150 virtual unsigned long long compressed_bytes () const
151  {return 0;}
152 
157 virtual unsigned long long decompressed_bytes () const
158  {return 0;}
159 
174 unsigned int count () const
175  {return Line_Count;}
176 
186 virtual Line_Cache& source (std::istream& stream);
187 
192 virtual std::istream& source () const
193  {return Cache::source ();}
194 
202 std::string bad_line_description () const;
203 
221  {return Synchronization_Lost;}
222 
223 /*==============================================================================
224  Manipulators
225 */
292 bool next_line ();
293 
301 virtual bool refill (unsigned long max_amount = (unsigned long)-1);
302 
310 virtual void reset ();
311 
312 /*==============================================================================
313  Helpers
314 */
315 private:
338 char* patch
339  (char* begin = NULL, char* end = NULL);
340 
341 protected:
342 
350 unsigned long long offset (char* location) const
351 {return bytes_read () - amount_used () + location - start ();}
352 
353 /*==============================================================================
354  Cache Management
355 */
356 protected:
357 
361 
366 unsigned long long
368 
370 unsigned int
372 
374 unsigned int
376 
378 bool
380 
389 std::ostringstream
391 
400 std::string
402 
403 }; // class Line_Cache
404 
405 } // namespace HiRISE
406 } // namespace UA
407 #endif
unsigned long amount_used() const
char * start() const
An Image_Line contains a cache of observation channel image pixel data.
Definition: Image_Line.hh:112
A Line_Cache manages the data contents for an Image_Line.
Definition: Line_Cache.hh:83
virtual bool compressed_data() const
Tests if the image data is compressed.
Definition: Line_Cache.hh:143
unsigned int Next_Line_Number
The number of the next line available in the cache.
Definition: Line_Cache.hh:375
unsigned long long source_bytes() const
Gets the amount (bytes) of source data that has been used.
Definition: Line_Cache.hh:136
std::ostringstream Bad_Line_Description
Message describing the reason for a repaired line.
Definition: Line_Cache.hh:390
std::string Next_Bad_Line_Description
Message intended for the next line to be assembled.
Definition: Line_Cache.hh:401
unsigned int Line_Count
The count of lines logically found so far.
Definition: Line_Cache.hh:371
bool next_line()
Gets the next line of image data into the Image_Line being managed.
Definition: Line_Cache.cc:313
bool Synchronization_Lost
Has line synchronization been lost?
Definition: Line_Cache.hh:379
std::string bad_line_description() const
Gets the description of the bad line cause.
Definition: Line_Cache.cc:125
virtual unsigned long long decompressed_bytes() const
Gets the amount (bytes) of decompressed data that has been generated.
Definition: Line_Cache.hh:157
unsigned long long offset(char *location) const
Gets the source offset location of a cache location.
Definition: Line_Cache.hh:350
virtual unsigned long long bytes_read() const
Gets the total number of bytes read from the source stream.
Definition: Line_Cache.hh:120
unsigned long long Data_Bytes
The number of source data bytes used for line data.
Definition: Line_Cache.hh:367
unsigned int count() const
Gets the current line count.
Definition: Line_Cache.hh:174
virtual void reset()
Resets the cache to its empty state and the line structure to match the current structure of the mana...
Definition: Line_Cache.cc:794
virtual unsigned long long compressed_bytes() const
Gets the amount (bytes) of compressed data that has been processed.
Definition: Line_Cache.hh:150
Image_Line * Line
Image_Line being managed.
Definition: Line_Cache.hh:360
static const char *const ID
Class identification name with source code version and date.
Definition: Line_Cache.hh:90
bool synchronization_lost()
Check for lost line synchronization.
Definition: Line_Cache.hh:220
virtual std::istream & source() const
Gets the data source stream.
Definition: Line_Cache.hh:192
virtual bool refill(unsigned long max_amount=(unsigned long) -1)
Refills the cache storage from the data source stream.
Definition: Line_Cache.cc:787
University of Arizona.