Pure virtual base class of all objects that can load BitSeries data. More...

#include <Input.h>

Inheritance diagram for dsp::Input:
dsp::Operation OwnStream Reference::Able Reference::HeapTracked dsp::MPIRoot dsp::Seekable dsp::MPITrans dsp::File dsp::BCPMFile dsp::BlockFile dsp::CPSR2File dsp::CPSRFile dsp::DADABuffer dsp::DADAFile dsp::DummyFile dsp::FadcFile dsp::FITSFile dsp::GMRTBinaryFile dsp::GMRTFilterbankFile dsp::GUPPIBlockFile dsp::LBADR64_File dsp::LOFAR_DALFile dsp::LuMPFile dsp::Mark4File dsp::MaximFile dsp::MultiFile dsp::PdevFile dsp::PuMa2File dsp::PuMaFile dsp::S2File dsp::SigProcFile dsp::SMROFile dsp::SPDA1K_File dsp::SpigotFile dsp::WAPPFile

Public Types

typedef BitSeries OutputType
 
- Public Types inherited from dsp::Operation
enum  Function { Producer, Procedural, Structural }
 The function of the operator. More...
 

Public Member Functions

 Input (const char *name)
 Constructor.
 
virtual ~Input ()
 Destructor.
 
virtual const Inputget_origin () const
 The origin of the data may be re-implemented by wrappers like SerialFiles.
 
virtual void copy (const Input *input)
 Copies the behaviour and information attributes (not data) More...
 
void prepare ()
 Prepare the output with the attributes of the data source.
 
void reserve ()
 Reserve the maximum amount of output space required.
 
void reserve (BitSeries *)
 Reserve the maximum amount of space required in the given container.
 
virtual bool eod () const =0
 End of data.
 
virtual void restart ()
 Return to the start of data, if possible.
 
void load (BitSeries *data)
 Load BitSeries data. More...
 
virtual void set_output (BitSeries *data)
 Set the BitSeries to which data will be loaded.
 
virtual BitSeriesget_output ()
 Retrieve a pointer to the output. More...
 
virtual bool has_output () const
 Return true if output is set.
 
virtual void seek (int64_t offset, int whence=0)
 Seek to the specified time sample. More...
 
uint64_t tell () const
 Return the first time sample to be read on the next call to operate.
 
virtual void seek (const MJD &mjd)
 Seek to a sample close to the specified MJD.
 
virtual uint64_t get_block_size () const
 Return the number of time samples to load on each load_block.
 
virtual void set_block_size (uint64_t _size)
 Set the number of time samples to load on each load_block. More...
 
virtual uint64_t get_overlap () const
 Return the number of time samples by which consecutive blocks overlap.
 
virtual void set_overlap (uint64_t _overlap)
 Set the number of time samples by which consecutive blocks overlap.
 
virtual uint64_t get_stride () const
 Convenience function for returning block_size-overlap.
 
virtual uint64_t get_total_samples () const
 Return the total number of time samples available.
 
void set_total_samples (uint64_t s)
 Set the total number of time samples available. More...
 
 operator const Observation * () const
 Get the information about the data source.
 
virtual Observationget_info ()
 Get the information about the data source.
 
virtual const Observationget_info () const
 Get the information about the data source.
 
uint64_t get_load_sample () const
 Get the next time sample to be loaded.
 
uint64_t get_load_size () const
 Get the number of samples to be loaded.
 
unsigned get_resolution () const
 Get the time sample resolution of the data source.
 
void set_resolution (unsigned res)
 Set the time sample resolution of the data source (use with care)
 
void seek_seconds (double seconds, int whence=0)
 Convenience method used to seek in units of seconds.
 
double tell_seconds () const
 Convenience method used to report the offset in seconds.
 
void set_start_seconds (double seconds)
 Set the start of observation offset in units of seconds.
 
void set_total_seconds (double seconds)
 Convenience method used to set the number of seconds.
 
void set_context (ThreadContext *context)
 In multi-threaded programs, a mutual exclusion and a condition.
 
bool has_context () const
 Return true if the thread context has been set.
 
