libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::DataFile< N > Class Template Reference

Access to standard format data files. More...

#include <DataFile.h>

Inheritance diagram for osmscout::DataFile< N >:

Public Types

using ValueCache = Cache<FileOffset, std::shared_ptr<N> >
using ValueCacheEntry = typename Cache<FileOffset, ValueType>::CacheEntry
using ValueCacheRef = typename Cache<FileOffset, ValueType>::CacheRef
using ValueType = std::shared_ptr<N>

Public Member Functions

virtual bool Close ()
 Close the index.
 DataFile (const DataFile &)=delete
 DataFile (const std::string &datafile, size_t cacheSize)
 DataFile (DataFile &&)=delete
void FlushCache ()
bool GetByBlockSpan (const DataBlockSpan &span, std::vector< ValueType > &data) const
 Read data values from the given DataBlockSpan.
template<typename IteratorIn>
bool GetByBlockSpans (IteratorIn begin, IteratorIn end, std::vector< ValueType > &data) const
 Read data values from the given DataBlockSpans.
bool GetByOffset (FileOffset offset, ValueType &entry) const
 Read one data value from the given file offset.
template<typename IteratorIn>
bool GetByOffset (IteratorIn begin, IteratorIn end, size_t size, const GeoBox &boundingBox, std::vector< ValueType > &data) const
 Read data values from the given file offsets.
template<typename IteratorIn>
bool GetByOffset (IteratorIn begin, IteratorIn end, size_t size, std::unordered_map< FileOffset, ValueType > &dataMap) const
 Read data values from the given file offsets.
template<typename IteratorIn>
bool GetByOffset (IteratorIn begin, IteratorIn end, size_t size, std::vector< ValueType > &data) const
 Reads data for the given file offsets.
std::string GetFilename () const
virtual bool IsOpen () const
 Return true, if index is currently opened.
bool Open (const TypeConfigRef &typeConfig, const std::string &path, bool memoryMappedData)
 Open the index file.
DataFile & operator= (const DataFile &)=delete
DataFile & operator= (DataFile &&)=delete
virtual ~DataFile ()

Protected Attributes

TypeConfigRef typeConfig

Detailed Description

template<class N>
class osmscout::DataFile< N >

Access to standard format data files.

Allows to load data objects by offset using various standard library data structures.

Member Typedef Documentation

◆ ValueCache

template<class N>
using osmscout::DataFile< N >::ValueCache = Cache<FileOffset, std::shared_ptr<N> >

◆ ValueCacheEntry

template<class N>
using osmscout::DataFile< N >::ValueCacheEntry = typename Cache<FileOffset, ValueType>::CacheEntry

◆ ValueCacheRef

template<class N>
using osmscout::DataFile< N >::ValueCacheRef = typename Cache<FileOffset, ValueType>::CacheRef

◆ ValueType

template<class N>
using osmscout::DataFile< N >::ValueType = std::shared_ptr<N>

Constructor & Destructor Documentation

◆ DataFile() [1/3]

template<class N>
osmscout::DataFile< N >::DataFile ( const std::string & datafile,
size_t cacheSize )

◆ DataFile() [2/3]

template<class N>
osmscout::DataFile< N >::DataFile ( const DataFile< N > & )
delete

References DataFile().

◆ DataFile() [3/3]

template<class N>
osmscout::DataFile< N >::DataFile ( DataFile< N > && )
delete

References DataFile().

◆ ~DataFile()

template<class N>
osmscout::DataFile< N >::~DataFile ( )
virtual

References Close(), and IsOpen().

Member Function Documentation

◆ Close()

template<class N>
bool osmscout::DataFile< N >::Close ( )
virtual

◆ FlushCache()

template<class N>
void osmscout::DataFile< N >::FlushCache ( )

◆ GetByBlockSpan()

template<class N>
bool osmscout::DataFile< N >::GetByBlockSpan ( const DataBlockSpan & span,
std::vector< ValueType > & data ) const

Read data values from the given DataBlockSpan.

Method is thread-safe.

References osmscout::IOException::GetDescription(), and osmscout::log.

◆ GetByBlockSpans()

template<class N>
template<typename IteratorIn>
bool osmscout::DataFile< N >::GetByBlockSpans ( IteratorIn begin,
IteratorIn end,
std::vector< ValueType > & data ) const

Read data values from the given DataBlockSpans.

Method is thread-safe.

References osmscout::IOException::GetDescription(), and osmscout::log.

◆ GetByOffset() [1/4]

template<class N>
bool osmscout::DataFile< N >::GetByOffset ( FileOffset offset,
ValueType & entry ) const

◆ GetByOffset() [2/4]

template<class N>
template<typename IteratorIn>
bool osmscout::DataFile< N >::GetByOffset ( IteratorIn begin,
IteratorIn end,
size_t size,
const GeoBox & boundingBox,
std::vector< ValueType > & data ) const

Read data values from the given file offsets.

Method is thread-safe.

References osmscout::log.

◆ GetByOffset() [3/4]

template<class N>
template<typename IteratorIn>
bool osmscout::DataFile< N >::GetByOffset ( IteratorIn begin,
IteratorIn end,
size_t size,
std::unordered_map< FileOffset, ValueType > & dataMap ) const

Read data values from the given file offsets.

Method is thread-safe.

References GetByOffset().

◆ GetByOffset() [4/4]

template<class N>
template<typename IteratorIn>
bool osmscout::DataFile< N >::GetByOffset ( IteratorIn begin,
IteratorIn end,
size_t size,
std::vector< ValueType > & data ) const

Reads data for the given file offsets.

File offsets are passed by iterator over some container. the size parameter hints as the number of entries returned by the iterators and is used to preallocate enough room in the result vector.

Template Parameters
NObject type managed by the data file
IteratorInIterator over a colection
Parameters
beginStart iterator for the file offset
endEnd iterator for the file offset
sizeNumber of entries returnd by the begin, end itertaor pair. USed for preallocating enough space in result vector.
datavector containing data. Data is appended.
Returns
false if there was an error, else true

Method is thread-safe.

References osmscout::log.

◆ GetFilename()

template<class N>
std::string osmscout::DataFile< N >::GetFilename ( ) const
inline

◆ IsOpen()

template<class N>
bool osmscout::DataFile< N >::IsOpen ( ) const
virtual

Return true, if index is currently opened.

Method is NOT thread-safe.

Reimplemented in osmscout::IndexedDataFile< I, N >, and osmscout::IndexedDataFile< Id, osmscout::Intersection >.

Referenced by osmscout::IndexedDataFile< I, N >::IsOpen(), and ~DataFile().

◆ Open()

template<class N>
bool osmscout::DataFile< N >::Open ( const TypeConfigRef & typeConfig,
const std::string & path,
bool memoryMappedData )

◆ operator=() [1/2]

template<class N>
DataFile & osmscout::DataFile< N >::operator= ( const DataFile< N > & )
delete

References DataFile().

◆ operator=() [2/2]

template<class N>
DataFile & osmscout::DataFile< N >::operator= ( DataFile< N > && )
delete

References DataFile().

Member Data Documentation

◆ typeConfig

template<class N>
TypeConfigRef osmscout::DataFile< N >::typeConfig
protected

The documentation for this class was generated from the following file: