DataSeries.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 by Haydon Knight
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __DataSeries_h
10 #define __DataSeries_h
11 
12 #include "dsp/Observation.h"
13 
14 
15 namespace dsp {
16 
17  class Memory;
18 
20  /* The DataSeries class contains n-bit data arranged as a
21  function of frequency, polarization, time, and dimension, ie.
22 
23  f0p0t0d0...f0p0t0dD,f0p0t1d0...f0p0t1dD...f0p0tTd0...f0p0tTdD,
24  f0p1t0d0...f0p1t0dD,f0p1t1d0...f0p1t1dD...f0p1tTd0...f0p1tTdD,
25  ...
26  f0pPt0d0...f0pPt0dD,f0pPt1d0...f0pPt1dD...f0pPtTd0...f0pPtTdD,
27  f1p0t0d0...f1p0t0dD,f1p0t1d0...f1p0t1dD...f1p0tTd0...f1p0tTdD,
28  ...
29  fFpPt0d0...fFpPt0dD,fFpPt1d0...fFpPt1dD...fFpPtTd0...fFpPtTdD
30  */
31  class DataSeries : public Observation {
32 
33  public:
34 
36  static int instantiation_count;
38  static int64_t memory_used;
39 
42 
44  DataSeries(const DataSeries& ds);
45 
47  void initi();
48 
50  virtual DataSeries* clone() const = 0;
51 
53  virtual DataSeries* null_clone() const = 0;
54 
56  virtual DataSeries& swap_data(DataSeries& ds);
57 
59  virtual ~DataSeries();
60 
62  virtual DataSeries& operator = (const DataSeries& copy);
63 
65  void copy (const Observation* ds);
66 
68  virtual void copy (const DataSeries* ds)
69  { operator=( *ds ); }
70 
72  void set_ndat (uint64_t);
73 
75  void set_ndim (unsigned);
76 
78  void set_npol (unsigned);
79 
81  void set_nchan (unsigned);
82 
84  uint64_t get_ndat_allocated();
85 
87  bool reshape_required () { return shape_changed; };
88 
92  virtual void resize (uint64_t nsamples);
93 
94  virtual void resize (uint64_t nsamples, unsigned char*& old_buffer);
95 
97  void reshape ();
98 
100  void reshape (unsigned npol, unsigned ndim);
101 
103  virtual void zero ();
104 
106  virtual unsigned char* get_udatptr (unsigned ichan=0,unsigned ipol=0);
107 
109  virtual const unsigned char* get_udatptr (unsigned ichan=0,unsigned ipol=0) const;
110 
112  virtual uint64_t get_subsize(){ return subsize; }
113 
115  virtual void internal_match (const DataSeries*);
116 
118  virtual void copy_configuration (const Observation* copy);
119 
121  unsigned char* internal_get_buffer() { return buffer; }
122  const unsigned char* internal_get_buffer() const { return buffer; }
123 
125  uint64_t internal_get_size() const { return size; }
126 
128  uint64_t internal_get_subsize() const { return subsize; }
129 
131  virtual void set_memory (Memory*);
132  const Memory* get_memory () const;
133 
134  protected:
135 
137  virtual unsigned char* get_data();
139  virtual const unsigned char* get_data() const;
140 
142  unsigned char* buffer = nullptr;
143 
145  uint64_t size = 0;
146 
148  uint64_t subsize = 0;
149 
151  bool shape_changed = false;
152 
155 
156  };
157 
158 }
159 
160 #endif
virtual void set_ndat(uint64_t _ndat)
Set the number of time samples in container.
Definition: Observation.h:105
const Observation & operator=(const Observation &)
Assignment operator.
Definition: Observation.C:404
DataSeries()
Null constructor.
Definition: DataSeries.C:20
virtual ~DataSeries()
Destructor.
Definition: DataSeries.C:47
virtual DataSeries & operator=(const DataSeries &copy)
Set this equal to copy.
Definition: DataSeries.C:341
unsigned char * buffer
The data buffer.
Definition: DataSeries.h:147
virtual DataSeries * null_clone() const =0
Returns a null-instantiation (calls new)
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
unsigned get_ndim() const
Return the dimension of each datum.
Definition: Observation.h:80
void set_npol(unsigned)
Set the number of polarizations.
Definition: DataSeries.C:91
uint64_t internal_get_size() const
Return the internal memory size.
Definition: DataSeries.h:130
uint64_t get_ndat() const
Return the number of time samples in container.
Definition: Observation.h:107
void init()
Set all attributes to null default.
Definition: Observation.C:31
virtual DataSeries & swap_data(DataSeries &ds)
Swaps the two DataSeries's. Returns '*this'.
Definition: DataSeries.C:367
void set_ndat(uint64_t)
Enforces that ndat*ndim must be an integer number of bytes.
Definition: DataSeries.C:67
unsigned get_npol() const
Return the number of polarizations.
Definition: Observation.h:90
Reference::To< Memory > memory
The memory manager.
Definition: DataSeries.h:159
uint64_t size
The size of the data buffer (in bytes)
Definition: DataSeries.h:150
virtual void set_npol(unsigned _npol)
Set the number of polarizations.
Definition: Observation.h:88
Stores information about digital, band-limited, time-varying signals.
Definition: Observation.h:33
virtual void zero()
Set all values to zero.
Definition: DataSeries.C:251
virtual void resize(uint64_t nsamples)
Allocate the space required to store nsamples time samples.
Definition: DataSeries.C:121
virtual void internal_match(const DataSeries *)
Match the internal memory layout of another DataSeries.
Definition: DataSeries.C:383
uint64_t subsize
The number of BYTES in a data sub-division.
Definition: DataSeries.h:153
bool shape_changed
Flag for whether the shape of the data series has changed.
Definition: DataSeries.h:156
virtual void set_ndim(unsigned _ndim)
Set the dimension of each datum.
Definition: Observation.h:78
virtual void set_nchan(unsigned _nchan)
Set the number of channels into which the band is divided.
Definition: Observation.h:83
void copy(const Observation *ds)
Same as operator= but takes a pointer.
Definition: DataSeries.C:331
unsigned char * internal_get_buffer()
Return the internal memory base address.
Definition: DataSeries.h:126
void set_ndim(unsigned)
Enforces that ndat*ndim must be an integer number of bytes.
Definition: DataSeries.C:78
uint64_t internal_get_subsize() const
Return the internal memory sub-division size.
Definition: DataSeries.h:133
uint64_t get_ndat_allocated()
return the number of samples the current buffer can hold
Definition: DataSeries.C:129
virtual uint64_t get_subsize()
Stride (in bytes) between the same time sample in different chan/pol.
Definition: DataSeries.h:117
void initi()
Called by constructor to initialise variables.
Definition: DataSeries.C:25
void set_nchan(unsigned)
Set the number of channels.
Definition: DataSeries.C:100
virtual void set_memory(Memory *)
Set the memory manager.
Definition: DataSeries.C:53
void reshape()
Reshape the buffer to match the current attributes.
Definition: DataSeries.C:256
virtual unsigned char * get_udatptr(unsigned ichan=0, unsigned ipol=0)
Return pointer to the specified block of time samples.
Definition: DataSeries.C:303
Container of dimension/time-major order floating point data.
Definition: DataSeries.h:36
static int64_t memory_used
Stores the cumulative amount of memory used.
Definition: DataSeries.h:43
virtual DataSeries * clone() const =0
Cloner (calls new)
Pure virtual base class of objects that manage memory allocation and destruction.
Definition: Memory.h:23
static int instantiation_count
Counts number of DataSeries's in existence.
Definition: DataSeries.h:41
bool reshape_required()
Return true if reshape of data series required.
Definition: DataSeries.h:92
virtual unsigned char * get_data()
Returns a uchar pointer to the first piece of data.
Definition: DataSeries.C:291
unsigned get_nchan() const
Return the number of channels into which the band is divided.
Definition: Observation.h:85

Generated using doxygen 1.8.17