virtual std::string get_prefix () const
 Input derived types may specify a prefix to be added to output files.
 
- Public Member Functions inherited from dsp::Operation
 Operation (const char *name)
 All sub-classes must specify a unique name. More...
 
 Operation (const Operation &)
 Copy constructor.
 
virtual ~Operation ()
 Virtual destructor.
 
virtual bool operate ()
 Call this method to operate on data Returns false on failure. More...
 
virtual void add_extensions (Extensions *)
 Add any extensions.
 
virtual void combine (const Operation *)
 Combine accumulated results with another operation. More...
 
virtual void report () const
 Report operation statistics.
 
virtual void reset ()
 Reset accumulated results to intial values. More...
 
std::string get_name () const
 Return the unique name of this operation.
 
double get_total_time () const
 Return the total time spent on this Operation in seconds.
 
double get_elapsed_time () const
 Get the time spent in the last invocation of operate()
 
virtual uint64_t get_total_weights () const
 Return the total number of timesample weights encountered. More...
 
virtual uint64_t get_discarded_weights () const
 Return the number of invalid timesample weights encountered.
 
int get_id ()
 Inquire the unique instantiation id.
 
virtual Function get_function () const
 Get the function classification of this operation.
 
virtual double get_delay_time () const
 Get the time delay of this operation, if any, in seconds.
 
virtual void set_scratch (Scratch *)
 Set the scratch space.
 
bool scratch_was_set () const
 
virtual uint64_t bytes_storage () const
 The number of bytes of additional storage used by the operation.
 
virtual uint64_t bytes_scratch () const
 The number of bytes of scratch space used by the operation. More...
 
- Public Member Functions inherited from OwnStream
 OwnStream (const OwnStream &)
 
const OwnStreamoperator= (const OwnStream &)
 
virtual void set_cout (std::ostream &) const
 
virtual void set_cerr (std::ostream &) const
 
- Public Member Functions inherited from Reference::Able
 Able (const Able &)
 
Ableoperator= (const Able &)
 
unsigned get_reference_count () const
 
- Public Member Functions inherited from Reference::HeapTracked
 HeapTracked (const HeapTracked &)
 
HeapTrackedoperator= (const HeapTracked &)
 
bool __is_on_heap () const
 

Protected Member Functions

virtual void set_eod (bool)=0
 Set the 'end_of_data' flag in dsp::Seekable.
 
virtual void load_data (BitSeries *data)=0
 Load the next block of time samples into BitSeries. More...
 
virtual void operation ()
 Load data into the BitSeries specified with set_output. More...
 
virtual void mark_output ()
 Mark the output BitSeries with sequence informatin.
 
- Protected Member Functions inherited from dsp::Operation
virtual bool can_operate ()
 Return false if the operation doesn't have enough data to proceed.
 
virtual void set_name (const std::string &_name)
 Set the name!
 
int timers_index (const std::string &op_name)
 Returns the index in the 'timers' array of a particular timer.
 
- Protected Member Functions inherited from Reference::Able
Handle__reference (bool active) const
 
void __dereference (bool auto_delete=true) const
 

Protected Attributes

Reference::To< BitSeriesoutput
 The BitSeries to which data will be loaded on next call to operate.
 
Reference::To< Observationinfo
 Information about the data source (passed on to BitSeries in load)
 
unsigned resolution
 Time sample resolution of the data source. More...
 
uint64_t last_load_ndat
 The ndat of the BitSeries last loaded Used by Seekable::recycle_data() and set by load()
 
std::string real_source
 If not "" then the source of the output gets changed to this after loading [""].
 
- Protected Attributes inherited from dsp::Operation
Scratchscratch
 Shared scratch space, if needed.
 
bool set_scratch_called
 
std::string name
 Operation name.
 
uint64_t discarded_weights
 Number of time sample weights encountered that are flagged invalid.
 
uint64_t total_weights
 Total number of time sample weights encountered.
 
RealTimer optime
 Stop watch records the amount of time spent performing this operation.
 
int id
 Unique instantiation id.
 
