HiRISE
 Observation

Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Line_Cache Class Reference

A Line_Cache manages the data contents for an Image_Line. More...

#include <Line_Cache.hh>

Inheritance diagram for Line_Cache:
Inheritance graph
[legend]
Collaboration diagram for Line_Cache:
Collaboration graph
[legend]

Public Member Functions

 Line_Cache (Image_Line &image_line, std::istream &stream)
 Constructs a Line_Cache for an Image_Line bound to an istream. More...
 
virtual unsigned long long bytes_read () const
 Gets the total number of bytes read from the source stream. More...
 
unsigned long long source_bytes () const
 Gets the amount (bytes) of source data that has been used. More...
 
virtual bool compressed_data () const
 Tests if the image data is compressed. More...
 
virtual unsigned long long compressed_bytes () const
 Gets the amount (bytes) of compressed data that has been processed. More...
 
virtual unsigned long long decompressed_bytes () const
 Gets the amount (bytes) of decompressed data that has been generated. More...
 
unsigned int count () const
 Gets the current line count. More...
 
virtual Line_Cachesource (std::istream &stream)
 Sets the data source stream and resets the cache. More...
 
virtual std::istream & source () const
 Gets the data source stream. More...
 
std::string bad_line_description () const
 Gets the description of the bad line cause. More...
 
bool synchronization_lost ()
 Check for lost line synchronization. More...
 
bool next_line ()
 Gets the next line of image data into the Image_Line being managed. More...
 
virtual bool refill (unsigned long max_amount=(unsigned long) -1)
 Refills the cache storage from the data source stream. More...
 
virtual void reset ()
 Resets the cache to its empty state and the line structure to match the current structure of the managed line. More...
 
- Public Member Functions inherited from Image_Line
 Image_Line ()
 Constructs a default Image_Line. More...
 
 Image_Line (unsigned int bytes_per_pixel, unsigned int total_pixels, unsigned int total_lines=0, unsigned int channel_number=CCD_UNKNOWN, std::istream *stream=NULL)
 Constructs an Image_Line of a specified line length and pixel size. More...
 
 Image_Line (const Image_Line &component, bool duplicate=true)
 Copy constructor. More...
 
Image_Lineoperator= (const Image_Line &component)
 Assigns another Image_Line to this one. More...
 
virtual ~Image_Line ()
 Destructor. More...
 
std::string id () const
 Provides the class ID on a line followed by the base Data_Component::id. More...
 
const char * name () const
 Gets the NAME of this class. More...
 
u_int_32 sync () const
 Gets the extended Sync Element value. More...
 
Image_Linesync (u_int_32 value)
 Sets the extended Sync Element value. More...
 
u_int_32 channel () const
 Gets the Channel Element channel number. More...
 
Image_Linechannel (u_int_32 channel_number)
 Sets the Channel Element channel number. More...
 
u_int_32 expected_channel () const
 Gets the expected channel number for the line header. More...
 
Image_Lineexpected_channel (u_int_32 channel_number)
 Sets the expected channel number for the line header. More...
 
u_int_32 line_number () const
 Gets the Line_Number Element value. More...
 
Image_Lineline_number (u_int_32 line)
 Sets the Line_Number Element value. More...
 
bool bad_line () const
 Tests if the bad line flag is set. More...
 
Image_Linebad_line (bool state)
 Sets or clears the bad line flag. More...
 
std::string bad_line_description () const
 Gets the description of the bad line cause. More...
 
Pixel_type pixel (Index index) const
 Gets a pixel value. More...
 
Pixel_type operator[] (Index index) const
 Gets a pixel value. More...
 
void pixel (Index index, Pixel_type value)
 Sets a pixel value. More...
 
Pixel_type buffer_pixel (Index index) const
 Gets a Buffer_Pixels Element value. More...
 
void buffer_pixel (Index index, Pixel_type value)
 Sets a Buffer_Pixels Element value. More...
 
Pixel_type image_pixel (Index index) const
 Gets an Image_Pixels Element value. More...
 
void image_pixel (Index index, Pixel_type value)
 Sets an Image_Pixels Element value. More...
 
Pixel_type black_pixel (Index index) const
 Gets a Black_Pixels Element value. More...
 
void black_pixel (Index index, Pixel_type value)
 Sets a Black_Pixels Element value. More...
 
Pixel_type virtual_pixel (Index index) const
 Gets a Virtual_Pixels Element value. More...
 
void virtual_pixel (Index index, Pixel_type value)
 Sets a Virtual_Pixels Element value. More...
 
unsigned int pixel_count () const
 Gets the total number of pixels in the line. More...
 
