Simo 0.0.1
Loading...
Searching...
No Matches
InitializationStatus.h
1/*
2 * Copyright 2026 Matteo Fusi and Contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SIMO_INITIALIZATIONSTATUS_H
18#define SIMO_INITIALIZATIONSTATUS_H
19
20#include <string>
21#include <string_view>
22#include <vector>
23
24#include "Simo/compiler/Compiler.h"
25
26namespace Simo {
27
28class Module;
29
30class SIMO_PUBLIC InitializationStatus {
31 public:
32 InitializationStatus(Module* module,
33 const std::vector<std::string>& error_list);
34
35 explicit InitializationStatus(Module* module);
36
37 static InitializationStatus ok(Module* module);
38
39 void add_error(std::string_view new_error);
40
41 template <typename... Args>
42 InitializationStatus& emplace_sub_error(Args... args) {
43 sub_errors.emplace_back(args...);
44 success_ &= sub_errors.back().success();
45 return sub_errors.back();
46 }
47
48 [[nodiscard]] bool success() const;
49
50 explicit operator bool() const;
51
52 protected:
53 Module* module = nullptr;
54 std::vector<std::string> error_list;
55 std::vector<InitializationStatus> sub_errors;
56 bool success_ = false;
57};
58
59} // namespace Simo
60
61#endif // SIMO_INITIALIZATIONSTATUS_H
Definition Module.h:83