Loading...
Searching...
No Matches
expected_engine.h
Go to the documentation of this file.
#pragma once
#include <string>
#include <iostream>
namespace gridfire::expectations {
enum class EngineErrorTypes {
FAILURE,
INDEX,
STALE
};
enum class StaleEngineErrorTypes {
SYSTEM_RESIZED
};
// TODO: rename this to EngineExpectation or something similar
struct EngineError {
std::string m_message;
const EngineErrorTypes type = EngineErrorTypes::FAILURE;
explicit EngineError(const std::string &message, const EngineErrorTypes type)
: m_message(message), type(type) {}
virtual ~EngineError() = default;
friend std::ostream& operator<<(std::ostream& os, const EngineError& e) {
os << "EngineError: " << e.m_message;
return os;
}
};
struct EngineIndexError : EngineError {
int m_index;
explicit EngineIndexError(const int index)
: EngineError("Index error occurred", EngineErrorTypes::INDEX), m_index(index) {}
friend std::ostream& operator<<(std::ostream& os, const EngineIndexError& e) {
os << "EngineIndexError: " << e.m_message << " at index " << e.m_index;
return os;
}
};
struct StaleEngineError : EngineError {
StaleEngineErrorTypes staleType;
explicit StaleEngineError(const StaleEngineErrorTypes sType)
: EngineError("Stale engine error occurred", EngineErrorTypes::STALE), staleType(sType) {}
explicit operator std::string() const {
switch (staleType) {
case (StaleEngineErrorTypes::SYSTEM_RESIZED):
return "StaleEngineError: System resized, please update the engine.";
default:
return "StaleEngineError: Unknown stale error type.";
}
}
};
}
gridfire::expectations
Definition expected_engine.h:6
gridfire::expectations::EngineErrorTypes
EngineErrorTypes
Definition expected_engine.h:7
gridfire::expectations::EngineErrorTypes::FAILURE
@ FAILURE
Definition expected_engine.h:8
gridfire::expectations::EngineErrorTypes::STALE
@ STALE
Definition expected_engine.h:10
gridfire::expectations::EngineErrorTypes::INDEX
@ INDEX
Definition expected_engine.h:9
gridfire::expectations::StaleEngineErrorTypes
StaleEngineErrorTypes
Definition expected_engine.h:13
gridfire::expectations::StaleEngineErrorTypes::SYSTEM_RESIZED
@ SYSTEM_RESIZED
Definition expected_engine.h:14
gridfire::expectations::EngineError::~EngineError
virtual ~EngineError()=default
gridfire::expectations::EngineError::operator<<
friend std::ostream & operator<<(std::ostream &os, const EngineError &e)
Definition expected_engine.h:27
gridfire::expectations::EngineError::type
const EngineErrorTypes type
Definition expected_engine.h:20
gridfire::expectations::EngineError::m_message
std::string m_message
Definition expected_engine.h:19
gridfire::expectations::EngineError::EngineError
EngineError(const std::string &message, const EngineErrorTypes type)
Definition expected_engine.h:22
gridfire::expectations::EngineIndexError::m_index
int m_index
Definition expected_engine.h:34
gridfire::expectations::EngineIndexError::EngineIndexError
EngineIndexError(const int index)
Definition expected_engine.h:36
gridfire::expectations::EngineIndexError::operator<<
friend std::ostream & operator<<(std::ostream &os, const EngineIndexError &e)
Definition expected_engine.h:38
gridfire::expectations::StaleEngineError::staleType
StaleEngineErrorTypes staleType
Definition expected_engine.h:45
gridfire::expectations::StaleEngineError::StaleEngineError
StaleEngineError(const StaleEngineErrorTypes sType)
Definition expected_engine.h:47