Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
INullOptEdge.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
18
20#include <memory>
21#include <optional>
22
23namespace shamrock::solvergraph {
24
25 class INullOptEdge : public IEdge {
26 public:
27 INullOptEdge() : IEdge() {}
28
29 virtual std::string _impl_get_dot_label() const { return "null_opt_edge"; }
30 virtual std::string _impl_get_tex_symbol() const { return "null_opt_edge"; }
31 virtual void free_alloc() {}
32 };
33
34 inline std::shared_ptr<INullOptEdge> make_null_opt_edge() {
35 return std::make_shared<INullOptEdge>();
36 }
37
38 inline bool is_null_opt_edge(const std::shared_ptr<IEdge> &edge) {
39 return std::dynamic_pointer_cast<INullOptEdge>(edge) != nullptr;
40 }
41
42 template<class T>
43 inline std::shared_ptr<IEdge> obsfucate_null_opt_edge(const std::optional<T> &edge) {
44 if (edge.has_value()) {
45 return edge.value();
46 } else {
47 return make_null_opt_edge();
48 }
49 }
50
51} // namespace shamrock::solvergraph
virtual void free_alloc()
Free allocated memory.