rogue
Loading...
Searching...
No Matches
StreamReader.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_UTILITIES_FILEIO_STREAM_READER_H__
18#define __ROGUE_UTILITIES_FILEIO_STREAM_READER_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <condition_variable>
24#include <map>
25#include <memory>
26#include <mutex>
27#include <string>
28#include <thread>
29
31
32namespace rogue {
33namespace utilities {
34namespace fileio {
35
52 // Base file name for indexed-file mode.
53 std::string baseName_;
54
55 // Active file descriptor.
56 int32_t fd_;
57
58 // Current file index in indexed-file mode.
59 uint32_t fdIdx_;
60
61 // True while read thread is actively processing file data.
62 bool active_;
63
64 // Read worker thread.
65 std::thread* readThread_;
66 bool threadEn_;
67
68 // Worker thread entry point.
69 void runThread();
70
71 // Open next indexed file in sequence.
72 bool nextFile();
73
74 // Internal close helper.
75 void intClose();
76
77 // Condition signaled when activity state changes.
78 std::condition_variable cond_;
79
80 // Mutex for file/thread/activity state.
81 std::mutex mtx_;
82
83 public:
94 static std::shared_ptr<rogue::utilities::fileio::StreamReader> create();
95
97 static void setup_python();
98
106 StreamReader();
107
110
116 void open(std::string file);
117
121 void close();
122
128 bool isOpen();
129
133 void closeWait();
134
140 bool isActive();
141};
142
143// Convenience
144typedef std::shared_ptr<rogue::utilities::fileio::StreamReader> StreamReaderPtr;
145} // namespace fileio
146} // namespace utilities
147} // namespace rogue
148#endif
Stream master endpoint.
Definition Master.h:65
Reads Rogue stream data files and emits frames on stream master interface.
static std::shared_ptr< rogue::utilities::fileio::StreamReader > create()
Creates a stream reader instance.
~StreamReader()
Destroys stream reader and closes active file/thread.
void close()
Stops read thread and closes active file immediately.
void open(std::string file)
Opens a file and starts background read processing.
bool isOpen()
Returns whether a file descriptor is currently open.
static void setup_python()
Registers Python bindings for this class.
StreamReader()
Constructs a stream reader instance.
void closeWait()
Waits for read activity to complete, then closes file/thread.
bool isActive()
Returns read activity state.
std::shared_ptr< rogue::utilities::fileio::StreamReader > StreamReaderPtr