OGLplus  (0.59.0) a C++ wrapper for rendering APIs

fallback_input.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_TEXGEN_FALLBACK_INPUT_HPP
9 #define OGLPLUS_TEXGEN_FALLBACK_INPUT_HPP
10 
11 #include "base_input.hpp"
12 #include "const_output.hpp"
13 
14 namespace eagine::oglp::texgen {
15 
16 template <typename FallbackOutput>
17 class fallback_input : public base_input {
18 private:
19  FallbackOutput _fallback;
20 
21 public:
22  fallback_input(node_intf& parent, string_view name)
23  : base_input(parent, name)
24  , _fallback(parent) {}
25 
26  template <typename... P>
27  fallback_input(node_intf& parent, string_view name, P&&... p)
28  : base_input(parent, name)
29  , _fallback(parent, std::forward<P>(p)...) {}
30 
31  FallbackOutput& fallback() noexcept {
32  return _fallback;
33  }
34 
35  bool accepts_value_type(slot_data_type) override {
36  return true;
37  }
38 
39  output_intf& output() {
40  if(is_connected()) {
41  return connected_output();
42  } else {
43  return fallback();
44  }
45  }
46 
47  bool
48  set_default_value(valid_if_between<span_size_t, 0, 3> c, float v) override {
49  return fallback().set_default_value(c.value(), v);
50  }
51 
52  slot_data_type value_type() {
53  return output().value_type();
54  }
55 
56  std::ostream&
57  definitions(std::ostream& out, compile_context& ctxt) override {
58  return output().definitions(out, ctxt);
59  }
60 
61  std::ostream& expression(std::ostream& out, compile_context& ctxt) override {
62  return output().expression(out, ctxt);
63  }
64 };
65 
66 template <typename T>
67 using input_with_const_default = fallback_input<constant_output<T>>;
68 
69 } // namespace eagine::oglp::texgen
70 
71 #endif // OGLPLUS_TEXGEN_FALLBACK_INPUT_HPP
value_type
Value tree value element data type enumeration.
Definition: interface.hpp:27
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).