Image_Linepixel_count (unsigned int total_pixels)
 Sets the total number of pixels in the line. More...
 
unsigned int pixel_bytes () const
 Gets the number of bytes per pixel. More...
 
Image_Linepixel_bytes (unsigned int bytes_per_pixel)
 Sets the number of bytes per pixel. More...
 
unsigned int total_lines () const
 Gets the total number of image lines in the channel data set. More...
 
Image_Linetotal_lines (unsigned int lines)
 Sets the total number of image lines in the channel data set. More...
 
void mirror ()
 Mirrors the order of all pixels. More...
 
Image_Linelookup (const LUT &lut)
 Applies a LUT mapping to all pixel values. More...
 
Image_Linepukool (Pixel_type *table)
 Applies a "reverse" table mapping to all pixel values. More...
 
std::istream & source () const
 Gets the istream being used as the source of line data. More...
 
Image_Linesource (std::istream &stream)
 Sets the input stream to be used as the source of line data. More...
 
bool next ()
 Gets the next image line. More...
 
unsigned int count () const
 Gets the current line count. More...
 
unsigned long long bytes_read () const
 Gets the number of bytes read from the data source. More...
 
unsigned long long source_bytes () const
 Gets the amount (bytes) of source data that has been used. More...
 
bool compressed_data () const
 Indicates if the source line data was FELICS compressed. More...
 
unsigned long long compressed_bytes () const
 Gets the amount (bytes) of compressed data that has been processed. More...
 
unsigned long long decompressed_bytes () const
 Gets the amount (bytes) of decompressed data that has been generated. More...
 
Line_Cachecache ()
 Gets the line's data management cache object. More...
 
bool synchronization_lost ()
 Check for lost line synchronization. More...
 
std::ostream & print (std::ostream &stream=std::cout, bool verbose=false) const
 Prints the component structure and contents. More...
 
unsigned int width () const
 Gets the print listing width. More...
 
Image_Linewidth (unsigned int groups)
 Sets the print listing width. More...
 
idaeim::PVL::AggregatePVL () const
 Produces a PVL rendition of the component. More...
 
idaeim::PVL::AggregatePVL_description () const
 Produces a PVL description of the observation image data layout for a PDS label. More...
 
bool is_valid () const
 Tests if the component data is valid. More...
 
- Public Member Functions inherited from Data_Component
 Data_Component (const char **names=NULL, unsigned int size=0, const Index *offsets=NULL, const Index indexed_arrays[][2]=NULL, Data_Order order=Data_Block::MSB)
 Constructs a Data_Component using component specifications. More...
 
 Data_Component (const Data_Component &component, bool data_duplicate=true)
 Copy constructor. More...
 
Data_Componentoperator= (const Data_Component &component)
 Assignment operator. More...
 
virtual ~Data_Component ()
 Destructor. More...
 
const char * name (Index element) const
 Gets the name of a component Element. More...
 
virtual u_int_32 get (Index element, Index index=0) const
 Gets a value from a data Element or array entry of the component. More...
 
virtual Data_Componentput (const u_int_32 value, Index element, Index index=0)
 Puts a value into a data Element or array entry of the component. More...
 
std::ostream & print_element (const Index element, int format=DECIMAL, std::ostream &stream=std::cout, int width=0) const
 Prints an Element description. More...
 
std::ostream & print_element (const Index element, std::ostream &stream) const
 Prints an Element description. More...
 
std::ostream & print_element_location (const Index element, std::ostream &stream=std::cout) const
 Prints the location of an Element in the component. More...
 
unsigned int element_location_print_width (Index element) const
 Gets the width of the Element location printing fields. More...
 
unsigned int name_field_width () const
 Gets the width of the Element name printing field. More...
 
Data_Componentname_field_width (unsigned int width)
 Sets the width of the Element name field for printing. More...
 
Data_Blockdata (void *const block)
 Overrides the base Data_Block::data to reset Local_Data. More...
 
Data_Blockattach (void *const block, unsigned int size)
 Attaches a new block of data to the component. More...
 
Data_Componentresize (unsigned int size)
 Resizes the block of local data storage. More...
 
unsigned char * data () const
 Gets a pointer to the current component storage. More...
 
unsigned int local_data ()
 Gets the size of the local data storage area. More...
 
u_int_16 internet_checksum () const
 Calculates the Internet Checksum as per RFC 1071. More...
 
- Public Member Functions inherited from Data_Block
 Data_Block ()
 
 Data_Block (void *const data, const Index *offsets, Index total_elements=0, const Index *array_counts=NULL, bool native_order=true)
 
 Data_Block (void *const data, const Value_List &offsets, const Value_List &array_counts, bool native_order=true)
 
 Data_Block (void *const data, const Value_List &offsets, bool native_order=true)
 
 Data_Block (void *const data, const Index *offsets, Index total_elements, const Index *array_counts, Data_Order data_order)
 
 Data_Block (void *const data, const Value_List &offsets, const Value_List &array_counts, Data_Order data_order)
 
 Data_Block (void *const data, const Index *offsets, Index total_elements, Data_Order data_order)
 
 Data_Block (void *const data, const Index *offsets, Data_Order data_order)
 
 Data_Block (void *const data, const Value_List &offsets, Data_Order data_order)
 
 Data_Block (void *const data, const Index *offsets, const Index indexed_counts[][2], Data_Order data_order)
 
 Data_Block (const Data_Block &data_block)
 
Data_Blockoperator= (const Data_Block &data_block)
 
virtual ~Data_Block ()
 
bool native () const
 
Data_Blocknative (bool native_order)
 
Data_Order data_order () const
 
Data_Blockdata_order (Data_Order order)
 
unsigned char * data () const
 
Index size () const
 
Value_List element_offsets_list () const
 
Indexelement_offsets ()
 
bool element_offsets (const Value_List &offsets)
 
bool element_offsets (const Index *offsets, Index total_elements=NO_INDEX)
 
bool element_sizes (const Value_List &sizes)
 
bool element_sizes (const Index *sizes, Index total_elements=NO_INDEX)
 
Index offset_of (Index element) const
 
bool offset_of (Index element, Index offset)
 
bool insert_element (Index offset, Index size, Index array_count=1)
 
Data_Blockdelete_element (Index element)
 
Data_Blockshift_offsets (int amount)
 
Index elements () const
 
Index size_of (Index element) const
 
bool size_of (Index element, Index size)
 
Index value_size_of (Index element) const
 
Data_Blockvalue_size_of (Index element, Index size)
 
Index index_of (Index offset) const
 
Value_List array_counts_list () const
 
Indexarray_counts ()
 
Data_Blockarray_counts (const Value_List &counts, Index begin=0)
 
Data_Blockarray_counts (const Index *counts, Index begin=0, Index end=NO_INDEX)
 
Data_Blockarray_indexed_counts (const Index indexed_counts[][2], Index total_counts=NO_INDEX)
 
Data_Blockarray_offset_counts (const Index offset_counts[][2], Index total_counts=NO_INDEX)
 
Index count_of (Index element) const
 
Data_Blockcount_of (Index element, Index count)
 
bool reset_counts (bool unconditional=true, Index begin=0, Index end=NO_INDEX)
 
const Data_Blockget (T &value, const Index element, const Index index=0) const
 
const Data_Blockget (T &value, const Index element, const Index index=0) const
 
get (const Index element, const Index index=0) const
 
get (const Index element, const Index index=0) const
 
Data_Blockput (T &value, const Index element, const Index index=0)
 
Data_Blockput (T &value, const Index element, const Index index=0)
 
const Data_Blockget (T *array, const Index element, Index count=0) const
 
const Data_Blockget (T *array, const Index element, Index count=0) const
 
Data_Blockput (T *array, const Index element, Index count=0)
 
Data_Blockput (T *array, const Index element, Index count=0)
 
std::istream & input (std::istream &stream)
 
std::ostream & output (std::ostream &stream) const
 
std::ostream & print (std::ostream &stream=std::cout) const
 
- Public Member Functions inherited from Cache
 Cache ()
 
 Cache (unsigned long capacity, unsigned long data_margin=0, Data_Test data_test=NULL)
 
 Cache (unsigned long capacity, std::istream &source, unsigned long data_margin=0, Data_Test data_test=NULL)
 
virtual ~Cache ()
 
Cachesource (std::istream &source)
 
std::istream & source () const
 
unsigned long long bytes_read () const
 
Cachedata_margin (unsigned long amount)
 
unsigned long data_margin () const
 
Cachedata_test (Data_Test tester, unsigned long data_amount)
 
Data_Test data_test () const
 
unsigned long data_test_amount () const
 
virtual void drain ()
 
virtual Cacheput (char *data, unsigned long amount)
 
virtual unsigned long get (char *data, unsigned long amount)
 
unsigned long capacity () const
 
Cachecapacity (unsigned long amount)
 
unsigned long amount_used () const
 
unsigned long amount_free () const
 
char * start () const
 
Cachenext (char *location)
 
char * next () const
 
