本文整理汇总了C++中osmium::memory::Buffer::add_item方法的典型用法代码示例。如果您正苦于以下问题:C++ Buffer::add_item方法的具体用法?C++ Buffer::add_item怎么用?C++ Buffer::add_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osmium::memory::Buffer
的用法示例。
在下文中一共展示了Buffer::add_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_relation
/**
* Tell the Collector that you are interested in this relation
* and want it kept until all members have been assembled and
* it is handed back to you.
*
* The relation is copied and stored in a buffer inside the
* collector.
*/
void add_relation(const osmium::Relation& relation) {
const size_t offset = m_relations_buffer.committed();
m_relations_buffer.add_item(relation);
RelationMeta relation_meta(offset);
int n = 0;
for (auto& member : m_relations_buffer.get<osmium::Relation>(offset).members()) {
if (static_cast<TCollector*>(this)->keep_member(relation_meta, member)) {
member_meta(member.type()).emplace_back(member.ref(), m_relations.size(), n);
relation_meta.increment_need_members();
} else {
member.ref(0); // set member id to zero to indicate we are not interested
}
++n;
}
assert(offset == m_relations_buffer.committed());
if (relation_meta.has_all_members()) {
m_relations_buffer.rollback();
} else {
m_relations_buffer.commit();
m_relations.push_back(std::move(relation_meta));
// std::cerr << "added relation id=" << relation.id() << "\n";
}
}