libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
osmscout::DataFile< N > Class Template Reference

#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. More...
 
 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. More...
 
template<typename IteratorIn >
bool GetByBlockSpans (IteratorIn begin, IteratorIn end, std::vector< ValueType > &data) const
 Read data values from the given DataBlockSpans. More...
 
bool GetByOffset (FileOffset offset, ValueType &entry) const
 Read one data value from the given file offset. More...
 
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. More...
 
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. More...
 
template<typename IteratorIn >
bool GetByOffset (IteratorIn begin, IteratorIn end, size_t size, std::vector< ValueType > &data) const
 Reads data for the given file offsets. More...
 
std::string GetFilename () const
 
virtual bool IsOpen () const
 Return true, if index is currently opened. More...
 
bool Open (const TypeConfigRef &typeConfig, const std::string &path, bool memoryMappedData)
 Open the index file. More...
 
DataFileoperator= (const DataFile &)=delete
 
DataFileoperator= (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

◆ DataFile() [3/3]

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

◆ ~DataFile()

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

Member Function Documentation

◆ Close()

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

Close the index.

Method is NOT thread-safe.

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

Referenced by osmscout::DataFile< PTRoute >::Close().

◆ 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.

◆ 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.

◆ GetByOffset() [1/4]

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

Read one data value from the given file offset.

Method is thread-safe.

◆ 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.

◆ 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.

◆ 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.

◆ GetFilename()

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

◆ IsOpen()

template<class N >
bool osmscout::DataFile< N >::IsOpen
virtual

◆ Open()

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

Open the index file.

Method is NOT thread-safe.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Member Data Documentation

◆ typeConfig

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

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