bool prepared
 Set true when preparation optimizations are completed.
 

Friends

class IOManager
 

Additional Inherited Members

- Static Public Member Functions inherited from Reference::Able
static size_t get_instance_count ()
 
- Static Public Member Functions inherited from Reference::HeapTracked
static void * operator new (size_t size, void *ptr=0)
 
static void operator delete (void *location, void *ptr)
 
static void operator delete (void *location)
 
static size_t get_heap_queue_size ()
 
- Static Public Attributes inherited from dsp::Operation
static bool record_time = false
 Global flag enables stopwatch to record the time spent operating. More...
 
static bool report_time = true
 Global flag enables report of time spent in operation on descruction. More...
 
static bool verbose = false
 Global verbosity flag.
 
static int operation_status = 0
 Operations can set this to non-zero in operation() if they fail.
 
static bool check_state = true
 Operations should perform internal consistency checks.
 
static int instantiation_count = 0
 Counts how many Operation instantiations there have been Used for setting the unique instantiation ID. More...
 

Detailed Description

Pure virtual base class of all objects that can load BitSeries data.

This class defines the common interface as well as some basic functionality relating to sources of BitSeries data.

Member Function Documentation

◆ copy()

void dsp::Input::copy ( const Input input)
virtual

Copies the behaviour and information attributes (not data)

copies the following behavioural and informational attributes:

  • block_size
  • overlap
  • info
  • resolution

◆ get_output()

dsp::BitSeries * dsp::Input::get_output ( )
virtual

Retrieve a pointer to the output.

throws an exception if the output is not set. To test if the output attribute is set, use Input::has_output.

◆ load()

void dsp::Input::load ( BitSeries data)

Load BitSeries data.

Only this load method is guaranteed to be thread safe

Set the Observation attributes of data and load the next block of data. Because set_output and operate must be called separately, the only thread-safe interface to the Input class.

◆ load_data()

virtual void dsp::Input::load_data ( BitSeries data)
protectedpure virtual

Load the next block of time samples into BitSeries.

Implementations of this method must read get_load_size time samples, beginning with get_load_sample

Implemented in dsp::MPIRoot, dsp::Seekable, and dsp::MPITrans.

◆ operation()

void dsp::Input::operation ( )
protectedvirtual

Load data into the BitSeries specified with set_output.

Load data into the BitSeries specified by set_output.

Implements dsp::Operation.

◆ seek()

void dsp::Input::seek ( int64_t  offset,
int  whence = 0 
)
virtual

Seek to the specified time sample.

ensures that the load_sample attribute accomodates any extra time samples required owing to time sample resolution. also ensures that the load_size attribute is properly set.

Parameters
offsetthe number of time samples to offset
whencefrom where to offset: SEEK_SET, SEEK_CUR, SEEK_END (see <unistd.h>)

Reimplemented in dsp::DADABuffer.

Referenced by dsp::MPIRoot::load_data(), and dsp::DADABuffer::seek().

◆ set_block_size()

void dsp::Input::set_block_size ( uint64_t  size)
virtual

Set the number of time samples to load on each load_block.

ensures that the load_size attribute is properly set.

Reimplemented in dsp::DADABuffer, and dsp::MPIRoot.

Referenced by dsp::MPIRoot::load_data(), dsp::TestInput::runtest(), dsp::MPIRoot::set_block_size(), and dsp::DADABuffer::set_block_size().

◆ set_total_samples()

void dsp::Input::set_total_samples ( uint64_t  s)
inline

Set the total number of time samples available.

Generally useful for debugging

References get_info(), and dsp::Observation::set_ndat().

Member Data Documentation

◆ resolution

unsigned dsp::Input::resolution
protected

Time sample resolution of the data source.

Derived classes must define the smallest number of time samples that can be loaded at one time. For instance, when reading two-bit sampled data, four time samples may be packed into one byte. In this case, resolution == 4.

Referenced by get_resolution(), Input(), dsp::Mark5bFile::open_file(), dsp::Mark5File::open_file(), and set_resolution().


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

Generated using doxygen 1.8.17