unsigned long amount_consumed () const
 
long amount_remaining () const
 
char * last () const
 
Cachelast (char *location)
 
void state_report (std::ostream &stream) const
 
void state_report () const
 

Static Public Attributes

static const char *const ID
 Class identification name with source code version and date. More...
 
- Static Public Attributes inherited from Image_Line
static const char *const ID
 Class identification name with source code version and date. More...
 
static const char *const NAME = "Image Line"
 The component name. More...
 
static const char * NAMES []
 The name of each Element. More...
 
static const unsigned int LINE_HEADER_BYTES = 6
 The number of bytes in the line header section. More...
 
static const unsigned int BUFFER_PIXELS_COUNT = 12
 The number of buffer pixels. More...
 
static const unsigned int BLACK_PIXELS_COUNT = 16
 The number of black pixels. More...
 
static const unsigned int MAX_VIRTUAL_PIXELS_COUNT = MAX_VIRTUAL_PIXELS
 The maximum number of allowable virtual pixels. More...
 
static const unsigned int MAX_PIXELS_PER_LINE
 The maximum number of pixels allowed. More...
 
static const unsigned int DEFAULT_CALIBRATION_LINES = CALIBRATION_LINES
 The default number of calibration lines at the beginning of the observation channel data. More...
 
static const Index MAX_COMPONENT_BYTES
 Total maximum number of bytes in the Data_Block. More...
 
static const Index OFFSETS_TEMPLATE []
 Data_Block data storage address offset template for each Element. More...
 
static const Index ARRAY_COUNTS_TEMPLATE [][2]
 Data_Block array element value counts each keyed to an Element Index. More...
 
static const u_int_32 SYNC = 0xFF00E000
 Expected Sync Element value after extension. More...
 
static const u_int_8 SYNC_3 = 0xFF
 Expected Sync Element MSB (byte 3) value. More...
 
static const u_int_8 SYNC_2 = 0x00
 Expected Sync Element MSB+1 (byte 2) value. More...
 
static const u_int_8 SYNC_1_BIT_MASK = 0xE0
 Bit mask for the Sync Element extension field of the Channel Element. More...
 
static const u_int_8 CHANNEL_BIT_MASK = 0x1F
 Bit mask for channel number field of the Channel Element. More...
 
static const u_int_32 LINE_NUMBER_MASK = 0x007FFFFF
 Bit mask for the line number field of the Line_Number Element. More...
 
static const char * Sync_Type_Names []
 Sync_Type names. More...
 
static const unsigned int DEFAULT_WIDTH = LINE_PRINT_GROUPS_WIDTH
 The default width, in pixel groups, of a print listing. More...
 
static unsigned int Calibration_Lines = CALIBRATION_LINES
 Number of image lines at the beginning of the image data to be designated as calibration data. More...
 
- Static Public Attributes inherited from Data_Component
static const char *const ID
 Class identification name with source code version and date. More...
 
static const int DECIMAL = 0
 Format specifier. More...
 
static const int HEX = -1
 
static const int BOOLEAN = -2
 
static const char PATHNAME_DELIMITER = FILESYSTEM_PATHNAME_DELIMITER
 Host filesystem pathname delimiter. More...
 
static const int UTC_SECONDS_PRECISION = SECONDS_PRECISION
 UTC seconds precision (digits after the decimal point). More...
 
static const char SUBSECONDS_DELIMITER = ':'
 Delimits subseconds from seconds in clock count representations. More...
 
static const char *const SPICE_METAKERNEL_VARIABLE
 The name of the environment variable for the SPICE metakernel pathname. More...
 
static const char *const DEFAULT_SPICE_METAKERNEL
 The default SPICE metakernal pathname. More...
 
static const int MRO_CLOCK_ID = MRO_CLOCK_NAIF_ID
 The ID used by NAIF for specifying the MRO clock to CSPICE routines. More...
 
static const char *const INVALID_UTC_TIME = DEFAULT_INVALID_UTC_TIME
 
- Static Public Attributes inherited from Instrument
static const char *const ID
 
static const unsigned int CCDS
 
static const unsigned int CCD_UNKNOWN
 
static const char *const CCD_NAMES []
 
static const char *const CCD_FILTER_NAMES []
 
static const unsigned int CCD_BY_CPMM []
 
static const unsigned int CPMM_BY_CCD []
 
static const char *const WAVELENGTH_UNITS
 
static const unsigned int CCD_CENTER_WAVELENGTHS []
 
static const unsigned int CCD_BANDWIDTHS []
 
static const double CCD_FOCAL_PLANE_X_OFFSETS_MM []
 
