Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
job.cpp
Go to the documentation of this file.
1/*
2 Job - render job closure
3
4 Copyright (C)
5 2012, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
14
27#include "vault/gear/job.h"
29#include "lib/util.hpp"
30
31#include <boost/functional/hash.hpp>
32#include <typeinfo>
33
34
35namespace vault{
36namespace gear {
37
38 namespace { // Details...
39
40 inline JobClosure&
41 myClosure (const Job * const self)
42 {
43 ASSERT (self);
44 ASSERT (self->jobClosure);
45 return *static_cast<JobClosure*> (self->jobClosure);
46 }
47
48 } // (END) Details...
49
50
51 using lib::HashVal;
53
54
55
63
65
66
67
68
69 void
71 {
72 myClosure(this).invokeJobOperation (parameter);
73 }
74
75
83 {
84 return myClosure(this).getJobKind();
85 }
86
87
88 bool
89 Job::usesClosure (JobClosure const& otherClosure) const
90 {
91 return isSameObject (myClosure(this), otherClosure);
92 }
93
94
95
103 HashVal
104 hash_value (Job const& job)
105 {
106 return myClosure(&job).hash_value (job.parameter);
107 }
108
109 HashVal
111 {
112 HashVal hash = this->hashOfInstance (parameter.invoKey);
113 boost::hash_combine(hash, typeid(*this).hash_code());
114 boost::hash_combine(hash, parameter.nominalTime);
115 return hash;
116 }
117
118
119}} // namespace vault::gear
120
121namespace {
122 using vault::gear::Job;
123
124 inline Job&
125 forwardInvocation (lumiera_jobDefinition& jobDef)
126 {
127 Job& job = static_cast<Job&> (jobDef);
128 return job;
129 }
130}
131
132
133
134extern "C" { /* ==== implementation C interface for job invocation ======= */
135
136void
138{
139 REQUIRE (jobDef);
140 forwardInvocation(*jobDef).triggerJob();
141}
142
143size_t
145{
146 REQUIRE (jobDef);
147 return hash_value (forwardInvocation (*jobDef));
148}
149
151#include "lib/luid.h"
152
153int
154lumiera_invokey_eq (void* l, void* r)
155{
156 return lumiera_uid_eq ((LumieraUid)l, (LumieraUid)r);
157}
158}/* extern "C" */
Interface of the closure for frame rendering jobs.
Definition job.h:244
lib::HashVal hash_value(JobParameter) const
Definition job.cpp:110
virtual JobKind getJobKind() const =0
virtual HashVal hashOfInstance(InvocationInstanceID) const =0
virtual void invokeJobOperation(JobParameter parameter)=0
virtual ~JobClosure()
this is an interface
Definition job.cpp:62
virtual ~JobFunctor()
this is an interface
Definition job.cpp:61
Individual frame rendering task, forwarding to a closure.
Definition job.h:276
bool usesClosure(JobClosure const &) const
Definition job.cpp:89
JobKind getKind() const
find out about the classification of this job.
Definition job.cpp:82
void triggerJob() const
Definition job.cpp:70
#define hash
lumiera_uid * LumieraUid
Definition hash-value.h:41
size_t lumiera_job_get_hash(LumieraJobDefinition jobDef)
calculate a hash value based on the Job's identity.
Definition job.cpp:144
void lumiera_job_invoke(LumieraJobDefinition jobDef)
trigger execution of a specific job, assuming availability of all prerequisites
Definition job.cpp:137
int lumiera_invokey_eq(void *l, void *r)
Definition job.cpp:154
Definition of a render job.
JobKind
Definition job.h:64
lumiera_jobDefinition * LumieraJobDefinition
Definition job.h:145
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid's for equality.
Definition luid.c:97
Lumiera unique object identifier.
Job & forwardInvocation(lumiera_jobDefinition &jobDef)
Definition job.cpp:125
size_t HashVal
a STL compatible hash value
Definition hash-value.h:52
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Definition util.hpp:421
JobClosure & myClosure(const Job *const self)
Definition job.cpp:41
lumiera_jobParameter const & JobParameter
Definition job.h:205
HashVal hash_value(ManifestationID const &id)
Vault-Layer implementation namespace root.
Generic implementation of a JobFunctor to perform no calculations.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...