file.hpp
Go to the documentation of this file.
1 //
2 // File.hpp
3 //
4 // File reader.
5 //
6 // Sick AG
7 //
8 // HISTORY
9 //
10 // 1.0.0 2013-02-12, VWi
11 // Initial version.
12 //
13 
14 
15 
16 #ifndef FILE_HPP
17 #define FILE_HPP
18 
19 #include "../BasicDatatypes.hpp"
20 #include "../tools/Mutex.hpp"
21 #include "../tools/SickThread.hpp"
22 #include <list>
23 // Ausgabestream und Kompression
24 #include <iostream>
25 #include <fstream>
26 
27 
28 //
29 //
30 //
31 class File
32 {
33 public:
34  File();
35  ~File();
36 
37  std::string getFilename();
38  void close();
39  bool open(std::string inputFileName, bool beVerbose = false);
40 
41  // Read callback (for being called when data is available)
42  typedef void (*ReadFunction)(void* obj, UINT8* inputBuffer, UINT32& numBytes); // ReadFunction
43  void setReadCallbackFunction(ReadFunction readFunction, void* obj);
44 
45  // Information if the connection is disconnected.
46  typedef void (*DisconnectFunction)(void* obj); // Called on disconnect
47  void setDisconnectCallbackFunction(DisconnectFunction discFunction, void* obj);
48 
49 
50 private:
52 
53  // Thread stuff
54  void startReadThread();
55  void readThreadFunction(bool& endThread, UINT16& waitTimeMs);
58 
59 
60  // File
61  std::string m_inputFileName;
62  std::ifstream m_inputFileStream; // input file stream
64 
65  // Callbacks
66  ReadFunction m_readFunction; // Receive callback
67  void* m_readFunctionObjPtr; // Object of the Receive callback
69  void* m_disconnectFunctionObjPtr; // Object of the Disconect callback
70 };
71 
72 #endif // FILE_HPP
INT32 readInputData()
Definition: file.cpp:145
std::string getFilename()
void * m_readFunctionObjPtr
Definition: file.hpp:67
std::string m_inputFileName
Definition: file.hpp:61
DisconnectFunction m_disconnectFunction
Definition: file.hpp:68
uint16_t UINT16
void setReadCallbackFunction(ReadFunction readFunction, void *obj)
Definition: file.cpp:78
SickThread< File,&File::readThreadFunction > m_readThread
Definition: file.hpp:56
uint32_t UINT32
Definition: Mutex.hpp:16
void close()
Definition: file.cpp:66
Mutex m_inputFileMutex
Definition: file.hpp:63
File()
Definition: file.cpp:14
void setDisconnectCallbackFunction(DisconnectFunction discFunction, void *obj)
Definition: file.cpp:205
ReadFunction m_readFunction
Definition: file.hpp:66
int32_t INT32
void(* DisconnectFunction)(void *obj)
Definition: file.hpp:46
void startReadThread()
Definition: file.cpp:90
void(* ReadFunction)(void *obj, UINT8 *inputBuffer, UINT32 &numBytes)
Definition: file.hpp:42
std::ifstream m_inputFileStream
Definition: file.hpp:62
~File()
Definition: file.cpp:30
void readThreadFunction(bool &endThread, UINT16 &waitTimeMs)
Definition: file.cpp:103
bool m_beVerbose
Definition: file.hpp:51
Definition: file.hpp:31
bool open(std::string inputFileName, bool beVerbose=false)
Definition: file.cpp:39
void * m_disconnectFunctionObjPtr
Definition: file.hpp:69
uint8_t UINT8


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Mon Oct 26 2020 03:27:30