Unpacker.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 -2011 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Kernel/Classes/dsp/Unpacker.h
10 
11 
12 #ifndef __Unpacker_h
13 #define __Unpacker_h
14 
15 #include "dsp/Transformation.h"
16 #include "dsp/TimeSeries.h"
17 #include "dsp/BitSeries.h"
18 #include "dsp/Input.h"
19 
20 #include "Registry.h"
21 
22 namespace dsp {
23 
25 
37  class Unpacker : public Transformation <BitSeries, TimeSeries>
38  {
39 
40  public:
41 
43  Unpacker (const char* name = "Unpacker");
44 
46  virtual Unpacker* clone() const;
47 
49  static Unpacker* create (const Observation* observation);
50 
52  virtual bool get_order_supported (TimeSeries::Order) const;
53 
55  virtual void set_output_order (TimeSeries::Order);
56 
58  virtual bool get_device_supported (Memory*) const;
59 
61  virtual void set_device (Memory*);
62 
64 
66  virtual bool matches (const Observation* observation) = 0;
67 
69  virtual void match_resolution (Input*) {}
70 
72  virtual unsigned get_resolution () const { return 0; }
73 
75  void prepare ();
76 
78  void reserve ();
79 
81  class Iterator;
82 
84  Iterator get_iterator (unsigned idig);
85 
88 
89  protected:
90 
93 
95  virtual void transformation ();
96 
98 
100  virtual void unpack () = 0;
101 
103  virtual void match (const Observation* observation);
104 
106  static Register& get_register();
107 
109  template<class T>
110  const T* get_Input ()
111  {
112  const Input* input = NULL;
113 
114  if (get_input())
115  if (get_input()->get_loader())
117 
118  if (!input)
119  throw Error (InvalidState, "Unpacker::get_Input",
120  "Input object does not exist");
121 
122  const T* ptr = dynamic_cast<const T*>( input );
123  if( ptr )
124  return ptr;
125 
126  throw Error (InvalidState, "Unpacker::get_Input",
127  "BitSeries::input is not of required type");
128  }
129  };
130 
131 }
132 
133 #endif // !defined(__Unpacker_h)
Registry::List< Unpacker > Register
typedef used to simplify template syntax in Unpacker_registry.C
Definition: Unpacker.h:97
virtual unsigned get_resolution() const
Return the smallest number of time samples that can be unpacked.
Definition: Unpacker.h:82
const BitSeries * get_input() const
Return pointer to the container from which input data will be read.
Definition: HasInput.h:41
virtual void set_output_order(TimeSeries::Order)
Set the order of the dimensions in the output TimeSeries.
Definition: Unpacker.C:65
void prepare()
Copy the input attributes to the output.
Definition: Unpacker.C:29
virtual void set_device(Memory *)
Set the device on which the unpacker will operate.
Definition: Unpacker.C:79
Pure virtual base class of all objects that can load BitSeries data.
Definition: Input.h:31
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
Defines the interface by which Transformations are performed on data.
Definition: Transformation.h:54
virtual const Input * get_origin() const
The origin of the data may be re-implemented by wrappers like SerialFiles.
Definition: Input.h:47
Order
Order of the dimensions.
Definition: TimeSeries.h:39
std::string name
Operation name.
Definition: Operation.h:153
static Register & get_register()
Return the list of registered sub-classes.
Definition: Unpacker_registry.C:337
void reserve()
Reserve the maximum amount of space required in the output.
Definition: Unpacker.C:41
Unpacker(const char *name="Unpacker")
Constructor.
Definition: Unpacker.C:16
Stores information about digital, band-limited, time-varying signals.
Definition: Observation.h:33
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
virtual void unpack()=0
The unpacking routine.
virtual void transformation()
The operation unpacks n-bit into floating point TimeSeries.
Definition: Unpacker.C:87
Manages memory allocation and destruction on the host machine.
Definition: MemoryHost.h:22
virtual bool matches(const Observation *observation)=0
Return true if the derived class can convert the Observation.
const Input * get_loader() const
Accessing the Input is not thread-safe.
Definition: BitSeries.h:99
TimeSeries::Order output_order
The order of the dimensions in the output TimeSeries.
Definition: Unpacker.h:102
virtual Unpacker * clone() const
Clone operator.
Definition: Unpacker.C:22
A container for storing digitized (generally not floating point) data
Definition: BitSeries.h:35
virtual void match(const Observation *observation)
Specialize the Unpacker for the Observation.
Definition: Unpacker.C:122
const T * get_Input()
Provide BitSeries::input attribute access to derived classes.
Definition: Unpacker.h:120
Abstract base class of Transformations that convert n-bit to float.
Definition: Unpacker.h:42
Iterator get_iterator(unsigned idig)
Return the iterator for the specified digitizer.
Definition: Unpacker.C:129
static Unpacker * create(const Observation *observation)
Return a pointer to a new instance of the appropriate sub-class.
Definition: Unpacker_create.C:13
virtual void match_resolution(Input *)
Match the unpacker to the resolution of the Input.
Definition: Unpacker.h:79
virtual bool get_order_supported(TimeSeries::Order) const
Return true if the unpacker supports the specified output order.
Definition: Unpacker.C:58
Interface to Unpacker iterator implementations.
Definition: UnpackerIterator.h:24
Pure virtual base class of objects that manage memory allocation and destruction.
Definition: Memory.h:23
virtual bool get_device_supported(Memory *) const
Return true if the unpacker can operate on the specified device.
Definition: Unpacker.C:73
Reference::To< const BitSeries > input
Container from which input data will be read.
Definition: HasInput.h:49
@ OrderFPT
Frequency, Polarization, Time (default before 3 October 2008)
Definition: TimeSeries.h:47

Generated using doxygen 1.8.17