Overpass API regression suite coverage (Nova Scotia) / overpass_api/statements/retro.cc

overpass_api/statements/retro.cc

30 of 41 instrumented lines run by the suite (73.2%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#include "evaluator.h"
20#include "retro.h"
23Generic_Statement_Maker< Retro_Statement > Retro_Statement::statement_maker("retro");
26Retro_Statement::Retro_Statement
27 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)
284515 q : Statement(line_number_), timestamp(0)
304515 q std::map< std::string, std::string > attributes;
324515 q eval_attributes_array(get_name(), attributes, input_attributes);
36void Retro_Statement::add_statement(Statement* statement, std::string text)
3711415 q{
3811415 q assure_no_text(text, this->get_name());
4011415 q if (!timestamp)
414515 q {
424515 q Evaluator* tag_value = dynamic_cast< Evaluator* >(statement);
434515 q if (tag_value)
444515 q timestamp = tag_value;
450 else
460 add_static_error("A Retro statement must have an Evaluator as first sub-statement.");
474515 q }
486915 q else if (statement)
496915 q {
506915 q if (statement->get_name() == "newer")
510 add_static_error("\"newer\" can appear only inside \"query\" statements.");
536915 q substatements.push_back(statement);
546915 q }
5511415 q}
58uint64 eval_timestamp(Evaluator& criterion, const Statement& stmt, Resource_Manager& rman)
601715 q Prepare_Task_Context context(criterion.request_context(), stmt, rman);
611715 q Owner< Eval_Task > task(criterion.get_string_task(context, 0));
621715 q std::string valuation = (*task).eval(0);
641715 q return Timestamp(valuation).timestamp;
68void Retro_Statement::execute(Resource_Manager& rman)
701715 q if (!timestamp)
710 return;
731715 q uint64 retro_timestamp = eval_timestamp(*timestamp, *this, rman);
741715 q if (!retro_timestamp)
751715 q return;
770 rman.push_stack_frame();
780 rman.set_desired_timestamp(retro_timestamp);
800 for (std::vector< Statement* >::iterator it = substatements.begin(); it != substatements.end(); ++it)
810 (*it)->execute(rman);
830 rman.pop_stack_frame();
840 rman.health_check(*this);
850}