HiRISE
 Observation

Gap_Map.hh
Go to the documentation of this file.
1 /* HiRISE Gap Map
2 
3 PIRL CVS ID: Gap_Map.hh,v 1.10 2020/02/25 00:16:17 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_GAP_MAP_
20 #define _HIRISE_GAP_MAP_
21 
22 #include "Data_Component.hh"
23 
24 #if defined (INCLUDE_PVL)
25 // idaeim::PVL
26 #include "PVL.hh"
27 #endif
28 
29 #include <iosfwd>
30 #include <string>
31 #include <vector>
32 #include <utility>
33 
34 namespace UA
35 {
36 namespace HiRISE
37 {
38 /*******************************************************************************
39  Gap_Map
40 */
68 class Gap_Map
69 : public Data_Component
70 {
71 public:
72 /*==============================================================================
73  Types:
74 */
77 
79 typedef std::pair<Location, Location> Range;
80 
82 typedef std::vector<Range> List;
83 
84 /*==============================================================================
85  Constants:
86 */
88 static const char* const
89  ID;
90 
92 static const char* const
94 
97  {
99  RANGE_END
100  };
101 
103 static const char* const
105 
107 enum
108  {
109  INSIDE = -1,
110  OUTSIDE = 0,
111  OVERLAP = 1
112  };
113 
118 static const unsigned int
120 
122 static const u_int_8
124 
125 /*==============================================================================
126  Constructors
127 */
130 Gap_Map ();
131 
142 Gap_Map (std::istream& stream, unsigned int count);
143 
151 Gap_Map (const Gap_Map& map, bool data_duplicate = true);
152 
157 Gap_Map& operator= (const Gap_Map& map);
158 
159 /*==============================================================================
160  Accessors
161 */
168 virtual std::string id () const;
169 
175 virtual const char* name () const;
176 
185 virtual Location get (Index range, End_Point end_point) const;
186 
196 Gap_Map::Range gap (Index range) const;
197 
204 Gap_Map::List gaps () const;
205 
210 unsigned int total_gaps () const
211 {return count_of (0) >> 1;}
212 
218 bool in_gap (const Location location) const;
219 
235 int in_gap (const Location start, const Location end) const;
236 
247 int in_gap (const Gap_Map::Range& range) const
248  {return in_gap (range.first, range.second);}
249 
250 /*==============================================================================
251  Manipulators
252 */
279 Gap_Map& set (const Location start, const Location end);
280 
287 Gap_Map& set (const Gap_Map::Range& range)
288  {return set (range.first, range.second);}
289 
296 Gap_Map& set (const Gap_Map::List list);
297 
318 Gap_Map& clear (const Location start, const Location end);
319 
325  {return clear (0, (Location)-1);}
326 
333 Gap_Map& clear (const Gap_Map::Range& range)
334  {return clear (range.first, range.second);}
335 
342 Gap_Map& clear (const Gap_Map::List list);
343 
354 Gap_Map& shift (int_32 amount);
355 
356 /*------------------------------------------------------------------------------
357  Direct range manipulation.
358 */
359 protected:
360 
372 virtual Data_Component& put
373  (const Location location, Index range, End_Point end_point);
374 
392 Gap_Map& insert_range (Index range, Location start, Location end);
393 
406 Gap_Map& remove_range (Index first, Index last = (Index)-1);
407 
408 /*==============================================================================
409  Printing
410 */
411 public:
450 virtual std::ostream& print
451  (std::ostream& stream = std::cout, bool verbose = false) const;
452 
453 #if defined (INCLUDE_PVL)
454 /*==============================================================================
455  PVL
456 */
465 virtual idaeim::PVL::Aggregate* PVL () const;
466 
477 
478 #endif // defined (INCLUDE_PVL)
479 
480 /*==============================================================================
481  Validation
482 */
487 virtual bool is_valid () const;
488 
489 /*==============================================================================
490  Utility
491 */
506 static Gap_Map::List gaps_in
507  (void* start, void* end, unsigned int threshold = 0);
508 
522 static unsigned int sequence_threshold (unsigned int threshold = 0);
523 
535 static Gap_Map::Range& shift (Gap_Map::Range& range, int_32 amount);
536 
544 static Gap_Map::List& shift (Gap_Map::List& list, int_32 amount);
545 
546 /*------------------------------------------------------------------------------
547  Data
548 */
549 private:
550 
552 static unsigned int
553  Sequence_Threshold;
554 
556 u_int_32
557  Map_Storage_Amount;
558 
559 }; // class Gap_Map
560 
561 /*==============================================================================
562  Helper functions
563 */
571 std::ostream& operator<<
572  (std::ostream& stream, const Gap_Map& map);
573 
574 
575 } // namespace HiRISE
576 } // namespace UA
577 #endif
unsigned int Index
Index count_of(Index element) const
A Data_Component provides a common, virtual interface for all HiRISE Observation data blocks.
Definition: Data_Component.hh:124
A Gap_Map contains a map of data gap ranges for the file with which it is associated.
Definition: Gap_Map.hh:70
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.
Definition: Gap_Map.cc:813
@ OUTSIDE
Definition: Gap_Map.hh:110
@ INSIDE
Definition: Gap_Map.hh:109
@ OVERLAP
Definition: Gap_Map.hh:111
virtual std::ostream & print(std::ostream &stream=std::cout, bool verbose=false) const
Prints the component structure and contents.
Definition: Gap_Map.cc:1139
u_int_32 Location
A gap range end-point offset location value.
Definition: Gap_Map.hh:76
Gap_Map & operator=(const Gap_Map &map)
Assigns another Gap_Map to this one.
Definition: Gap_Map.cc:220
static const u_int_8 GAP_BYTE_VALUE
The value of a "gap filled" data byte.
Definition: Gap_Map.hh:123
End_Point
Gap range end-point value symbols.
Definition: Gap_Map.hh:97
@ RANGE_START
Definition: Gap_Map.hh:98
@ RANGE_END
Definition: Gap_Map.hh:99
Gap_Map & insert_range(Index range, Location start, Location end)
Inserts a new range into the map.
Definition: Gap_Map.cc:848
bool in_gap(const Location location) const
Tests if a location falls in a gap range.
Definition: Gap_Map.cc:313
virtual std::string id() const
Provides the class ID on a line followed by the base Data_Component::id.
Definition: Gap_Map.cc:233
static const unsigned int DEFAULT_SEQUENCE_THRESHOLD
The default sequence of gap byte values required for a gap segment.
Definition: Gap_Map.hh:119
Gap_Map & set(const Location start, const Location end)
Sets a gap range.
Definition: Gap_Map.cc:411
int in_gap(const Gap_Map::Range &range) const
Tests if a Range overlaps a gap range in the map.
Definition: Gap_Map.hh:247
Gap_Map & shift(int_32 amount)
Shifts all range locations some amount.
Definition: Gap_Map.cc:718
virtual Location get(Index range, End_Point end_point) const
Gets a gap range end-point value.
Definition: Gap_Map.cc:244
std::pair< Location, Location > Range
A gap range end-point pair of offset location values.
Definition: Gap_Map.hh:79
virtual const char * name() const
Gets the NAME of this class.
Definition: Gap_Map.cc:238
virtual bool is_valid() const
Tests if the component data is valid.
Definition: Gap_Map.cc:1296
Gap_Map & remove_range(Index first, Index last=(Index) -1)
Removes ranges from the map.
Definition: Gap_Map.cc:966
static unsigned int sequence_threshold(unsigned int threshold=0)
Gets the sequence threshold for determining a gap segment range, optionally setting a new threshold.
Definition: Gap_Map.cc:1281
static const char *const END_POINT_NAMES[]
Gap range end-point value names.
Definition: Gap_Map.hh:104
Gap_Map::Range gap(Index range) const
Gets a gap Range.
Definition: Gap_Map.cc:276
Gap_Map::List gaps() const
Gets a List of Range pairs from the map.
Definition: Gap_Map.cc:296
Gap_Map & clear()
Clears the entire map.
Definition: Gap_Map.hh:324
Gap_Map & clear(const Gap_Map::Range &range)
Clears a gap range.
Definition: Gap_Map.hh:333
unsigned int total_gaps() const
Gets the total number of gap segments in the map.
Definition: Gap_Map.hh:210
Gap_Map & set(const Gap_Map::Range &range)
Sets a gap Range.
Definition: Gap_Map.hh:287
std::vector< Range > List
A list of gap range pairs.
Definition: Gap_Map.hh:82
static const char *const ID
Class identification name with source code version and date.
Definition: Gap_Map.hh:89
static const char *const NAME
The component name.
Definition: Gap_Map.hh:93
static Gap_Map::List gaps_in(void *start, void *end, unsigned int threshold=0)
Gets a list of gap ranges in a data block.
Definition: Gap_Map.cc:1190
idaeim::PVL::Aggregate * PVL_description() const
Produces a PVL description of a Gap_Map for a PDS label.
Definition: Gap_Map.cc:1070
virtual idaeim::PVL::Aggregate * PVL() const
Produces a PVL rendition of the component.
Definition: Gap_Map.cc:1038
Gap_Map()
Constructs an empty Gap_Map.
Definition: Gap_Map.cc:143
unsigned int u_int_32
U_INT_8_TYPE u_int_8
8-bit unsigned integer type.
Definition: Data_Component.hh:56
INT_32_TYPE int_32
32-bit integer type.
Definition: Data_Component.hh:74
PIRL::Data_Block::Index Index
Data_Block element index type.
Definition: Data_Component.hh:95
University of Arizona.