Libosmium
2.20.0
Fast and flexible C++ library for working with OpenStreetMap data
|
#include <relations_database.hpp>
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 |
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.
Now the handle
and second_handle
refer to the same relation.
See the RelationHandle for information about what you can do with it.
|
inlineexplicit |
Construct a RelationsDatabase.
stash | Reference to an ItemStash object. All relations will be stored in this stash. It must be available until the RelationsDatabase is destroyed. |
|
inline |
Insert a relation into the database. The relation is copied into the stash.
Complexity: Amortized constant.
relation | The relation to be copied into the database. |
|
inlinenoexcept |
Return the number of non-removed relations in the database.
Complexity: Linear in the number of relations (as returned by size()).
void osmium::relations::RelationsDatabase::for_each_relation | ( | TFunc && | func | ) |
Iterate over all (not-removed) relations in the database.
TFunc | Function with type void(const RelationHandle&). |
func | Callback function which will be called for every not-removed relation with a RelationHandle. |
|
inlineprivate |
|
inlineprivatenoexcept |
Access the number of members of the entry at the specified position. This returns a reference so it can be changed.
|
inlinenoexcept |
Return a handle to the relation at the specified position in the database.
Complexity: Constant.
|
inlineprivate |
|
inlinenoexcept |
The number of relations stored in the database. Includes relations marked as removed.
Complexity: Constant.
|
inlinenoexcept |
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.
|
friend |
|
private |
|
private |