Lumiera  0.pre.03
»edit your freedom«
exit-node.hpp
Go to the documentation of this file.
1 /*
2  EXIT-NODE.hpp - top-level node of the render network to pull generated media
3 
4  Copyright (C) Lumiera.org
5  2023, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
30 #ifndef ENGINE_EXIT_NODE_H
31 #define ENGINE_EXIT_NODE_H
32 
33 #include "lib/error.hpp"
34 #include "lib/nocopy.hpp"
35 #include "lib/hash-value.h"
36 #include "lib/iter-adapter-stl.hpp"
37 #include "lib/time/timevalue.hpp"
38 #include "vault/gear/job.h"
39 
40 #include <utility>
41 #include <deque>
42 
43 using lib::HashVal;
44 using lib::time::FSecs;
46 
47 
48 namespace steam {
49 namespace engine {
50 
51  class ExitNode;
52  using ExitNodes = std::deque<engine::ExitNode>;
53 
55 
56  namespace {// hard wired placeholder config....
57  const Duration DUMMY_JOB_RUNTIME{FSecs{1,50}};
58  }
59 
60 
72  class ExitNode
74  {
75  HashVal pipelineIdentity_;
76  Duration runtimeBound_;
77  ExitNodes prerequisites_;
78  JobFunctor* action_{nullptr};
79 
80  public:
81  ExitNode()
82  : pipelineIdentity_{0}
83  , runtimeBound_{DUMMY_JOB_RUNTIME}
84  , prerequisites_{}
85  { }
86 
87  ExitNode (HashVal id
88  ,Duration jobRuntime
89  ,ExitNodes&& prereq =ExitNodes{}
90  ,JobFunctor* functor =nullptr)
91  : pipelineIdentity_{id}
92  , runtimeBound_{jobRuntime}
93  , prerequisites_{std::move (prereq)}
94  , action_{functor}
95  { }
96 
97  explicit
98  ExitNode (HashVal id
99  ,ExitNodes&& prereq =ExitNodes{})
100  : ExitNode{id, DUMMY_JOB_RUNTIME, std::move(prereq)}
101  { }
102 
103  static ExitNode NIL;
104 
105 
106  bool
107  empty() const
108  {
109  return 0 == pipelineIdentity_
110  or not action_;
111  }
112 
113  bool
114  isValid() const
115  {
116  return true;
117  }
118 
119 
120  HashVal
121  getPipelineIdentity() const
122  {
123  return pipelineIdentity_;
124  }
125 
126  auto
127  getPrerequisites() const
128  {
129  return lib::iter_stl::eachElm (prerequisites_);
130  }
131 
132  JobFunctor&
133  getInvocationFunctor() const
134  {
135  REQUIRE (action_);
136  return *action_;
137  }
138 
139  Duration
140  getUpperBoundRuntime() const
141  {
143  return runtimeBound_;
144  }
145  };
146 
147 
148 }} // namespace steam::engine
149 #endif /*ENGINE_EXIT_NODE_H*/
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
A top-level point in the render node network where data generation can be driven. ...
Definition: exit-node.hpp:72
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:229
Definition of a render job.
Types marked with this mix-in may be created by copy-construction (or move construction), but may be not reassigned thereafter.
Definition: nocopy.hpp:91
Lumiera error handling (C++ interface).
Hash value types and utilities.
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:56
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:477
Preconfigured adapters for some STL container standard usage situations.
a family of time value like entities and their relationships.
static ExitNode NIL
storage for the »inactive« ExitNode marker
Definition: exit-node.hpp:103