Observation
|
A Gap_Map contains a map of data gap ranges for the file with which it is associated. More...
#include <Gap_Map.hh>
Public Types | |
enum | End_Point { RANGE_START, RANGE_END } |
Gap range end-point value symbols. More... | |
enum | { INSIDE = -1, OUTSIDE = 0, OVERLAP = 1 } |
Return values for in_gap(Location, Location) method. More... | |
typedef u_int_32 | Location |
A gap range end-point offset location value. | |
typedef std::pair< Location, Location > | Range |
A gap range end-point pair of offset location values. | |
typedef std::vector< Range > | List |
A list of gap range pairs. | |
Public Member Functions | |
Gap_Map () | |
Constructs an empty Gap_Map. | |
Gap_Map (std::istream &stream, unsigned int count) | |
Constructs a Gap_Map loaded from a data stream. | |
Gap_Map (const Gap_Map &map, bool data_duplicate=true) | |
Copy constructor. | |
Gap_Map & | operator= (const Gap_Map &map) |
Assigns another Gap_Map to this one. | |
virtual std::string | id () const |
Provides the class ID on a line followed by the base Data_Component::id. | |
virtual const char * | name () const |
Gets the NAME of this class. | |
virtual Location | get (Index range, End_Point end_point) const |
Gets a gap range end-point value. | |
Gap_Map::Range | gap (Index range) const |
Gets a gap Range. | |
Gap_Map::List | gaps () const |
Gets a List of Range pairs from the map. | |
unsigned int | total_gaps () const |
Gets the total number of gap segments in the map. | |
bool | in_gap (const Location location) const |
Tests if a location falls in a gap range. | |
int | in_gap (const Location start, const Location end) const |
Tests if a [start, end) range overlaps a gap range in the map. | |
int | in_gap (const Gap_Map::Range &range) const |
Tests if a Range overlaps a gap range in the map. | |
Gap_Map & | set (const Location start, const Location end) |
Sets a gap range. | |
Gap_Map & | set (const Gap_Map::Range &range) |
Sets a gap Range. | |
Gap_Map & | set (const Gap_Map::List list) |
Sets a list of gap ranges. | |
Gap_Map & | clear (const Location start, const Location end) |
Clears a gap range. | |
Gap_Map & | clear () |
Clears the entire map. | |
Gap_Map & | clear (const Gap_Map::Range &range) |
Clears a gap range. | |
Gap_Map & | clear (const Gap_Map::List list) |
Clears a list of gap ranges. | |
Gap_Map & | shift (int_32 amount) |
Shifts all range locations some amount. | |
virtual std::ostream & | print (std::ostream &stream=std::cout, bool verbose=false) const |
Prints the component structure and contents. | |
virtual idaeim::PVL::Aggregate * | PVL () const |
Produces a PVL rendition of the component. | |
idaeim::PVL::Aggregate * | PVL_description () const |
Produces a PVL description of a Gap_Map for a PDS label. | |
virtual bool | is_valid () const |
Tests if the component data is valid. | |
Static Public Member Functions | |
static Gap_Map::List | gaps_in (void *start, void *end, unsigned int threshold=0) |
Gets a list of gap ranges in a data block. | |
static unsigned int | sequence_threshold (unsigned int threshold=0) |
Gets the sequence threshold for determining a gap segment range, optionally setting a new threshold. | |
static Gap_Map::Range & | shift (Gap_Map::Range &range, int_32 amount) |
Shifts the end points of a Range some amount. | |
static Gap_Map::List & | shift (Gap_Map::List &list, int_32 amount) |
Shifts a List of Ranges some amount. | |
Static Public Attributes | |
static const char *const | ID = "UA::HiRISE::Gap_Map (1.14 2020/02/14 01:17:18)" |
Class identification name with source code version and date. | |
static const char *const | NAME = "Gap Map" |
The component name. | |
static const char *const | END_POINT_NAMES [] |
Gap range end-point value names. | |
static const unsigned int | DEFAULT_SEQUENCE_THRESHOLD = GAP_MAP_DEFAULT_SEQUENCE_THRESHOLD |
The default sequence of gap byte values required for a gap segment. | |
static const u_int_8 | GAP_BYTE_VALUE = 0xFF |
The value of a "gap filled" data byte. | |
Protected Member Functions | |
virtual Data_Component & | put (const Location location, Index range, End_Point end_point) |
Puts a the value of an end-point into a gap range. | |
Gap_Map & | insert_range (Index range, Location start, Location end) |
Inserts a new range into the map. | |
Gap_Map & | remove_range (Index first, Index last=(Index)-1) |
Removes ranges from the map. |
A Gap_Map contains a map of data gap ranges for the file with which it is associated.
The map is composed of [start, end) Range value pairs where each pair defines the location of a gap segment in the associated file. The ranges are non-overlapping and ordered by increasing location values.
A data gap segment is defined as a contiguous sequence of gap byte values. The sequence threshold defines the minimum number of gap byte values that must be identified for a segment to be recognized.
N.B.: The Gap_Map is implemented as a Data_Block containing a single array element of end-point values; two per range segment.
Note: There is no Gap_Map component in an observation data file; one is generated for EDR product files. The Data_Component interface is provided for consistency with all other observation and EDR file components.
1.10
enum End_Point |
anonymous enum |
Gap_Map | ( | std::istream & | stream, |
unsigned int | count | ||
) |
Constructs a Gap_Map loaded from a data stream.
If the specified count of gap ranges can not be read from the stream the count will be adjusted to the nearest number of complete ranges actually read. Any extra bytes read are ignored. No more data is read than required for the range count specified.
stream | The istream from which to read the component data. |
count | The number of ranges in the map. |
Copy constructor.
map | The Gap_Map to be copied. |
data_duplicate | true if the data content of the copied component is to be duplicated in the copy; false if the data content is to be shared. |
Assigns another Gap_Map to this one.
map | The Gap_Map to be assigned. |
References Data_Component::operator=().
std::string id | ( | ) | const [virtual] |
Provides the class ID on a line followed by the base Data_Component::id.
Reimplemented from Data_Component.
References Gap_Map::ID.
const char * name | ( | ) | const [virtual] |
Gets the NAME of this class.
Implements Data_Component.
References Gap_Map::NAME.
Gap_Map::Location get | ( | Index | range, |
End_Point | end_point | ||
) | const [virtual] |
Gets a gap range end-point value.
range | The gap range to get. |
end_point | Either RANGE_START or RANGE_END. |
std::out_of_range | if the range is not in the map. |
std::invalid_argument | if an invalid end-point is specified. |
References Data_Component::get(), and ID.
Gap_Map::Range gap | ( | Index | range ) | const |
Gets a gap Range.
A gap Range has start (inclusive) and end (exclusive) end-point location values as its first and second values, respectively.
range | The gap range to get. |
std::out_of_range | if the range is not in the map. |
References ID.
Referenced by Gap_Map::gaps().
Gap_Map::List gaps | ( | ) | const |
Gets a List of Range pairs from the map.
References Gap_Map::gap(), and Gap_Map::total_gaps().
unsigned int total_gaps | ( | ) | const [inline] |
Gets the total number of gap segments in the map.
References Data_Block::count_of().
Referenced by Gap_Map::gaps(), main(), Gap_Map::PVL(), and Gap_Map::PVL_description().
bool in_gap | ( | const Location | location ) | const |
Tests if a location falls in a gap range.
location | The location to be tested. |
Referenced by Observation::components().
Tests if a [start, end) range overlaps a gap range in the map.
Reverse range locations - in which start > end - may be specified (see the Note for the set method).
start | The starting (inclusive) location byte (0-based) of the range. |
end | The ending (exclusive) location byte of the range. |
int in_gap | ( | const Gap_Map::Range & | range ) | const [inline] |
Tests if a Range overlaps a gap range in the map.
range | The Range to be tested. |
References Gap_Map::in_gap().
Referenced by Gap_Map::in_gap().
Sets a gap range.
The range may overlap existing ranges in the map. A range that falls totally within an existing map range results in no change to the map. A range that extends beyond existing map ranges results in coalescing overlapped ranges: all overlapped or abutted ranges will become one range - additional ranges are removed - with its start location at the lesser of the map range and specified range start locations and its end location at the greater of the map range and specified range end locations. If the range does not overlap any existing map ranges a new range will be inserted at the appropriate place in the map.
Note: The start and end locations may be specified in descending order - with start > end. The start location will still be inclusive and the end location exclusive. Thus the reverse range [n, m), where n > m, becomes [m+1, n+1). N.B.: Reverse ranges can never include 0 because, since Location values are unsigned, an end location of -1 is interpreted as the largest possible positive value.
start | The starting (inclusive) location byte (0-based) of the range. |
end | The ending (exclusive) location byte of the range. |
Referenced by Observation::components(), and Observation::line().
Gap_Map& set | ( | const Gap_Map::Range & | range ) | [inline] |
Sets a gap Range.
range | The Range to be set. |
Gap_Map & set | ( | const Gap_Map::List | list ) |
Sets a list of gap ranges.
list | The list of gap ranges to be set. |
Clears a gap range.
Reverse range locations - in which start > end - may be specified (see the Note for the set method).
The range may overlap existing map ranges. Completely overlapped ranges are removed. Ranges partially overlapped at the start or end have their start or end moved to the end or start of the specified range. A range that falls totally within an existing map range results in the range end being set to the specified range start and a new range inserted in the map with its start at the specified range end and its end at the map range end. A range that does not overlap any existing map ranges results in no change to the map.
start | The starting (inclusive) location byte (0-based) of the range. |
end | The ending (exclusive) location byte of the range. |
Referenced by Observation::components().
Gap_Map& clear | ( | ) | [inline] |
Clears the entire map.
References Gap_Map::clear().
Referenced by Gap_Map::clear().
Gap_Map& clear | ( | const Gap_Map::Range & | range ) | [inline] |
Clears a gap range.
range | The Range to be cleared. |
References Gap_Map::clear().
Referenced by Gap_Map::clear().
Gap_Map & clear | ( | const Gap_Map::List | list ) |
Clears a list of gap ranges.
list | The list of gap ranges to be cleared. |
Gap_Map & shift | ( | int_32 | amount ) |
Shifts all range locations some amount.
A negative shift that would move a range start location below 0 results in the range start being clipped to 0. If the shift would move a range end location at or below 0 the range is removed from the map.
amount | The amount of the shift (positive or negative). |
Referenced by Observation::components(), and Observation::line().
Data_Component & put | ( | const Location | location, |
Index | range, | ||
End_Point | end_point | ||
) | [protected, virtual] |
Puts a the value of an end-point into a gap range.
The gap range is reset to the new range.
location | The end-point location. |
range | The gap range to modify. |
end_point | Either RANGE_START or RANGE_END. |
std::out_of_range | if the range is not in the map. |
std::invalid_argument | if an invalid end-point is specified. |
References ID.
Inserts a new range into the map.
The range may not overlap any existing map ranges. The new range will be inserted before the specified range.
range | The Index where the new range is to be inserted in the gap map. |
start | The starting (inclusive) location byte (0-based) of the range. |
end | The ending (exclusive) location byte of the range. |
range_error | If the range number is greater than the current number of map ranges, the start of the range is greater than or equal to the end of the preceeding map range (if there is one), or the end of the range is greater than or equal to the start of the following map range. |
References ID.
Removes ranges from the map.
All ranges from first to last (inclusive) are removed from the map. If only one range is specified it will be the only one removed. Ranges not in the map are silently ignored.
first | The number (0-based) of the first range to be removed. |
last | The number of the last range to be removed. This argument is optional. |
ostream & print | ( | std::ostream & | stream = std::cout , |
bool | verbose = false |
||
) | const [virtual] |
Prints the component structure and contents.
Each range of the map is printed on a separate line. Each range description line has the format:
Element@Offset:Count*Size : Start End
where:
All parts of the listing are right justified in their space padded fields. Values that are longer than the available field width will result in a larger field to accommodate the entire value.
stream | The ostream where the listing will be written. |
verbose | true if the class name and ID are to be included in the listing. |
Implements Data_Component.
References ID.
Referenced by list_selections(), and main().
Aggregate * PVL | ( | ) | const [virtual] |
Produces a PVL rendition of the component.
The map is described as an Array of (start, end) Integer pairs.
Implements Data_Component.
References Aggregate::add(), Vectal< T >::clear(), Gap_Map::NAME, Gap_Map::RANGE_END, Gap_Map::RANGE_START, and Gap_Map::total_gaps().
Referenced by list_selections(), and main().
Aggregate * PVL_description | ( | ) | const |
Produces a PVL description of a Gap_Map for a PDS label.
The description is an OBJECT that contains the PDS parameters required to describe a data product binary data object.
References Parser::get_parameters(), Gap_Map::ID, and Gap_Map::total_gaps().
bool is_valid | ( | ) | const [virtual] |
Tests if the component data is valid.
Implements Data_Component.
Gap_Map::List gaps_in | ( | void * | start, |
void * | end, | ||
unsigned int | threshold = 0 |
||
) | [static] |
Gets a list of gap ranges in a data block.
The data block is scanned for data bytes with a value of GAP_BYTE_VALUE. The number of such contigous bytes must reach a threshold for a gap segment to be identified.
start | The address where the data block starts (inclusive). |
end | The address where the data block ends (exclusive). |
threshold | The gap sequence threshold to use. If not specified (or zero) the sequence threshold is used. |
Referenced by Observation::components(), and Observation::line().
unsigned int sequence_threshold | ( | unsigned int | threshold = 0 ) |
[static] |
Gets the sequence threshold for determining a gap segment range, optionally setting a new threshold.
The sequence threshold is the minimum number of contiguous data bytes with a value of GAP_BYTE_VALUE that are required to identify a gap segment. The value is intialized to the DEFAULT_SEQUENCE_THRESHOLD value.
threshold | The new sequence threshold amount. If not provided (or zero) a new value will not be set. |
Referenced by Observation::components().
Gap_Map::Range & shift | ( | Gap_Map::Range & | range, |
int_32 | amount | ||
) | [static] |
Shifts the end points of a Range some amount.
If the shift would move the range end location at or below 0 the range becomes empty in the sense that both its lower and upper bounds are zero.
range | The Range to have its end points shifted. |
amount | The amount of the shift (positive or negative). |
Gap_Map::List & shift | ( | Gap_Map::List & | list, |
int_32 | amount | ||
) | [static] |
Shifts a List of Ranges some amount.
list | The List containing the ranges to be shifted. |
amount | The amount of the shift (positive or negative). |
const char *const ID = "UA::HiRISE::Gap_Map (1.14 2020/02/14 01:17:18)" [static] |
Class identification name with source code version and date.
Reimplemented from Data_Component.
Referenced by Gap_Map::id(), and Gap_Map::PVL_description().
const char *const NAME = "Gap Map" [static] |
The component name.
Referenced by Gap_Map::name(), and Gap_Map::PVL().
const char *const END_POINT_NAMES [static] |
{ "start", "end" }
Gap range end-point value names.
const unsigned int DEFAULT_SEQUENCE_THRESHOLD = GAP_MAP_DEFAULT_SEQUENCE_THRESHOLD [static] |
The default sequence of gap byte values required for a gap segment.
const u_int_8 GAP_BYTE_VALUE = 0xFF [static] |
The value of a "gap filled" data byte.
Referenced by Observation::components().