-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadTimestampFile.cpp
executable file
·85 lines (74 loc) · 3.13 KB
/
ReadTimestampFile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @file ReadTimestampFile.cpp
* @ingroup DataManagement
* @author Dominique Vaufreydaz, Grenoble Alpes University, Inria
* @copyright All right reserved.
*/
#include "ReadTimestampFile.h"
using namespace std;
using namespace MobileRGBD;
/** @brief Constructor. Create a ReadTimestampFile object using specific file.
*
* @param FileName [in] Name of the file to open (even with '/' separator under Windows as Windows handles it also as a folder/file separator).
* @param SizeOfLineBuffer [in] Size of buffer to read each line of the file (default=ReadTimestamp::DefaultLineBufferSize).
*/
ReadTimestampFile::ReadTimestampFile( const string& FileName, size_t SizeOfLineBuffer /* = ReadTimestamp::DefaultLineBufferSize */ ) : ReadTimestamp( FileName, SizeOfLineBuffer )
{
DataBuffer = nullptr;
}
/** @brief Search for a specific timestamp and set the DataBuffer pointer on the beginning of the data.
* Could be overloaded as a virtual function.
*
* @param RequestedTimestamp [in] Requested timestamp.
* @param ValidityTimeInMs [in] Threshold for searching for a timestamp (default=ReadTimestamp::DefaultValidityTimeInMs).
* @return True if the timestamp has been found.
*/
bool ReadTimestampFile::GetDataForTimestamp(const TimeB &RequestedTimestamp, unsigned short int ValidityTimeInMs /* = (unsigned short int)ReadTimestamp::DefaultValidityTimeInMs */ )
{
if ( SearchDataForTimestamp(RequestedTimestamp, ValidityTimeInMs) == true )
{
DataBuffer = &LineBuffer[EndOfTimestampPosition];
return true;
}
return false;
}
/** @brief Search for the timestamp and set the DataBuffer pointer on the beginning of the data.
* Could be overloaded as a virtual function.
*
* @param ValidityTimeInMs [in] Threshold for searching for a timestamp (default=ReadTimestamp::DefaultValidityTimeInMs).
* @return True if the timestamp has been found.
*/
bool ReadTimestampFile::GetCurrentData(unsigned short int ValidityTimeInMs /* = (unsigned short int)ReadTimestamp::DefaultValidityTimeInMs */ )
{
// Do we have an internal timestamp ?
if ( CurrentTimestampIsInitialized == false )
{
// no timestamp, no data
return false;
}
// Call function with internal timestamp
return GetDataForTimestamp( CurrentTimestamp, ValidityTimeInMs );
}
/** @brief Search for the timestamp and if found, and process it by calling ProcessElement.
*
* @param RequestedTimestamp [in] Requested timestamp.
* @param UserData [in] Pointer on a UserData pass to the ProcessElement function (default=nullptr).
* @return True if everything went fine.
*/
bool ReadTimestampFile::Process( const TimeB &RequestTimestamp, void * UserData /* = nullptr */ )
{
if ( GetDataForTimestamp( RequestTimestamp ) == true )
{
return ProcessElement( RequestTimestamp, UserData );
}
return false;
}
/** @brief Process the current element by calling ProcessElement on it (usefull when we parse at the same time we read timestamp).
*
* @param UserData [in] Pointer on a UserData pass to the ProcessElement function (default=nullptr).
* @return True if everything went fine.
*/
bool ReadTimestampFile::ProcessCurrent( void * UserData /* = nullptr */ )
{
return Process( CurrentTimestamp, UserData );
}