Osmium  0.1
include/osmium/handler/range_from_history.hpp
Go to the documentation of this file.
00001 #ifndef OSMIUM_HANDLER_RANGE_FROM_HISTORY_HPP
00002 #define OSMIUM_HANDLER_RANGE_FROM_HISTORY_HPP
00003 
00004 /*
00005 
00006 Copyright 2011 Jochen Topf <jochen@topf.org> and others (see README).
00007 
00008 This file is part of Osmium (https://github.com/joto/osmium).
00009 
00010 Osmium is free software: you can redistribute it and/or modify it under the
00011 terms of the GNU Lesser General Public License or (at your option) the GNU
00012 General Public License as published by the Free Software Foundation, either
00013 version 3 of the Licenses, or (at your option) any later version.
00014 
00015 Osmium is distributed in the hope that it will be useful, but WITHOUT ANY
00016 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00017 PARTICULAR PURPOSE. See the GNU Lesser General Public License and the GNU
00018 General Public License for more details.
00019 
00020 You should have received a copy of the Licenses along with Osmium. If not, see
00021 <http://www.gnu.org/licenses/>.
00022 
00023 */
00024 
00025 namespace Osmium {
00026 
00027     namespace Handler {
00028 
00036         template <class THandler>
00037         class RangeFromHistory : public Base {
00038 
00039         public:
00040 
00041             RangeFromHistory(THandler* handler, time_t from, time_t to) : Base(), m_handler(handler), m_from(from), m_to(to) {
00042             }
00043 
00044             void init(Osmium::OSM::Meta& meta) {
00045                 m_handler->init(meta);
00046             }
00047 
00048             void before_nodes() {
00049                 m_handler->before_nodes();
00050             }
00051 
00052             void node(const shared_ptr<Osmium::OSM::Node>& node) {
00053                 if ((node->endtime() == 0 || node->endtime() >= m_from) && node->timestamp() <= m_to) {
00054                     m_handler->node(node);
00055                 }
00056             }
00057 
00058             void after_nodes() {
00059                 m_handler->after_nodes();
00060             }
00061 
00062             void before_ways() {
00063                 m_handler->before_ways();
00064             }
00065 
00066             void way(const shared_ptr<Osmium::OSM::Way>& way) {
00067                 if ((way->endtime() == 0 || way->endtime() >= m_from) && way->timestamp() <= m_to) {
00068                     m_handler->way(way);
00069                 }
00070             }
00071 
00072             void after_ways() {
00073                 m_handler->after_ways();
00074             }
00075 
00076             void before_relations() {
00077                 m_handler->before_relations();
00078             }
00079 
00080             void relation(const shared_ptr<Osmium::OSM::Relation>& relation) {
00081                 if ((relation->endtime() == 0 || relation->endtime() >= m_from) && relation->timestamp() <= m_to) {
00082                     m_handler->relation(relation);
00083                 }
00084             }
00085 
00086             void after_relations() {
00087                 m_handler->after_relations();
00088             }
00089 
00090             void final() {
00091                 m_handler->final();
00092             }
00093 
00094         private:
00095 
00096             THandler* m_handler;
00097 
00098             const time_t m_from;
00099             const time_t m_to;
00100 
00101         }; // class RangeFromHistory
00102 
00103     } // namespace Handler
00104 
00105 } // namespace Osmium
00106 
00107 #endif // OSMIUM_HANDLER_RANGE_FROM_HISTORY_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines