GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
expected_engine.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <iostream>
5
12
16
17 // TODO: rename this to EngineExpectation or something similar
18 struct EngineError {
19 std::string m_message;
21
22 explicit EngineError(const std::string &message, const EngineErrorTypes type)
23 : m_message(message), type(type) {}
24
25 virtual ~EngineError() = default;
26
27 friend std::ostream& operator<<(std::ostream& os, const EngineError& e) {
28 os << "EngineError: " << e.m_message;
29 return os;
30 }
31 };
32
35
36 explicit EngineIndexError(const int index)
37 : EngineError("Index error occurred", EngineErrorTypes::INDEX), m_index(index) {}
38 friend std::ostream& operator<<(std::ostream& os, const EngineIndexError& e) {
39 os << "EngineIndexError: " << e.m_message << " at index " << e.m_index;
40 return os;
41 }
42 };
43
46
48 : EngineError("Stale engine error occurred", EngineErrorTypes::STALE), staleType(sType) {}
49
50 explicit operator std::string() const {
51 switch (staleType) {
53 return "StaleEngineError: System resized, please update the engine.";
54 default:
55 return "StaleEngineError: Unknown stale error type.";
56 }
57 }
58 };
59}
friend std::ostream & operator<<(std::ostream &os, const EngineError &e)
EngineError(const std::string &message, const EngineErrorTypes type)
friend std::ostream & operator<<(std::ostream &os, const EngineIndexError &e)
StaleEngineError(const StaleEngineErrorTypes sType)