STIR  6.2.0
InputStreamWithRecordsFromUPENNbin.h
Go to the documentation of this file.
1 //
2 //
11 /*
12  Copyright (C) 2020-2022 University of Pennsylvania
13  This file is part of STIR.
14 
15  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
16 
17  See STIR/LICENSE.txt for details
18 */
19 #ifndef __stir_IO_InputStreamWithRecordsFromUPENNbin_H__
20 #define __stir_IO_InputStreamWithRecordsFromUPENNbin_H__
21 
24 
25 #include "liblist.h"
26 #include "libmhdr.h"
27 
28 START_NAMESPACE_STIR
29 
36 class InputStreamWithRecordsFromUPENNbin : public RegisteredParsingObject<InputStreamWithRecordsFromUPENNbin,
37  InputStreamWithRecordsFromUPENN,
38  InputStreamWithRecordsFromUPENN>
39 {
40 private:
43  InputStreamWithRecordsFromUPENN>
44  base_type;
45 
46 public:
47  static const char* const registered_name;
48 
49  InputStreamWithRecordsFromUPENNbin();
50 
51  virtual ~InputStreamWithRecordsFromUPENNbin()
52  {
53  delete in;
54  delete eventCodec;
55  }
56 
57  virtual inline Succeeded create_output_file(const std::string ofilename);
59  virtual Succeeded set_up();
61  virtual std::string method_info() const;
62 
63  virtual Succeeded get_next_record(CListRecordPENN& record);
65  virtual Succeeded reset();
66 
67  virtual SavedPosition save_get_position();
68 
69  virtual Succeeded set_get_position(const SavedPosition&);
70 
71  inline std::streambuf& get_stream()
72  { /*return &this->inputList;*/
73  }
74 
75  const PET::ListFileHeader* get_file_header() const;
76 
77  virtual void set_current_record();
78 
79  virtual void set_new_record(const bool& d,
80  const short int& _dt,
81  const unsigned short int& _xa,
82  const unsigned short int& _xb,
83  const unsigned short int& _za,
84  const unsigned short int& _zb,
85  const unsigned short int& _ea,
86  const unsigned short int& _eb);
87 
88 protected:
89  virtual void set_defaults();
90  virtual void initialise_keymap();
91  virtual bool post_processing();
92 
93 private:
94  void set_record(const uint8_t* e);
95 
96  list::EventFormat eventFormat;
97  list::EventCodec* eventCodec = nullptr;
98  list::InputBuffer* in = nullptr;
99  PET::ListFileHeader listHeader;
100  std::filebuf inputListFile;
101  std::streambuf* inputList; // = std::cin.rdbuf();
102  // shared_ptr<list::EventFormat> eventFormat;
103  int pos;
104  list::EventCodec* olistCodec = nullptr;
105  std::filebuf outputListFile;
106  std::streambuf* outputList;
107 
108  list::OutputBuffer* out = nullptr;
109 
110  std::streampos starting_stream_position;
111 
112  std::vector<std::streampos> saved_get_positions;
113 
114  // uint8_t current_record[8];
115  const uint8_t* current_record;
116 
117  int eventSize = 0;
118 
119  bool has_output = false;
120 };
121 
122 END_NAMESPACE_STIR
123 
125 
126 #endif
Base class for reading listmode files from the PENNPet Explorer scanner.
Definition: InputStreamWithRecordsFromUPENN.h:40
Class for reading binary listmode files from the PENNPet Explorer scanner.
Definition: InputStreamWithRecordsFromUPENNbin.h:36
Implementation of class stir::InputStreamWithRecordsFromUPENNbin.
Declaration of class stir::InputStreamWithRecordsFromUPENN.
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition: Succeeded.h:43
Declaration of class stir::RegisteredParsingObject.