Lumiera  0.pre.03
»edit your freedom«
activity-lang.cpp
Go to the documentation of this file.
1 /*
2  ActivityLang - definition language framework for scheduler activities
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 
34 #include "lib/format-obj.hpp"
35 #include "lib/symbol.hpp"
36 #include "vault/gear/scheduler.hpp"
37 
38 #include <string>
39 #include <boost/functional/hash.hpp>
40 
41 using std::string;
42 using lib::Symbol;
43 using lib::time::Time;
45 
46 
47 namespace vault{
48 namespace gear {
49  namespace activity {
50  Hook::~Hook() { } // emit VTable here...
51  }
53  HashVal
54  hash_value (ManifestationID const& id)
55  {
56  return boost::hash_value (uint32_t{id});
57  }
58 
59  Symbol WorkTiming::WORKSTART{"WorkStart"};
60  Symbol WorkTiming::WORKSTOP {"WorkStop"};
61 
63 
64 
65  Activity::operator string() const
66  {
67  return string{"Act("}
68  + showVerb()
69  + util::showAddr(this)
70  + ": "
71  + showData()
72  + "; ⤵ "
73  + (next? next->showVerb()+util::showAddr(*next)
74  : util::BOTTOM_INDICATOR)
75  + ")";
76  }
77 
78  string
79  Activity::showVerb() const
80  {
81  switch (verb_) {
82  case INVOKE: return "INVOKE";
83  case WORKSTART: return "WORKSTART";
84  case WORKSTOP: return "WORKSTOP";
85  case NOTIFY: return "NOTIFY";
86  case GATE: return "GATE";
87  case POST: return "POST";
88  case FEED: return "FEED";
89  case HOOK: return "HOOK";
90  case TICK: return "TICK";
91  default: NOTREACHED ("uncovered Activity verb diagnostics.");
92  }
93  }
94 
95  string
96  Activity::showData() const
97  {
98  switch (verb_) {
99  case INVOKE:
100  return util::showPtr (data_.invocation.task)
101  + ", "
102  + util::toString(TimeValue{data_.invocation.time});
103  case WORKSTART:
104  case WORKSTOP:
105  return util::toString(TimeValue{data_.timing.instant})
106  + ", quality="
107  + util::toString(data_.timing.quality);
108  case NOTIFY:
109  return util::showAddr(data_.notification.target)
110  + ", timing:"
111  + util::toString(Time{data_.notification.timing});
112  case GATE:
113  return "<"
114  + util::toString(data_.condition.rest)
115  + ", until "
116  + util::toString(Time{data_.condition.dead});
117  case POST:
118  return "["
119  + util::toString(Time{data_.timeWindow.life})
120  + "…"
121  + util::toString(Time{data_.timeWindow.dead})
122  + "]";
123  case FEED:
124  return "{"
125  + util::toString(data_.feed.one)
126  + "::"
127  + util::toString(data_.feed.two)
128  + "}";
129  case HOOK:
130  return util::showPtr (data_.callback.hook)
131  + "("
132  + util::toString(data_.callback.arg)
133  + ")";
134  case TICK:
135  return "◆ ";
136  default:
137  NOTREACHED ("uncovered Activity verb in activation function.");
138  }
139  }
140 
141 
142 }} // namespace vault::gear
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
Token or Atom with distinct identity.
Definition: symbol.hpp:126
Service for coordination and dispatch of render activities.
Marker for current (and obsolete) manifestations of a CalcStream processed by the Render-Engine...
Definition: activity.hpp:93
Marker types to indicate a literal string and a Symbol.
A language framework to define and interconnect scheduler activity verbs.
virtual ~Hook()
this is an interface
Simple functions to represent objects, for debugging and diagnostics.
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:56
basic constant internal time value.
Definition: timevalue.hpp:142
Vault-Layer implementation namespace root.