1 // Copyright 2011 Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 //   notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 //   notice, this list of conditions and the following disclaimer in the
12 //   documentation and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors
14 //   may be used to endorse or promote products derived from this software
15 //   without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 /// \file engine/drivers/scan_action.hpp
30 /// Driver to scan the contents of an action.
31 ///
32 /// This driver module implements the logic to scan the contents of an stored
33 /// action and to notify the presentation layer as soon as data becomes
34 /// available.  This is to prevent reading all the data from the action at once,
35 /// which could take too much memory.
36 
37 #if !defined(ENGINE_DRIVERS_SCAN_ACTION_HPP)
38 #define ENGINE_DRIVERS_SCAN_ACTION_HPP
39 
40 extern "C" {
41 #include <stdint.h>
42 }
43 
44 #include "engine/test_program.hpp"
45 #include "store/transaction.hpp"
46 #include "utils/datetime.hpp"
47 #include "utils/fs/path.hpp"
48 #include "utils/optional.hpp"
49 
50 namespace engine {
51 
52 class action;
53 class test_result;
54 
55 namespace drivers {
56 namespace scan_action {
57 
58 
59 /// Abstract definition of the hooks for this driver.
60 class base_hooks {
61 public:
62     virtual ~base_hooks(void) = 0;
63 
64     /// Callback executed when an action is found.
65     ///
66     /// \param action_id The identifier of the loaded action.
67     /// \param action The action loaded from the database.
68     virtual void got_action(const int64_t action_id,
69                             const engine::action& action) = 0;
70 
71     /// Callback executed when a test results is found.
72     ///
73     /// \param iter Container for the test result's data.  Some of the data are
74     ///     lazily fetched, hence why we receive the object instead of the
75     ///     individual elements.
76     virtual void got_result(store::results_iterator& iter) = 0;
77 };
78 
79 
80 /// Tuple containing the results of this driver.
81 class result {
82 public:
83     /// Initializer for the tuple's fields.
result(void)84     result(void)
85     {
86     }
87 };
88 
89 
90 result drive(const utils::fs::path&, utils::optional< int64_t >,
91              base_hooks&);
92 
93 
94 }  // namespace scan_action
95 }  // namespace drivers
96 }  // namespace engine
97 
98 #endif  // !defined(ENGINE_DRIVERS_SCAN_ACTION_HPP)
99