Select Git revision
transaction_status.h
-
Joscha Schmiedt authoredJoscha Schmiedt authored
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.