22#define OSM2PGSQL_DEPENDENCY_MANAGER_HPP
33
44#include " id-tracker.hpp"
5- #include " middle.hpp"
65#include " osmtypes.hpp"
76
87#include < cassert>
98#include < memory>
109
11- struct pending_processor
12- {
13- virtual ~pending_processor () = default ;
14-
15- virtual void enqueue_way (osmid_t id) = 0;
16- virtual void enqueue_relation (osmid_t id) = 0;
17-
18- virtual void process_ways () = 0;
19- virtual void process_relations () = 0;
20- };
10+ struct middle_t ;
2111
2212/* *
2313 * The job of the dependency manager is to keep track of the dependencies
@@ -69,23 +59,24 @@ class dependency_manager_t
6959 virtual bool has_pending () const noexcept { return false ; }
7060
7161 /* *
72- * Process all pending objects.
73- *
74- * \param pf Processor that we should feed the objects to and that
75- * will handle the actual processing.
76- *
77- * \post !has_pending()
62+ * Get the list of pending way ids. After calling this, the internal
63+ * list is cleared.
7864 */
79- virtual void process_pending (pending_processor &) {}
65+ virtual idlist_t get_pending_way_ids () { return {}; }
66+
67+ /* *
68+ * Get the list of pending relation ids. After calling this, the internal
69+ * list is cleared.
70+ */
71+ virtual idlist_t get_pending_relation_ids () { return {}; }
8072};
8173
8274/* *
8375 * The job of the dependency manager is to keep track of the dependencies
8476 * between OSM objects, that is nodes in ways and members of relations.
8577 *
8678 * Whenever an OSM object changes, this class is notified and remembers
87- * the ids for later use. Later on the class can be told to process the
88- * ids it has remembered.
79+ * the ids for later use.
8980 */
9081class full_dependency_manager_t : public dependency_manager_t
9182{
@@ -111,49 +102,19 @@ class full_dependency_manager_t : public dependency_manager_t
111102
112103 bool has_pending () const noexcept override ;
113104
114- void process_pending (pending_processor &proc) override ;
115-
116- /* *
117- * Get access to the pending way ids. This is for debugging only.
118- *
119- * Note that the list of pending way ids will be empty after calling
120- * this.
121- *
122- * \tparam TOutputIterator Some output iterator type, for instance
123- * created with std::back_inserter(some vector).
124- * \param it output iterator to which all ids should be written. *it
125- * must be of type osmid_t.
126- */
127- template <typename TOutputIterator>
128- void get_pending_way_ids (TOutputIterator &&it)
105+ idlist_t get_pending_way_ids () override
129106 {
130- osmid_t id;
131- while (id_tracker::is_valid (id = m_ways_pending_tracker.pop_mark ())) {
132- *it++ = id;
133- }
107+ return get_ids (m_ways_pending_tracker);
134108 }
135109
136- /* *
137- * Get access to the pending relation ids. This is for debugging only.
138- *
139- * Note that the list of pending relation ids will be empty after calling
140- * this.
141- *
142- * \tparam TOutputIterator Some output iterator type, for instance
143- * created with std::back_inserter(some vector).
144- * \param it output iterator to which all ids should be written. *it
145- * must be of type osmid_t.
146- */
147- template <typename TOutputIterator>
148- void get_pending_relation_ids (TOutputIterator &&it)
110+ idlist_t get_pending_relation_ids () override
149111 {
150- osmid_t id;
151- while (id_tracker::is_valid (id = m_rels_pending_tracker.pop_mark ())) {
152- *it++ = id;
153- }
112+ return get_ids (m_rels_pending_tracker);
154113 }
155114
156115private:
116+ static idlist_t get_ids (id_tracker &tracker);
117+
157118 std::shared_ptr<middle_t > m_object_store;
158119
159120 id_tracker m_ways_pending_tracker;
0 commit comments