static const double CCD_FOCAL_PLANE_Y_OFFSETS_MM []
 
static const double CCD_PIXEL_SIZE_MM
 
static const unsigned int CCD_CHANNELS
 
static const unsigned int CCD_CHANNEL_UNKNOWN
 
static const unsigned int CCD_IMAGE_SENSORS
 
static const unsigned int MAX_BYTES_PER_PIXEL
 
static const unsigned int MAX_PIXEL_VALUES []
 
static const unsigned int MAX_IMAGE_LINES
 
static const unsigned int TOTAL_TDI_STAGES
 
static const unsigned int TDI_STAGES []
 
static const unsigned int TOTAL_BINNING_FACTORS
 
static const unsigned int BINNING_FACTORS []
 
static const unsigned int CCD_BINNED_PIXELS []
 
static const unsigned int STORED_LUTS
 
static const unsigned int STIMULATOR_LEDS
 
static const char *const STIMULATOR_LED_NAMES []
 
static const double EXPOSURE_SETUP_MICROS
 
static const unsigned int DELTA_LINE_TIME_MAX
 
static const double DELTA_LINE_TIME_TICK_NANOS
 
static const double LINE_TIME_PRE_OFFSET
 
static const unsigned int TRIM_ADDITION_LINES
 
static const unsigned int REVERSE_READOUT_LINES
 
static const unsigned int MASKED_LINES
 
static const unsigned int DLL_LOCKED
 
static const unsigned int DLL_NOT_LOCKED
 
static const unsigned int SPACECRAFT_EPOCH
 
static const double MRO_CLOCK_SUBTICK_MICROS
 
static const double HIRISE_CLOCK_SUBTICK_MICROS
 
static const int SPACECRAFT_NAIF_ID
 
static const unsigned int SSR_BYTE_BOUNDARY
 
static const int UNKNOWN_NUMBER
 
static const int NOT_APPLICABLE_NUMBER
 
static const char *const UNKNOWN_STRING
 
static const char *const NOT_APPLICABLE_STRING
 
- Static Public Attributes inherited from Data_Block
static const char *const ID
 
static const Index NO_INDEX
 
- Static Public Attributes inherited from Cache
static const char *const ID
 

Protected Member Functions

unsigned long long offset (char *location) const
 Gets the source offset location of a cache location. More...
 
- Protected Member Functions inherited from Data_Block
void limits_checker (const Index element, const Index index, bool getter, bool array) const
 

Protected Attributes

Image_LineLine
 Image_Line being managed. More...
 
unsigned long long Data_Bytes
 The number of source data bytes used for line data. More...
 
unsigned int Line_Count
 The count of lines logically found so far. More...
 
unsigned int Next_Line_Number
 The number of the next line available in the cache. More...
 
bool Synchronization_Lost
 Has line synchronization been lost? More...
 
std::ostringstream Bad_Line_Description
 Message describing the reason for a repaired line. More...
 
std::string Next_Bad_Line_Description
 Message intended for the next line to be assembled. More...
 
- Protected Attributes inherited from Image_Line
unsigned int Pixels_per_Line
 Total pixels in a line. More...
 
unsigned int Bytes_per_Pixel
 Bytes per pixel. More...
 
unsigned int Total_Lines
 Total number of lines expected. More...
 
unsigned int Channel_Number
 Expected channel number. More...
 
Line_CacheData_Cache
 Line data cache. More...
 
unsigned int Width
 Width of listing (pixel groups). More...
 

Additional Inherited Members

- Public Types inherited from Image_Line
enum  Elements {
  Sync ,
  Channel ,
  Line_Number ,
  Buffer_Pixels ,
  Image_Pixels ,
  Black_Pixels ,
  Virtual_Pixels ,
  Total_Elements
}
 An Element refers to a data containing constituent of a component. More...
 
enum  Sync_Type {
  No_Sync_Type ,
  Line_Header_Sync_Type ,
  FELICS_Sync_Type
}
 Possible types of sync patterns. More...
 
- Public Types inherited from Data_Block
enum  Data_Order
 
enum  Array_Index_Counts
 
enum  Array_Offset_Counts
 
typedef unsigned int Index
 
typedef std::vector< IndexValue_List
 
typedef void(* Copier) (unsigned char *destination, int destination_amount, const unsigned char *source, int source_amount)
 
- Public Types inherited from Cache
typedef bool(* Data_Test) (const void *)
 
- Static Public Member Functions inherited from Image_Line
static unsigned int calibration_lines ()
 Gets the number of image lines designated as calibration data. More...
 
