Vuo
2.4.4
Loading...
Searching...
No Matches
compiler
VuoModuleInfo.cc
Go to the documentation of this file.
1
10
#include "
VuoModuleInfo.hh
"
11
#include "
VuoCompiler.hh
"
12
#include "
VuoCompilerEnvironment.hh
"
13
#include "
VuoCompilerGraphvizParser.hh
"
14
#include "
VuoCompilerModule.hh
"
15
#include <sys/time.h>
16
20
VuoModuleInfo::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
30
VuoModuleInfo::VuoModuleInfo
(
VuoCompilerEnvironment
*environment,
const
string
&searchPath,
VuoFileUtilities::File
*file,
31
bool
isSourceFile,
bool
isSubcomposition)
32
{
33
initialize(environment, searchPath, file, isSourceFile, isSubcomposition);
34
}
35
39
void
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;
45
moduleKey =
VuoCompiler::getModuleKeyForPath
(file->
getRelativePath
());
46
moduleKeyMangled =
VuoCompilerModule::isModuleKeyMangledInFileName
(file->
getRelativePath
());
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
{
66
containedNodeClasses =
VuoCompilerGraphvizParser::getNodeClassNamesFromCompositionFile
(file->
path
());
67
}
68
catch
(...)
69
{
70
// Issues parsing the composition will be caught later when compiling it.
71
}
72
}
73
}
74
}
75
79
VuoModuleInfo::~VuoModuleInfo
(
void
)
80
{
81
#if VUO_PRO
82
fini_Pro();
83
#endif
84
85
delete
file;
86
87
if
(loading)
88
dispatch_release(loading);
89
}
90
94
VuoCompilerEnvironment
*
VuoModuleInfo::getEnvironment
(
void
)
const
95
{
96
return
environment;
97
}
98
102
string
VuoModuleInfo::getSearchPath
(
void
)
const
103
{
104
return
searchPath;
105
}
106
110
string
VuoModuleInfo::getModuleKey
(
void
)
const
111
{
112
return
moduleKey;
113
}
114
118
bool
VuoModuleInfo::isModuleKeyMangled
(
void
)
const
119
{
120
return
moduleKeyMangled;
121
}
122
126
void
VuoModuleInfo::setUnmangledModuleKey
(
const
string
&moduleKey)
127
{
128
this->moduleKey = moduleKey;
129
moduleKeyMangled =
false
;
130
}
131
135
VuoFileUtilities::File
*
VuoModuleInfo::getFile
(
void
)
const
136
{
137
return
file;
138
}
139
143
string
VuoModuleInfo::getSourceCode
(
void
)
const
144
{
145
return
sourceCode;
146
}
147
151
void
VuoModuleInfo::setSourceCode
(
const
string
&sourceCode)
152
{
153
this->sourceCode = sourceCode;
154
}
155
159
void
VuoModuleInfo::revertSourceCode
(
void
)
160
{
161
sourceCode = file->
getContentsAsString
();
162
}
163
167
bool
VuoModuleInfo::isSourceCodeOverridden
(
void
)
const
168
{
169
return
sourceCodeOverridden;
170
}
171
175
void
VuoModuleInfo::setSourceCodeOverridden
(
bool
overridden)
176
{
177
sourceCodeOverridden = overridden;
178
}
179
183
bool
VuoModuleInfo::isNewerThan
(
VuoModuleInfo
*other)
const
184
{
185
return
lastModified > other->lastModified;
186
}
187
191
bool
VuoModuleInfo::isNewerThan
(
double
ageInSeconds)
const
192
{
193
return
lastModified > ageInSeconds;
194
}
195
199
bool
VuoModuleInfo::isOlderThan
(
double
ageInSeconds)
const
200
{
201
return
lastModified < ageInSeconds;
202
}
203
207
void
VuoModuleInfo::setLastModifiedToNow
(
void
)
208
{
209
struct
timeval t;
210
gettimeofday(&t, NULL);
211
lastModified = t.tv_sec + t.tv_usec/1000000.0;
212
}
213
217
set<string>
VuoModuleInfo::getContainedNodeClasses
(
void
)
const
218
{
219
return
containedNodeClasses;
220
}
221
225
int
VuoModuleInfo::getLongestDownstreamPath
(
void
)
const
226
{
227
return
longestDownstreamPath;
228
}
229
233
void
VuoModuleInfo::setLongestDownstreamPath
(
int
pathLength)
234
{
235
longestDownstreamPath = pathLength;
236
}
237
241
bool
VuoModuleInfo::getAttempted
(
void
)
const
242
{
243
return
attempted;
244
}
245
250
void
VuoModuleInfo::setAttempted
(
bool
attempted)
251
{
252
this->attempted = attempted;
253
}
254
258
dispatch_group_t
VuoModuleInfo::getLoadingGroup
(
void
)
const
259
{
260
return
loading;
261
}
262
266
void
VuoModuleInfo::dump
()
const
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
}
Generated on Thu Nov 9 2023 16:59:29 for Vuo by
1.9.8