47 #ifndef _MIRA_TAPEVISITOR_H_ 48 #define _MIRA_TAPEVISITOR_H_ 124 typedef std::map<std::string, const Tape::ChannelInfo*>
ChannelMap;
168 MIRA_THROW(XIO,
"Cannot instantiate message from the end iterator");
202 template <
typename T>
207 if(
mMessage->info->type!=typeName<T>()) {
208 MIRA_THROW(XIO,
"Cannot read a '"<<typeName<T>()<<
209 "' from Tape-Iterator message which has type '"<<
mMessage->info->type<<
"'");
270 return mMessage->tape->getTZOffset();
281 MIRA_THROW(XIO,
"Cannot access message at the end iterator");
308 bool ignoreStartTime =
false);
320 void visit(
Tape* iTape,
const std::vector<std::string>& channels,
323 bool ignoreStartTime =
false);
376 return mMessages.rbegin()->tape->getTZOffset();
409 MessageMap::iterator it =
mMessages.begin();
415 if ( diffNow < diffNext )
447 MessageMap::iterator i = start.
mMessage;
449 if (i->info->name == channel)
471 MessageMap::iterator i = start.
mMessage;
473 if (std::find(channels.begin(), channels.end(), i->info->name) != channels.end())
494 void reIndex(
Tape* tape,
bool ignoreStartTime =
false);
iterator & operator++()
Definition: TapeVisitor.h:150
A tape is a binary file that contains recorded/serialized data of one or multiple channels...
Definition: Tape.h:142
iterator & operator--()
Definition: TapeVisitor.h:156
void reIndex(Tape *tape, bool ignoreStartTime=false)
T & value()
Returns a read-write reference to the underlying data.
Definition: Stamped.h:202
const MessageInstance * operator->() const
Instantiates the message by loading it from the underlying tape file.
Definition: TapeVisitor.h:190
ChannelMap mChannels
Definition: TapeVisitor.h:498
Duration getTimeOffset() const
Get the offset of the recording time for this message.
Definition: TapeVisitor.h:247
iterator at(Duration timeOffset)
Iterator to the message at the given offset since start of tape.
Definition: TapeVisitor.h:403
A Tape is a representation of recorded channel data in a binary file.
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
const ChannelMap & getChannels() const
Get a list of the visited channels.
Definition: TapeVisitor.h:483
std::map< std::string, const Tape::ChannelInfo * > ChannelMap
Maps channel info to channel names.
Definition: TapeVisitor.h:124
iterator end()
Iterator to the end of visited messages.
Definition: TapeVisitor.h:425
Duration timeOffset
time offset of the message relative to start of recording
Definition: TapeVisitor.h:107
Time getStartTime() const
Get the common start time of the visit for all tapes.
Definition: TapeVisitor.h:329
MessageInstance mInstance
Definition: TapeVisitor.h:284
Duration getLastMessageTimeOffset() const
Get the time offset of the last visited message.
Definition: TapeVisitor.h:362
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
Information about a channel in a tape.
Definition: Tape.h:186
Iterator to iterate over all messages in all tapes visited by the visitor.
Definition: TapeVisitor.h:133
Buffer< uint8 > data
serialized message data
Definition: TapeVisitor.h:89
Duration getTZOffset() const
Get the time zone offset of the tape containing this message.
Definition: TapeVisitor.h:267
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
iterator & operator=(const iterator &other)
Definition: TapeVisitor.h:143
Duration abs(const Duration &duration)
Get the absolute duration from a duration.
Definition: Time.h:401
uint32 getMessageCount() const
Get the number of messages to visit.
Definition: TapeVisitor.h:384
TapeVisitor * mVisitor
Definition: TapeVisitor.h:285
MessageMap mMessages
Definition: TapeVisitor.h:497
const Tape::ChannelInfo * info
pointer to the info object of the channel
Definition: TapeVisitor.h:110
const Tape::ChannelInfo * getChannelInfo() const
Get the information object about the channel this message belongs to.
Definition: TapeVisitor.h:259
MessageMap::iterator mMessage
Definition: TapeVisitor.h:286
bool operator<(const MessageInfo &other) const
Definition: TapeVisitor.h:115
void read(Stamped< T > &oData)
Instantiates the message by loading it from the underlying tape file and deserializes its content int...
Definition: TapeVisitor.h:203
Use this class to represent time durations.
Definition: Time.h:106
boost::optional< Time > mStart
Definition: TapeVisitor.h:496
void setStartTime(const Time &start)
Set the common start time of the visit for all tapes.
Definition: TapeVisitor.h:339
uint64 offset
offset of the message in the tape
Definition: TapeVisitor.h:80
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
iterator(TapeVisitor *visitor, MessageMap::iterator message)
Definition: TapeVisitor.h:139
iterator findNextOf(const iterator &start, const std::string &channel)
Returns the iterator to the next message from given channel, starting at the given start iterator...
Definition: TapeVisitor.h:445
static Duration infinity()
Returns a special duration time representing positive infinity.
Definition: Time.h:242
Duration getFirstMessageTimeOffset() const
Get the time offset of the first visited message.
Definition: TapeVisitor.h:351
Instance of a message from a tape.
Definition: TapeVisitor.h:71
void addChannel(Tape *tape, const Tape::ChannelInfo *channel, Duration first=Duration::nanoseconds(0), Duration last=Duration::infinity())
iterator begin()
Iterator to the first visited message in a tape.
Definition: TapeVisitor.h:393
Visitor class to inspect tapes by channels and/or time interval.
Definition: TapeVisitor.h:66
static Duration negativeInfinity()
Returns a special duration time representing negative infinity.
Definition: Time.h:235
std::vector< MessageInfo > MessageMap
Vector of message informations.
Definition: TapeVisitor.h:122
const Tape::MessageIndex * index
pointer to the index object of the message
Definition: TapeVisitor.h:113
iterator findNextOfAnyOf(Duration startOffset, const std::vector< std::string > &channels)
Returns the iterator to the next message from any of the given channels with a time offset of at leas...
Definition: TapeVisitor.h:459
Info about a message entry in a tape.
Definition: TapeVisitor.h:96
iterator findNextOfAnyOf(const iterator &start, const std::vector< std::string > &channels)
Returns the iterator to the next message from any of the given channels, starting at the given start ...
Definition: TapeVisitor.h:469
void deserialize(T &value, bool enableTypeCheck=true, bool recursive=false)
Provides a special deserialize interface for the BinaryDeserializer.
Definition: BinarySerializer.h:1329
Tape * tape
pointer to tape the message is stored in
Definition: TapeVisitor.h:77
void visit(Tape *iTape, Duration first=Duration::negativeInfinity(), Duration last=Duration::infinity(), bool ignoreStartTime=false)
Visit a tape by specifying an interval of the relative time of the first and the last message...
static Time invalid()
Returns an invalid time.
Definition: Time.h:497
MessageInstance()
Definition: TapeVisitor.h:73
friend class iterator
Definition: TapeVisitor.h:127
bool compressed
specifies whether the data was compressed within the tape or not
Definition: TapeVisitor.h:92
MessageInfo()
Definition: TapeVisitor.h:98
iterator findNextOf(Duration startOffset, const std::string &channel)
Returns the iterator to the next message from given channel with a time offset of at least startOffse...
Definition: TapeVisitor.h:435
const MessageInstance & operator*() const
Instantiates the message by loading it from the underlying tape file.
Definition: TapeVisitor.h:165
tick_type nanoseconds() const
Returns normalized number of nanoseconds (0..999)
Definition: Time.h:295
Index entry for a message in the tape.
Definition: Tape.h:178
void validate() const
Definition: TapeVisitor.h:278
std::string frameID
frame id of the channel
Definition: TapeVisitor.h:83
Duration getLastMessageTZOffset() const
Get the time zone offset of the last visited message.
Definition: TapeVisitor.h:373
bool operator!=(const iterator &other) const
Definition: TapeVisitor.h:237
uint32 sequenceID
sequence id
Definition: TapeVisitor.h:86
bool operator==(const iterator &other) const
Definition: TapeVisitor.h:232
iterator()
Definition: TapeVisitor.h:136
void readJSON(Stamped< JSONValue > &oData)
Instantiates the message by loading it from the underlying tape file and deserializes its content as ...
Tape * tape
pointer to tape the message is stored in
Definition: TapeVisitor.h:104