Skip to content
Snippets Groups Projects
Select Git revision
  • 5fec463bf67d7ec11d13fda48d82db5e9b8fd70e
  • main default protected
  • f-sss4grpc
  • dev
  • 108-implement-rpc-call-for-server-side-scripting
  • f-windows-conan-create
  • f-to-string
  • f-update-requirements
  • f-related-projects
  • f-role
  • f-remote-path
  • f-rel-path
  • f-consol-message
  • v0.3.0
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.2
  • v0.1.1
  • v0.1
  • v0.0.19
  • v0.0.18
  • v0.0.16
  • v0.0.15
  • v0.0.10
  • v0.0.9
  • v0.0.8
  • v0.0.7
  • v0.0.6
  • v0.0.5
  • v0.0.4
  • v0.0.3
  • v0.0.2
33 results

transaction_status.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    transaction_status.h 9.43 KiB
    /*
     * This file is a part of the LinkAhead Project.
     *
     * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
     * Copyright (C) 2021-2024 IndiScale GmbH <info@indiscale.com>
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as
     * published by the Free Software Foundation, either version 3 of the
     * License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public License
     * along with this program. If not, see <https://www.gnu.org/licenses/>.
     *
     */
    
    #ifndef LINKAHEAD_TRANSACTION_STATUS_H
    #define LINKAHEAD_TRANSACTION_STATUS_H
    
    #include "linkahead/status_code.h"
    #include "linkahead/exceptions.h"
    #include <memory> // for shared_ptr, unique_ptr
    #include <string> // for string
    
    namespace linkahead::transaction {
    using linkahead::StatusCode;
    using linkahead::exceptions::AuthenticationError;
    using linkahead::exceptions::ConnectionError;
    using linkahead::exceptions::Exception;
    using linkahead::exceptions::TransactionError;
    using linkahead::exceptions::TransactionStatusError;
    using linkahead::exceptions::TransactionTypeError;
    
    /**
     * Define static factory method in the TransactionStatus class.
     */
    #define LINKAHEAD_TRANSACTION_STATUS_DEFAULT_FACTORY(_StatusName, _StatusCode)                     \
      inline static auto _StatusName()->const TransactionStatus & {                                    \
        static const TransactionStatus instance(_StatusCode,                                           \
                                                linkahead::get_status_description(_StatusCode));       \
        return instance;                                                                               \
      }
    
    /**
     * TransactionStatus indicates the current status of a transaction and, when it
     * has already terminated, whether the transaction has been successful or not.
     *
     * A status code of 0 denotes a generic success state, positive values indicate
     * errors, and negative values indicate other states, such as different stages
     * of a transaction in process.
     */
    class TransactionStatus {
    public:
      /**
       * Factory for an INITIAL status.
       *
       * This status means that the transaction has not been executed yet and the
       * transaction does not contain any sub-transactions yet.
       */
      LINKAHEAD_TRANSACTION_STATUS_DEFAULT_FACTORY(INITIAL, StatusCode::INITIAL)
      /**
       * Factory for a GO_ON status.
       *
       * This status means that the transaction has not been executed yet but it
       * already contains sub-transaction and more subtransactions may be added.