Libosmium 2.22.0 Fast and flexible C++ library for working with OpenStreetMap data

Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
osmium::relations::RelationsDatabase Class Reference

`#include <relations_database.hpp>`

Collaboration diagram for osmium::relations::RelationsDatabase:
[legend]

## Classes
struct | element

## Public Member Functions
| RelationsDatabase (osmium::ItemStash &stash)
std::size_t | used_memory () const noexcept
std::size_t | size () const noexcept
RelationHandle | add (const osmium::Relation &relation)
RelationHandle | operator[] (std::size_t pos) noexcept
std::size_t | count_relations () const noexcept
template<typename TFunc >
void | for_each_relation (TFunc &&func)

## Private Member Functions
osmium::Relation & | get_relation (std::size_t pos)
std::size_t & | members (std::size_t pos) noexcept
void | remove (std::size_t pos)

## Private Attributes
osmium::ItemStash & | m_stash
std::vector< element > | m_elements

## Friends
class | RelationHandle

## Detailed Description

The RelationsDatabase is used for bringing relations and their members together. It stores the relations in memory and keeps track of how many members are needed to "complete" the relation. It is intended to work together with the MembersDatabase template class and usually used by relations manager classes.

To access relations stored in the database a RelationHandle is used. It is returned from the add() function. The handle is used for all operations on the database contents, such as accessing the stored relation, incrementing the member count or removing a relation from the database.

From the handle a "position" can be accessed, which, together with the database object, can be turned into a handle again. The position alone is smaller than the handle, so it can be stored elsewhere more efficiently. Specifically this is used in the MembersDatabase.

osmium::ItemStash stash;
osmium::relations::RelationsDatabase db{stash};
auto handle = db.add(relation);
auto pos = handle.pos();
auto second_handle = db[pos];
osmium::ItemStash
Definition item_stash.hpp:57
osmium::relations::RelationsDatabase
Definition relations_database.hpp:82
osmium::item_type::relation
@ relation

Now the `handle` and `second_handle` refer to the same relation.

See the RelationHandle for information about what you can do with it.

## Constructor & Destructor Documentation

## ◆ RelationsDatabase()

osmium::relations::RelationsDatabase::RelationsDatabase | ( | osmium::ItemStash & | stash | ) |
| inline explicit

Construct a RelationsDatabase.

Parameters

  stash | Reference to an ItemStash object. All relations will be stored in this stash. It must be available until the RelationsDatabase is destroyed.

## Member Function Documentation

## ◆ add()

RelationHandle osmium::relations::RelationsDatabase::add | ( | const osmium::Relation & | relation | ) |
| inline

Insert a relation into the database. The relation is copied into the stash.

Complexity: Amortized constant.

Parameters

  relation | The relation to be copied into the database.

Returns
  A handle to the relation.

## ◆ count_relations()

std::size_t osmium::relations::RelationsDatabase::count_relations | ( |  | ) | const
| inline noexcept

Return the number of non-removed relations in the database.

Complexity: Linear in the number of relations (as returned by size()).

## ◆ for_each_relation()

template<typename TFunc >

void osmium::relations::RelationsDatabase::for_each_relation | ( | TFunc && | func | ) |

Iterate over all (not-removed) relations in the database.

Template Parameters

  TFunc | Function with type void(const RelationHandle&).

Parameters

  func | Callback function which will be called for every not-removed relation with a RelationHandle.

## ◆ get_relation()

osmium::Relation & osmium::relations::RelationsDatabase::get_relation | ( | std::size_t | pos | ) |
| inline private

## ◆ members()

std::size_t & osmium::relations::RelationsDatabase::members | ( | std::size_t | pos | ) |
| inline private noexcept

Access the number of members of the entry at the specified position. This returns a reference so it can be changed.

## ◆ operator[]()

RelationHandle osmium::relations::RelationsDatabase::operator[] | ( | std::size_t | pos | ) |
| inline noexcept

Return a handle to the relation at the specified position in the database.

Complexity: Constant.

## ◆ remove()

void osmium::relations::RelationsDatabase::remove | ( | std::size_t | pos | ) |
| inline private

## ◆ size()

std::size_t osmium::relations::RelationsDatabase::size | ( |  | ) | const
| inline noexcept

The number of relations stored in the database. Includes relations marked as removed.

Complexity: Constant.

## ◆ used_memory()

std::size_t osmium::relations::RelationsDatabase::used_memory | ( |  | ) | const
| inline noexcept

Return an estimate of the number of bytes currently needed for the RelationsDatabase. This does NOT include the memory used in the stash. Used for debugging.

Complexity: Constant.

## Friends And Related Symbol Documentation

## ◆ RelationHandle

friend class RelationHandle
| friend

## Member Data Documentation

## ◆ m_elements

std::vector<element> osmium::relations::RelationsDatabase::m_elements
| private

## ◆ m_stash

osmium::ItemStash& osmium::relations::RelationsDatabase::m_stash
| private

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

- include/osmium/relations/relations_database.hpp