static void calibration_lines (unsigned int lines)
 Sets the number of image lines designated as calibration data. More...
 
static bool is_sync (void *data_at)
 Tests if some data contains a line header sync pattern. More...
 
static Sync_Type next_sync (std::istream &stream)
 Searches an istream for an image data synchronization pattern. More...
 
- Static Public Member Functions inherited from Instrument
static unsigned int calibration_lines_minimum (unsigned int TDI, unsigned int binning)
 
static int focal_plane_x_offset (unsigned int CPMM, unsigned int binning=1)
 
- Static Public Member Functions inherited from Data_Block
static Data_Order native_order ()
 
static Value_Listsizes_to_offsets (Value_List &sizes)
 
static Indexsizes_to_offsets (Index *sizes, Index total_elements=NO_INDEX)
 
static Value_Listoffsets_to_sizes (Value_List &offsets)
 
static Indexoffsets_to_sizes (Index *offsets, Index total_elements=NO_INDEX)
 
- Public Attributes inherited from Data_Block
 MSB
 
 LSB
 
 ELEMENT_INDEX
 
 INDEX_COUNT
 
 ELEMENT_OFFSET
 
 OFFSET_COUNT
 
Copier Get
 
Copier Put
 
- Static Protected Member Functions inherited from Data_Block
static void get_forwards (unsigned char *host, int host_amount, const unsigned char *data, int data_amount)
 
static void get_backwards (unsigned char *host, int host_amount, const unsigned char *data, int data_amount)
 
static void put_forwards (unsigned char *data, int data_amount, const unsigned char *host, int host_amount)
 
static void put_backwards (unsigned char *data, int data_amount, const unsigned char *host, int host_amount)
 

Detailed Description

A Line_Cache manages the data contents for an Image_Line.

A Line_Cache uses an istream to provide the source of data for an Image_Line. In addition, the line data read from the stream is checked for structural integrity that is consistent with the characteracteristics of the Image_Line being managed. A broken line data sequence is replaced with line data having the correct structure, but filled with data gap values.

Though a Line_Cache is a subclass of Image_Line, the base object that is instantiated is not the Image_Line being managed. This is because the managed Image_Line itself makes the determination about what type of cache to instantiate based on an initial examination of the data from the stream. If a FELICS synchronization pattern is found then a FELICS_Line_Cache will be used (which is a subclass of Line_Cache) instead of a simple Line_Cache which is used when a normal line header synchronization pattern is found. The former type of cache overrides the cache content methods to decompress image data for use by the latter type of cache in the usual manner. The instantiated by Image_Line object is used both for its Image_Line manipulation methods, and to contain the gap filled replacement line data.

Image data structural integrity is determined by examing the data from the stream for the presence of a correct line header at the beginning of the line data and the presence of a correct line header (or Science Channel Header synchronization pattern, or end-of-file) at the expected location of the next line beginning. A correct line header contains all elements with the expected values. The failure to meet all the structural integrity criteria defines a broken line. For a broken line the data of the Image_Line being managed is assigned to the base Image_Line data with its gap filled values and line header set to contain the expected values. N.B.: Replacement data for broken lines will have a valid - not gap filled

Author
Bradford Castalia, UA/PIRL, 12/04 1.8

Constructor & Destructor Documentation

◆ Line_Cache()

Line_Cache ( Image_Line image_line,
std::istream &  stream 
)

Constructs a Line_Cache for an Image_Line bound to an istream.

Cache storage sufficient to hold at least 32 lines (of the largest size possible) is allocated.

References Image_Line::Channel_Number, Data_Component::data(), Line_Cache::Line, Data_Block::size(), and Image_Line::Total_Lines.

Member Function Documentation

◆ bytes_read()

virtual unsigned long long bytes_read ( ) const
inlinevirtual

Gets the total number of bytes read from the source stream.

Returns
The number of bytes read from the source.
See also
refill()

Reimplemented in FELICS_Line_Cache.

Referenced by Image_Line::bytes_read(), and Line_Cache::offset().

◆ source_bytes()

unsigned long long source_bytes ( ) const
inline

Gets the amount (bytes) of source data that has been used.

The amount of source data that was used to generate image lines, excluding any fill data, is returned. N.B.: This value will be less than or greater than the number of bytes read if the reconstruction of damaged image lines resulted in excess source data being dropped, or padded with gap fill values to replace missing data, respectively.

The count is reset to zero when the cache is reset.

Returns
The number of source bytes used to generate image lines.

References Line_Cache::Data_Bytes.

Referenced by Image_Line::source_bytes().

◆ compressed_data()

