SerialFiles.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 - 2023 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Kernel/Classes/dsp/SerialFiles.h
10 
11 #ifndef __dsp_Kernel_Classes_SerialFiles_h
12 #define __dsp_Kernel_Classes_SerialFiles_h
13 
14 #include "dsp/MultiFile.h"
15 
16 namespace dsp {
17 
19  class SerialFiles : public MultiFile {
20 
21  public:
22 
24  SerialFiles (const char* name = "SerialFiles");
25 
27  virtual ~SerialFiles ();
28 
30  const Input* get_origin () const { return get_loader(); }
31 
33  void force_contiguity ();
34 
36  virtual void have_open (const std::vector<std::string>& filenames);
37 
39  File* get_loader ();
40  const File* get_loader () const;
41 
43  std::vector< Reference::To<File> >& get_files () {return files;}
44 
46  bool has_loader ();
47 
50  virtual void erase_files();
51 
54  virtual void erase_files (const std::vector<std::string>& erase_filenames);
55 
57  std::string get_current_filename() const { return current_filename; }
58 
60  unsigned get_index() const { return current_index; }
61 
63  uint64_t get_next_sample();
64 
66  void add_extensions (Extensions *ext);
67 
68  protected:
69 
71  virtual int64_t load_bytes (unsigned char* buffer, uint64_t bytes);
72 
74  virtual int64_t seek_bytes (uint64_t bytes);
75 
78 
80  std::string current_filename;
81 
83  void init();
84 
86  void ensure_contiguity ();
87 
88  private:
89 
91  bool test_contiguity;
92 
94  unsigned current_index;
95 
97  void after_open (File*);
98 
100  void setup ();
101 
103  void set_loader (unsigned index);
104 
105  };
106 
107 }
108 
109 #endif // !defined(__dsp_Kernel_Classes_SerialFiles_h)
110 
virtual int64_t load_bytes(unsigned char *buffer, uint64_t bytes)
Load bytes from file.
Definition: SerialFiles.C:164
Reference::To< File > loader
Currently open File instance.
Definition: SerialFiles.h:87
void set_output(BitSeries *data)
Set the bits series into which data will be loaded.
Definition: Seekable.C:318
SerialFiles(const char *name="SerialFiles")
Constructor.
Definition: SerialFiles.C:20
unsigned resolution
Time sample resolution of the data source.
Definition: Input.h:178
virtual bool contiguous(const File *that) const
Return true this this is contiguous with that.
Definition: File.C:340
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
virtual void reopen()
Reopen the file.
Definition: File.C:162
virtual Observation * get_info()
Get the information about the data source.
Definition: Input.h:113
void add_extensions(Extensions *ext)
Add any relevant extensions (calls loader's add_extensions())
Definition: SerialFiles.C:297
void init()
initialize variables
std::string current_filename
Name of the currently opened file.
Definition: SerialFiles.h:90
virtual void add_extensions(Extensions *)
Add any extensions.
Definition: Operation.C:86
void ensure_contiguity()
Ensure that files are contiguous.
Definition: SerialFiles.C:132
Loads BitSeries data from file.
Definition: File.h:38
virtual void close()
Close the file.
Definition: File.C:145
std::string name
Operation name.
Definition: Operation.h:153
virtual void erase_files()
Erase the entire list of loadable files Resets the file pointers.
Definition: SerialFiles.C:95
virtual void have_open(const std::vector< std::string > &filenames)
Makes sure only these filenames are open.
Definition: SerialFiles.C:79
virtual int64_t seek_bytes(uint64_t bytes)
Set the file pointer to the absolute number of sampled data bytes.
Definition: File.C:283
virtual ~SerialFiles()
Destructor.
Definition: SerialFiles.C:26
File * get_loader()
Retrieve a pointer to the loader File instance.
Definition: SerialFiles.C:308
std::vector< Reference::To< File > > & get_files()
Access to current file objects.
Definition: SerialFiles.h:53
void force_contiguity()
Treat the files as contiguous.
Definition: SerialFiles.C:30
virtual int64_t load_bytes(unsigned char *buffer, uint64_t nbytes)
Load nbyte bytes of sampled data from the device into buffer.
Definition: File.C:190
std::vector< std::string > filenames
Name of the currently opened file.
Definition: MultiFile.h:63
uint64_t get_next_sample()
Inquire the next sample to load for the current file.
virtual int64_t seek_bytes(uint64_t bytes)
Adjust the file pointer.
Definition: SerialFiles.C:220
bool has_loader()
Return true if the loader File instance is set.
Definition: SerialFiles.C:303
Loads serial BitSeries data from multiple files.
Definition: SerialFiles.h:24
std::string get_filename() const
Return the name of the file from which this instance was created.
Definition: File.h:86
const Input * get_origin() const
The origin is the current loader.
Definition: SerialFiles.h:40
Base class of objects that load data from multiple files.
Definition: MultiFile.h:24
unsigned get_index() const
Find out the index of current file is.
Definition: SerialFiles.h:70
std::string get_current_filename() const
Find out which file is currently open;.
Definition: SerialFiles.h:67
MJD get_start_time() const
Return the start time of the leading edge of the first time sample.
Definition: Observation.h:152
std::vector< Reference::To< File > > files
List of files.
Definition: MultiFile.h:60

Generated using doxygen 1.8.17