Path: blob/main/contrib/kyua/store/read_transaction.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 store/read_transaction.hpp29/// Implementation of read-only transactions on the backend.3031#if !defined(STORE_READ_TRANSACTION_HPP)32#define STORE_READ_TRANSACTION_HPP3334#include "store/read_transaction_fwd.hpp"3536extern "C" {37#include <stdint.h>38}3940#include <memory>41#include <string>4243#include "model/context_fwd.hpp"44#include "model/test_program_fwd.hpp"45#include "model/test_result_fwd.hpp"46#include "store/read_backend_fwd.hpp"47#include "store/read_transaction_fwd.hpp"48#include "utils/datetime_fwd.hpp"4950namespace store {515253namespace detail {545556model::test_program_ptr get_test_program(read_backend&, const int64_t);575859} // namespace detail606162/// Iterator for the set of test case results that are part of an action.63///64/// \todo Note that this is not a "standard" C++ iterator. I have chosen to65/// implement a different interface because it makes things easier to represent66/// an SQL statement state. Rewrite as a proper C++ iterator, inheriting from67/// std::iterator.68class results_iterator {69struct impl;7071/// Pointer to the shared internal implementation.72std::shared_ptr< impl > _pimpl;7374friend class read_transaction;75results_iterator(std::shared_ptr< impl >);7677public:78~results_iterator(void);7980results_iterator& operator++(void);81operator bool(void) const;8283const model::test_program_ptr test_program(void) const;84std::string test_case_name(void) const;85model::test_result result(void) const;86utils::datetime::timestamp start_time(void) const;87utils::datetime::timestamp end_time(void) const;8889std::string stdout_contents(void) const;90std::string stderr_contents(void) const;91};929394/// Representation of a read-only transaction.95///96/// Transactions are the entry place for high-level calls that access the97/// database.98class read_transaction {99struct impl;100101/// Pointer to the shared internal implementation.102std::shared_ptr< impl > _pimpl;103104friend class read_backend;105read_transaction(read_backend&);106107public:108~read_transaction(void);109110void finish(void);111112model::context get_context(void);113results_iterator get_results(void);114};115116117} // namespace store118119#endif // !defined(STORE_READ_TRANSACTION_HPP)120121122