28 #include <icl_sourcesink/SimpleURI.h> 29 #include <icl_sourcesink/Position.h> 37 const std::string& name)
39 icl_sourcesink::PositionResolverBase::
Ptr(
40 new icl_sourcesink::KeyframePositionResolver(
41 icl_sourcesink::FileResolutionHelper::
Ptr(
46 boost::dynamic_pointer_cast<icl_sourcesink::KeyframePositionResolver>(
50 m_resolver_x->resolutionHelper()->clone())),
61 "Failed to open URI '" << uri() <<
"'." <<
endl);
68 "Checking for resolver index cache." <<
endl);
69 std::string resolver_index_filename =
70 icl_sourcesink::SimpleURI(uri()).path()
71 + icl_sourcesink::PositionResolverBase::INDEX_FILE_SUFFIX;
73 "Checking for resolver index cache at '" << resolver_index_filename <<
"'..." <<
endl);
74 if (m_resolver->load(resolver_index_filename))
77 "Successfully loaded resolver index cache from '" << resolver_index_filename <<
"'." <<
endl);
83 "No resolver index cache found, building index." <<
endl);
85 std::size_t count = 0;
90 m_resolver_x->addEntry(pos.timestamp, pos.dsin, filepos);
91 if (++count % 1000 == 0)
93 std::cerr <<
"Building resolver index: " 94 << int(
double(filepos)*100.0/
double(filesize)) <<
"% \r" 98 std::cerr <<
"Resolver index completed. " << std::endl;
102 "Storing resolver index cache at '" << resolver_index_filename <<
"'." <<
endl);
103 if (!m_resolver->save(resolver_index_filename))
106 "Failed to store resolver index cache at '" << resolver_index_filename <<
"'." <<
endl);
111 m_resolver->makeFragmentable();
112 m_is_good = seek(icl_sourcesink::Index(0));
116 "Resolver index complete, total number of elements: " << m_resolver->registerSize() <<
endl);
122 icl_sourcesink::Position pos(
m_resolver_x->mapIndex<icl_sourcesink::Index>(internal_index));
123 boost::optional<uint64_t> seek_pos =
m_resolver_x->resolveExtra(pos, icl_sourcesink::RT_EXACT);
129 "Failed to seek to position " << seek_pos
130 <<
" even though the resolver had a valid entry for that position!" <<
endl);
142 "Failed to resolve internal index " << internal_index.value
143 <<
", probably end of file" <<
endl);
151 if (m_resolver->advance())
156 "Resolution helper failed to advance. This should not happen!" <<
endl);
169 "Failed to advance, probably end of file" <<
endl);
#define LOGGING_INFO_C(streamname, classname, arg)
virtual bool advance()
Implementation of DataSourceBase::advance().
icl_sourcesink::DataSource< tCanMessage > HardwareCanSource
Base type for all sources providing tCanMessage data.
HardwareCanSourceCanfile(const std::string &uri, const std::string &name="HardwareCanSourceCanfile")
std::size_t m_sequence_number
Ever-increasing sequence number.
#define LOGGING_WARNING_C(streamname, classname, arg)
unsigned __int64 uint64_t
#define LOGGING_DEBUG_C(streamname, classname, arg)
ThreadStream & endl(ThreadStream &stream)
CanMessageStamped::Ptr m_buffer
Buffers the current data element.
icl_sourcesink::KeyframePositionResolver::Ptr m_resolver_x
CanFileResolutionHelper::Ptr m_resolution_helper
Our own resolution helper.
virtual bool seekImpl(const icl_sourcesink::InternalIndex internal_index)
Implementation of DataSourceBase::seekImpl().
boost::shared_ptr< HardwareCanSourceCanfile > Ptr
Shared pointer shorthand.
#define LOGGING_ERROR_C(streamname, classname, arg)