Vuo 2.4.4
Loading...
Searching...
No Matches
VuoModuleInfo.cc
Go to the documentation of this file.
1
10#include "VuoModuleInfo.hh"
11#include "VuoCompiler.hh"
14#include "VuoCompilerModule.hh"
15#include <sys/time.h>
16
20VuoModuleInfo::VuoModuleInfo(VuoCompilerEnvironment *environment, const string &searchPath, const string &relativePath,
21 bool isSourceFile, bool isSubcomposition)
22{
23 VuoFileUtilities::File *file = new VuoFileUtilities::File(searchPath, relativePath);
24 initialize(environment, searchPath, file, isSourceFile, isSubcomposition);
25}
26
31 bool isSourceFile, bool isSubcomposition)
32{
33 initialize(environment, searchPath, file, isSourceFile, isSubcomposition);
34}
35
39void VuoModuleInfo::initialize(VuoCompilerEnvironment *environment, const string &searchPath, VuoFileUtilities::File *file,
40 bool isSourceFile, bool isSubcomposition)
41{
42 this->environment = environment;
43 this->searchPath = searchPath;
44 this->file = file;
47 sourceCodeOverridden = false;
48 lastModified = VuoFileUtilities::getFileLastModifiedInSeconds(file->isInArchive() ? file->getArchivePath() : file->path());
49 longestDownstreamPath = 0;
50 attempted = false;
51 loading = nullptr;
52
53#if VUO_PRO
54 init_Pro();
55#endif
56
57 if (isSourceFile)
58 {
59 loading = dispatch_group_create();
60 sourceCode = file->getContentsAsString();
61
62 if (isSubcomposition)
63 {
64 try
65 {
67 }
68 catch (...)
69 {
70 // Issues parsing the composition will be caught later when compiling it.
71 }
72 }
73 }
74}
75
80{
81#if VUO_PRO
82 fini_Pro();
83#endif
84
85 delete file;
86
87 if (loading)
88 dispatch_release(loading);
89}
90
95{
96 return environment;
97}
98
103{
104 return searchPath;
105}
106
111{
112 return moduleKey;
113}
114
119{
120 return moduleKeyMangled;
121}
122
126void VuoModuleInfo::setUnmangledModuleKey(const string &moduleKey)
127{
128 this->moduleKey = moduleKey;
129 moduleKeyMangled = false;
130}
131
136{
137 return file;
138}
139
144{
145 return sourceCode;
146}
147
151void VuoModuleInfo::setSourceCode(const string &sourceCode)
152{
153 this->sourceCode = sourceCode;
154}
155
160{
161 sourceCode = file->getContentsAsString();
162}
163
168{
169 return sourceCodeOverridden;
170}
171
176{
177 sourceCodeOverridden = overridden;
178}
179
184{
185 return lastModified > other->lastModified;
186}
187
191bool VuoModuleInfo::isNewerThan(double ageInSeconds) const
192{
193 return lastModified > ageInSeconds;
194}
195
199bool VuoModuleInfo::isOlderThan(double ageInSeconds) const
200{
201 return lastModified < ageInSeconds;
202}
203
208{
209 struct timeval t;
210 gettimeofday(&t, NULL);
211 lastModified = t.tv_sec + t.tv_usec/1000000.0;
212}
213
218{
219 return containedNodeClasses;
220}
221
226{
227 return longestDownstreamPath;
228}
229
234{
235 longestDownstreamPath = pathLength;
236}
237
242{
243 return attempted;
244}
245
250void VuoModuleInfo::setAttempted(bool attempted)
251{
252 this->attempted = attempted;
253}
254
258dispatch_group_t VuoModuleInfo::getLoadingGroup(void) const
259{
260 return loading;
261}
262
267{
268 fprintf(stderr, "module %s:\n"
269 "\tloadingGroup=%p\n"
270 "\tsearchPath=%s\n"
271 "\tattempted=%d\n"
272 "\tenvironment=%s\n"
273 "\tfile=%s%s%s\n"
274 "\tsourceCodeOverridden=%d\n"
275 "\tsourceCode=%s\n"
276 "\tcontainedNodeClasses:\n",
277 moduleKey.c_str(),
278 loading,
279 searchPath.c_str(),
280 attempted,
281 environment->getCompiledModuleCachePath().c_str(),
282 file->isInArchive() ? file->getArchivePath().c_str() : "",
283 file->isInArchive() ? "::" : "",
284 file->isInArchive() ? file->getRelativePath().c_str() : file->path().c_str(),
285 sourceCodeOverridden,
286 sourceCode.c_str());
287 for (auto i: containedNodeClasses)
288 fprintf(stderr, "\t\t%s\n", i.c_str());
289}