virtual bool compressed_data ( ) const
inlinevirtual

Tests if the image data is compressed.

Returns
Always returns false.

Reimplemented in FELICS_Line_Cache.

Referenced by Image_Line::compressed_data(), and Line_Cache::next_line().

◆ compressed_bytes()

virtual unsigned long long compressed_bytes ( ) const
inlinevirtual

Gets the amount (bytes) of compressed data that has been processed.

Returns
Always returns zero.

Reimplemented in FELICS_Line_Cache.

Referenced by Image_Line::compressed_bytes().

◆ decompressed_bytes()

virtual unsigned long long decompressed_bytes ( ) const
inlinevirtual

Gets the amount (bytes) of decompressed data that has been generated.

Returns
Always returns zero.

Reimplemented in FELICS_Line_Cache.

Referenced by Image_Line::decompressed_bytes().

◆ count()

unsigned int count ( ) const
inline

Gets the current line count.

The returned value is the logical line number of the current line data. This is the count of the number of lines that have been advanced since this Image_Line was constructed or the number of total_lines was set. This should be one more than the value of the line_number (if any lines have been read), but data loss or corruption during spacecraft data downlink may have invalidated some logical line data.

Returns
The current line number.
See also
total_lines(unsigned int)
next()

References Line_Cache::Line_Count.

Referenced by Image_Line::count().

◆ source() [1/2]

Line_Cache & source ( std::istream &  stream)
virtual

Sets the data source stream and resets the cache.

In addition to setting the cache source, a reset is done.

Parameters
streamThe istream to be used as the source of line data.
Returns
This Line_Cache.
See also
reset()

Reimplemented in FELICS_Line_Cache.

References Line_Cache::reset().

Referenced by Image_Line::source().

◆ source() [2/2]

virtual std::istream& source ( ) const
inlinevirtual

Gets the data source stream.

Returns
The istream used to refill the cache storage.

Reimplemented in FELICS_Line_Cache.

Referenced by FELICS_Line_Cache::source().

◆ bad_line_description()

std::string bad_line_description ( ) const

Gets the description of the bad line cause.

Returns
The bad line cause description string. This will be empty if the line is not marked as bad. Otherwise a multi-line description
  • with each line, including the last, ending with a new-line - is returned.

References Line_Cache::Bad_Line_Description.

Referenced by Image_Line::bad_line_description().

◆ synchronization_lost()

bool synchronization_lost ( )
inline

Check for lost line synchronization.

If, during acquisition of the next line, the line header synchronization is lost this condition will be flagged.

WARNING: Once line synchronization has been lost the source data stream will be left at a postion indeterminate with respect to the observation data structure. Further processing of the data stream without somehow reacquiring observation data structure synchronization will produce unpredictable results.

Returns
true if line synchronization has been lost and further processing of the data source stream should be discontinued; false if line synchronization is still good.

References Line_Cache::Synchronization_Lost.

Referenced by Image_Line::synchronization_lost().

◆ next_line()

bool next_line ( )

Gets the next line of image data into the Image_Line being managed.

If the line count has reached the total number of lines expected for the Image_Line being managed nothing is done. This is the only case where false is returned.

If the next available line number is greater than the expected current line a patched line is generated for the managed line using gap values.

The cache storage is refilled as needed to contain enough data for a new line plus a following line header (plus a little extra for checking purposes). The refill is done indirectly using the cache pointer of the managed line. This ensures that the cache storage will be refilled using the cache mechanism chosen by the managed line.

For line 0 the initial line header at the beginning of the cache is checked and corrected as necessary. If a line header is found here that does not contain the expected channel number then an out_of_range exception is thrown.

If the current line is the last line, or insufficient data was available for a complete line, the remaining data from the cache is used. When insufficient data is available the managed line is patched.

If the line header for the next line is found at the expected location in the cache the managed line data is set to the location of the current line data in the cache storage.

If the line header for the next line is not found at the expected location the cache storage is searched for the next line header from the location just after the starting line header to a position slightly past (two line headers worth) where the next line header was expected. If one is not found then one is created at the expected location. If this location does not contain gap data then the header for the current line and newly created next line header are marked as being attached to a bad line. If the search found a line header then it is checked as being the expected following line header (or fixed if it fell on the edge of gap data). If this header is found to contain the line number for the currently expected line, then the position of the next line header is set to this line header and this method is called recursively to get the next line. If the line number in the header is less than the current line number, or the channel number it contains is not the expected channel number, then line synchronization has been lost and an out_of_range exception is thrown. Otherwise the managed line is patched with data from the current line header up to, but not including, the next line header.

