Lumiera  0.pre.03
»edit your freedom«
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 
35 namespace vault{
36 namespace 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;
52  using util::isSameObject;
53 
54 
55 
63 
64  NopJobFunctor::NopJobFunctor() { }
65 
66 
67 
68 
69  void
70  Job::triggerJob() const
71  {
72  myClosure(this).invokeJobOperation (parameter);
73  }
74 
75 
81  JobKind
82  Job::getKind() const
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
110  JobClosure::hash_value (JobParameter parameter) const
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 
121 namespace {
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 
134 extern "C" { /* ==== implementation C interface for job invocation ======= */
135 
136 void
137 lumiera_job_invoke (LumieraJobDefinition jobDef)
138 {
139  REQUIRE (jobDef);
140  forwardInvocation(*jobDef).triggerJob();
141 }
142 
143 size_t
144 lumiera_job_get_hash (LumieraJobDefinition jobDef)
145 {
146  REQUIRE (jobDef);
147  return hash_value (forwardInvocation (*jobDef));
148 }
149 
151 #include "lib/luid.h"
152 
153 int
154 lumiera_invokey_eq (void* l, void* r)
155 {
156  return lumiera_uid_eq ((LumieraUid)l, (LumieraUid)r);
157 }
158 }/* extern "C" */
void lumiera_job_invoke(LumieraJobDefinition jobDef)
trigger execution of a specific job, assuming availability of all prerequisites
Definition: job.cpp:137
Generic implementation of a JobFunctor to perform no calculations.
virtual ~JobFunctor()
this is an interface
Definition: job.cpp:61
Lumiera unique object identifier.
size_t lumiera_job_get_hash(LumieraJobDefinition jobDef)
calculate a hash value based on the Job&#39;s identity.
Definition: job.cpp:144
JobKind
Definition: job.h:62
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
JobKind getKind() const
find out about the classification of this job.
Definition: job.cpp:82
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid&#39;s for equality.
Definition: luid.c:97
Definition of a render job.
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:52
Interface of the closure for frame rendering jobs.
Definition: job.h:235
Individual frame rendering task, forwarding to a closure.
Definition: job.h:268
Vault-Layer implementation namespace root.
virtual ~JobClosure()
this is an interface
Definition: job.cpp:62