Path: blob/main/contrib/kyua/drivers/scan_results.hpp
39478 views
// Copyright 2011 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file drivers/scan_results.hpp29/// Driver to scan the contents of a results file.30///31/// This driver module implements the logic to scan the contents of a results32/// file and to notify the presentation layer as soon as data becomes33/// available. This is to prevent reading all the data from the file at once,34/// which could take too much memory.3536#if !defined(DRIVERS_SCAN_RESULTS_HPP)37#define DRIVERS_SCAN_RESULTS_HPP3839extern "C" {40#include <stdint.h>41}4243#include <set>4445#include "engine/filters.hpp"46#include "model/context_fwd.hpp"47#include "store/read_transaction_fwd.hpp"48#include "utils/datetime_fwd.hpp"49#include "utils/fs/path_fwd.hpp"5051namespace drivers {52namespace scan_results {535455/// Tuple containing the results of this driver.56class result {57public:58/// Filters that did not match any available test case.59///60/// The presence of any filters here probably indicates a usage error. If a61/// test filter does not match any test case, it is probably a typo.62std::set< engine::test_filter > unused_filters;6364/// Initializer for the tuple's fields.65///66/// \param unused_filters_ The filters that did not match any test case.67result(const std::set< engine::test_filter >& unused_filters_) :68unused_filters(unused_filters_)69{70}71};727374/// Abstract definition of the hooks for this driver.75class base_hooks {76public:77virtual ~base_hooks(void) = 0;7879virtual void begin(void);8081/// Callback executed when the context is loaded.82///83/// \param context The context loaded from the database.84virtual void got_context(const model::context& context) = 0;8586/// Callback executed when a test results is found.87///88/// \param iter Container for the test result's data. Some of the data are89/// lazily fetched, hence why we receive the object instead of the90/// individual elements.91virtual void got_result(store::results_iterator& iter) = 0;9293virtual void end(const result& r);94};959697result drive(const utils::fs::path&, const std::set< engine::test_filter >&,98base_hooks&);99100101} // namespace scan_results102} // namespace drivers103104#endif // !defined(DRIVERS_SCAN_RESULTS_HPP)105106107