The location of the line header following the current line header is set in the Cache as the next data location and the line counter is incremented before returning a true value.

N.B.: If line synchronization is lost as a result of finding a line header that does not contain the expected channel number all remaing lines will be gap filled.

Returns
true if the next line of image data was obtained; false otherwise.
See also
Image_Line::total_lines()
patch(char*, char*)
Image_Line::bad_line()
Image_Line::expected_channel()

References Cache::amount_consumed(), Cache::amount_free(), Cache::amount_remaining(), Image_Line::bad_line(), Line_Cache::Bad_Line_Description, Image_Line::cache(), Image_Line::channel(), Image_Line::Channel_Number, Line_Cache::compressed_data(), Data_Component::data(), Line_Cache::Data_Bytes, Cache::last(), Line_Cache::Line, Line_Cache::Line_Count, Image_Line::LINE_HEADER_BYTES, Image_Line::line_number(), Line_Cache::Next_Bad_Line_Description, Line_Cache::Next_Line_Number, Image_Line::print(), Line_Cache::refill(), Data_Block::size(), Cache::state_report(), Image_Line::SYNC, Image_Line::sync(), Line_Cache::Synchronization_Lost, and Image_Line::Total_Lines.

Referenced by Image_Line::next().

◆ refill()

bool refill ( unsigned long  max_amount = (unsigned long)-1)
virtual

Refills the cache storage from the data source stream.

Parameters
max_amountThe maximum amount of data to obtain.
Returns
false if no more data is available; true otherwise. N.B.: If the cache storage is full no data will be read but the return value will still be true.

Reimplemented from Cache.

Reimplemented in FELICS_Line_Cache.

Referenced by Line_Cache::next_line().

◆ reset()

void reset ( )
virtual

Resets the cache to its empty state and the line structure to match the current structure of the managed line.

The structure of the reserved line is reset to match the structure of the managed line, the line counters are reset to zero, and the cache storage is reset to its empty state.

Reimplemented from Cache.

Reimplemented in FELICS_Line_Cache.

References Line_Cache::Data_Bytes, Image_Line::expected_channel(), Line_Cache::Line, Line_Cache::Line_Count, Line_Cache::Next_Line_Number, Image_Line::pixel_bytes(), Image_Line::pixel_count(), and Image_Line::total_lines().

Referenced by FELICS_Line_Cache::reset(), Line_Cache::source(), and Image_Line::total_lines().

◆ offset()

unsigned long long offset ( char *  location) const
inlineprotected

Gets the source offset location of a cache location.

Parameters
locationAn address (char*) of a cache location.
Returns
The offset (bytes) of the location relative to the source location when the number of bytes read was last zero.

References Cache::amount_used(), Line_Cache::bytes_read(), and Cache::start().

Member Data Documentation

◆ ID

const char *const ID
static
Initial value:
=
"UA::HiRISE::Line_Cache (1.23 2020/02/14 01:17:18)"

Class identification name with source code version and date.

Referenced by main().

◆ Line

Image_Line* Line
protected

◆ Data_Bytes

unsigned long long Data_Bytes
protected

The number of source data bytes used for line data.

See also
source_bytes()

Referenced by Line_Cache::next_line(), Line_Cache::reset(), and Line_Cache::source_bytes().

◆ Line_Count

unsigned int Line_Count
protected

The count of lines logically found so far.

Referenced by Line_Cache::count(), Line_Cache::next_line(), and Line_Cache::reset().

◆ Next_Line_Number

unsigned int Next_Line_Number
protected

The number of the next line available in the cache.

Referenced by Line_Cache::next_line(), and Line_Cache::reset().

◆ Synchronization_Lost

bool Synchronization_Lost
protected

Has line synchronization been lost?

Referenced by Line_Cache::next_line(), and Line_Cache::synchronization_lost().

◆ Bad_Line_Description

std::ostringstream Bad_Line_Description
protected

Message describing the reason for a repaired line.

If a delivered line has been repaired in any way there should be a bad line description for it. Before each line is assembled the bad line description is replaced with the Next_Bad_Line_Description which is then appended with any new messages.

Referenced by Line_Cache::bad_line_description(), and Line_Cache::next_line().

◆ Next_Bad_Line_Description

std::string Next_Bad_Line_Description
protected

Message intended for the next line to be assembled.

During line data checking the line header for the next line is identified to ensure line structure integrity. Repairs to this next line header result in an explanation message that typically needs to be carried over and applied to the following line where it will be used to set the Bad_Line_Description.

Referenced by Line_Cache::next_line().


The documentation for this class was generated from the following files: