51 #include <boost/optional.hpp> 245 mWaitForAlteredStartTime(false),
246 mMaxMessageBlockSize(64 * 1024* 1024),
247 mSortWindowSize(
Duration::seconds(2))
257 void open(
const Path&
file, OpenMode mode);
283 void waitForAlteredStartTime();
293 void alterStartTime(
const Time& startTime);
305 template <
typename T>
306 MIRA_DEPRECATED(
"Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)",
311 if (!mIsOpen || mMode != WRITE)
312 MIRA_THROW(XIO,
"Tape is not opened in write mode");
314 value->timestamp, value.readSerialized(),
315 (compress ? -1 : 0), meta, metaDB);
329 template <
typename T>
334 if (!mIsOpen || mMode != WRITE)
335 MIRA_THROW(XIO,
"Tape is not opened in write mode");
337 value->timestamp, value.readSerialized(),
338 compressionLevel, meta, metaDB);
353 template <
typename T>
354 MIRA_DEPRECATED(
"Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)",
356 std::list<BinarySerializerCodecPtr>& codecs,
360 if (!mIsOpen || mMode != WRITE)
361 MIRA_THROW(XIO,
"Tape is not opened in write mode");
363 value->timestamp, value.readSerialized(codecs),
364 (compress ? -1 : 0), meta, metaDB);
380 template <
typename T>
382 std::list<BinarySerializerCodecPtr>& codecs,
386 if (!mIsOpen || mMode != WRITE)
387 MIRA_THROW(XIO,
"Tape is not opened in write mode");
389 value->timestamp, value.readSerialized(codecs),
390 compressionLevel, meta, metaDB);
405 template <
typename T>
406 MIRA_DEPRECATED(
"Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)",
407 std::size_t
write(
const std::string& channelID,
const Stamped<T>& value,
416 buffer, (compress ? -1 : 0), meta, metaDB);
432 template <
typename T>
442 buffer, compressionLevel, meta, metaDB);
459 MIRA_DEPRECATED(
"Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)",
460 std::size_t
write(
const std::string& channelID,
const std::string&
typeName,
467 header.
sequenceID, data, (compress ? -1 : 0), meta, metaDB);
485 std::size_t
write(
const std::string& channelID,
const std::string&
typeName,
492 header.
sequenceID, data, compressionLevel, meta, metaDB);
510 MIRA_DEPRECATED(
"Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)",
511 std::size_t
write(
const std::string& channelID,
const std::string&
typeName,
512 const Time& time,
const std::string& frameID, uint32 sequenceID,
518 data, (compress ? -1 : 0), meta, metaDB);
537 std::size_t
write(
const std::string& channelID,
const std::string&
typeName,
538 const Time& time,
const std::string& frameID, uint32 sequenceID,
549 mMaxMessageBlockSize = size;
561 mSortWindowSize = interval;
573 mFile.timezoneOffset = mFile.start.
toLocal() - mFile.start;
597 return mFile.start + mFile.timezoneOffset;
609 if (mMessageBlocks.size()==0)
611 return mFile.start + mMessageBlocks.rbegin()->second.lastMessageOffset;
626 return mFile.timezoneOffset;
650 return mMessageBlocks;
662 return mFile.version;
671 static uint32 getCurrentVersion();
686 void readMessage(
const MessageIndex& index, std::string& frameID,
694 void readMessage(
const MessageIndex& index, std::string& frameID,
701 uint64 getFileHeaderSize()
const;
711 void readFileHeader();
712 void readChannelInfo();
713 void readMessageBlocks();
714 void readMessageBlock(uint64 offset);
715 void writeFileHeader();
717 void writeHeader(HeaderType
type, uint32 size);
718 void writeChannelInfo(ChannelInfo& info);
719 void startMessageBlock(
Duration time);
720 void finishMessageBlock();
MessageBlockMap mMessageBlocks
Pairs of offset - message block.
Definition: Tape.h:732
A tape is a binary file that contains recorded/serialized data of one or multiple channels...
Definition: Tape.h:142
static const uint32 sHeaderSize
size of the header packet
Definition: Tape.h:146
Duration timezoneOffset
Offset of the timezone on the recording machine to UTC.
Definition: Tape.h:206
Definition: BinarySerializer.h:324
std::size_t write(const std::string &channelID, const std::string &typeName, const StampedHeader &header, const Buffer< uint8 > &data, int compressionLevel=0, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase())
Write the serialized data into the tape.
Definition: Tape.h:485
uint32 nrBlocks
Nr of message data blocks.
Definition: Tape.h:209
T & value()
Returns a read-write reference to the underlying data.
Definition: Stamped.h:202
Duration timeOffset
Time offset of the message relative to start time of tape.
Definition: Tape.h:182
HeaderType
The type of the header specifying the following packet.
Definition: Tape.h:162
std::vector< MessageIndex > MessageVector
Definition: Tape.h:188
boost::mutex mMutex
Definition: Tape.h:730
uint32 getVersion() const
Get the version of the tape.
Definition: Tape.h:658
Buffer< uint8 > buffer
Buffer for the block data.
Definition: Tape.h:222
PropertyHint file(const std::string &filters=std::string(), bool save=false)
Tells the property editor that the path is for a file, and that it should show a "File Open"/"File Sa...
Definition: Path.h:247
Time toLocal() const
Converts to local time zone based on the settings of the machine.
Definition: Time.h:560
MetaTypeDatabase metaDB
Database of meta information needed by this type.
Definition: Tape.h:196
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
uint64 offsetToIndexTable
Offset in bytes of the index table for the channel.
Definition: Tape.h:190
boost::filesystem::path Path
Typedef of a Path (shorter version for boost::filesystem::path)
Definition: Path.h:69
bool mIsOpen
Definition: Tape.h:724
Duration firstMessageOffset
Time offset of the first message in the channel.
Definition: Tape.h:191
bool mWaitForAlteredStartTime
Definition: Tape.h:725
Time getStartTime() const
Get the time when the recording started.
Definition: Tape.h:581
Duration mSortWindowSize
Size of the window used for sorting messages in a tape.
Definition: Tape.h:738
TypeMetaPtr meta
Type meta information.
Definition: Tape.h:195
const Tape::ChannelMap & getChannels() const
Get a list of channels in the tape.
Definition: Tape.h:634
static const uint32 sMessageBlockSize
Definition: Tape.h:148
Duration lastMessageOffset
Time offset of the last message in the block.
Definition: Tape.h:221
OpenMode
The open mode for a tape.
Definition: Tape.h:151
static Time unixEpoch()
Returns the unix epoch 1.1.1970 0:0:0.000.
Definition: Time.h:514
Time getLocalStartTime() const
Get the time when the recording started in the local timezone of the machine the recording took place...
Definition: Tape.h:593
std::string name
Name of the messages channel.
Definition: Tape.h:229
Time start
Start recording time.
Definition: Tape.h:205
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:435
std::size_t write(ChannelRead< T > value, int compressionLevel=0, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase())
Write the content of a channel into the tape.
Definition: Tape.h:330
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:81
void serialize(const T &value, bool enableTypeCheck=true)
Provides a special serialize interface for the BinarySerializer.
Definition: BinarySerializer.h:598
uint32 nrChannels
Nr of channels.
Definition: Tape.h:210
Information about a channel in a tape.
Definition: Tape.h:186
std::string filename
Name of the tape.
Definition: Tape.h:207
const Tape::MessageBlockMap & getMessageBlocks() const
Get a list of the tapes message blocks.
Definition: Tape.h:646
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:421
uint32 sequenceID
Sequence id of the message.
Definition: Tape.h:231
Duration getTZOffset() const
Get the time zone offset.
Definition: Tape.h:622
ChannelMap mChannels
Definition: Tape.h:727
uint32 size
Size of the block.
Definition: Tape.h:219
std::string type
Typename of the channel.
Definition: Tape.h:194
MIRA_BASE_EXPORT void write(const Value &value, std::ostream &ioStream, bool formatted=false, int precision=-1)
Writes a json::Value into a given stream using the JSON format.
std::map< uint64, MessageBlock > MessageBlockMap
maps a message block to an offset
Definition: Tape.h:239
std::string frameID
Frame id of the message.
Definition: Tape.h:230
std::size_t write(ChannelRead< T > value, std::list< BinarySerializerCodecPtr > &codecs, int compressionLevel=0, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase())
Write the content of a channel into the tape.
Definition: Tape.h:381
MIRA_DEPRECATED("Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)", std::size_t write(const std::string &channelID, const std::string &typeName, const StampedHeader &header, const Buffer< uint8 > &data, bool compress, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase()))
Write the serialized data into the tape.
Definition: Tape.h:459
FileInfo mFile
File informations.
Definition: Tape.h:733
uint64 offsetToFirstInfo
Offset to the first channel info packet.
Definition: Tape.h:211
#define MIRA_FRAMEWORK_EXPORT
Definition: FrameworkExports.h:61
MessageVector messages
Messages.
Definition: Tape.h:197
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
bool compressed
Is message compressed.
Definition: Tape.h:228
void setMaxMessageBlockSize(uint32 size)
Set the maximum size of the chunks.
Definition: Tape.h:547
Use this class to represent time durations.
Definition: Time.h:104
void setStartTime(Time time)
Set an alternative start time for recording.
Definition: Tape.h:570
boost::optional< MessageBlock > mCurrentMessageBlock
Definition: Tape.h:729
std::size_t write(const std::string &channelID, const Stamped< T > &value, int compressionLevel=0, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase())
Write the stamped data into the tape.
Definition: Tape.h:433
uint64 offset
Offset in bytes of the info packet in the tape.
Definition: Tape.h:189
uint64 mLastInfo
Offset to the last written info field.
Definition: Tape.h:734
boost::mutex mMessageMutex
Definition: Tape.h:731
MessageMap mMessages
Messages we have not yet written to file (in the sort window)
Definition: Tape.h:737
MIRA_DEPRECATED("Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)", std::size_t write(ChannelRead< T > value, std::list< BinarySerializerCodecPtr > &codecs, bool compress, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase()))
Write the content of a channel into the tape.
Definition: Tape.h:354
MIRA_DEPRECATED("Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)", std::size_t write(const std::string &channelID, const Stamped< T > &value, bool compress, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase()))
Write the stamped data into the tape.
Definition: Tape.h:406
const std::string & getChannelID()
Definition: ChannelReadWrite.h:190
Mix in for adding a time stamp, an optional frame id and an optional sequence id to data types like P...
Definition: Stamped.h:149
boost::shared_ptr< TypeMeta > TypeMetaPtr
Definition: MetaSerializer.h:309
OpenMode mMode
Definition: Tape.h:726
uint64 dataSize
Size of all messages in bytes.
Definition: Tape.h:198
uint64 block
Offset in bytes of the containing block in the tape.
Definition: Tape.h:180
Time getEndTime() const
Get the time of the last entry.
Definition: Tape.h:605
uint32 mMaxMessageBlockSize
Maximum size of a message block.
Definition: Tape.h:735
MIRA_DEPRECATED("Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)", std::size_t write(const std::string &channelID, const std::string &typeName, const Time &time, const std::string &frameID, uint32 sequenceID, const Buffer< uint8 > &data, bool compress, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase()))
Low level write method to write serialized binary data to the tape.
Definition: Tape.h:510
uint32 version
Tape version.
Definition: Tape.h:208
std::string getTypename() const
Definition: ChannelReadWrite.h:195
uint64 offset
Offset in bytes of the message in the containing block.
Definition: Tape.h:181
Functions for modifying file system paths.
std::multimap< Duration, Message > MessageMap
maps a message to an time offset
Definition: Tape.h:241
Struct for a message block in a tape.
Definition: Tape.h:215
Buffer< uint8 > data
Buffer for the message data.
Definition: Tape.h:232
void setSortWindowSize(const Duration &interval)
Messages get sorted before they are written to a tape to guarantee a correct temporal order...
Definition: Tape.h:559
Duration lastMessageOffset
Time offset of the last message in the channel.
Definition: Tape.h:192
uint64 offset
Offset in bytes of the block in the tape.
Definition: Tape.h:217
std::map< std::string, ChannelInfo > ChannelMap
maps channel information to a channel names
Definition: Tape.h:237
std::set< std::string > mWrittenChannels
Definition: Tape.h:728
std::fstream file
The file stream.
Definition: Tape.h:204
Duration firstMessageOffset
Time offset of the first message in the block.
Definition: Tape.h:220
Index entry for a message in the tape.
Definition: Tape.h:178
uint32 uncompressedSize
Uncompressed size of the message.
Definition: Tape.h:233
Information about a tape file.
Definition: Tape.h:202
MIRA_DEPRECATED("Please use int compressionLevel(=0/-1) instead of bool compress(=false/true)", std::size_t write(ChannelRead< T > value, bool compress, TypeMetaPtr meta=TypeMetaPtr(), const MetaTypeDatabase &metaDB=MetaTypeDatabase()))
Write the content of a channel into the tape.
Definition: Tape.h:306
The framework that holds all manager classes and provides startup and shutdown of all framework relat...
Struct for message data in a tape.
Definition: Tape.h:226
Typename typeName(bool cvqualify=true)
Returns a compiler and platform independent typename of T.
Definition: Typename.h:103
std::string name
Name of the channel.
Definition: Tape.h:193
Tape()
Definition: Tape.h:243
uint32 nrMessages
Nr of contained messages.
Definition: Tape.h:218