MCPcopy Create free account
hub / github.com/ImageEngine/cortex / computeFn

Method computeFn

src/IECore/CachedReader.cpp:104–185  ·  view source on GitHub ↗

static function used by the cache mechanism to actually load the object data from file.

Source from the content-addressed store, hash-verified

102
103 // static function used by the cache mechanism to actually load the object data from file.
104 static ObjectPtr computeFn( const ComputeParameters &params )
105 {
106 const std::string &filePath = params.first;
107 MemberData *data = params.second;
108
109 {
110 /// Check if the file failed before...
111 FileErrors::const_accessor cit;
112 if ( data->m_fileErrors.find( cit, filePath ) )
113 {
114 throw Exception( ( format( "Previous attempt to read %s failed: %s" ) % filePath % cit->second ).str() );
115 }
116 }
117
118 ObjectPtr result(nullptr);
119 try
120 {
121 path resolvedPath = data->m_searchPaths.find( filePath );
122 if( resolvedPath.empty() )
123 {
124 string pathList;
125
126#ifdef _WIN32
127 const std::string separator = ";";
128#else
129 const std::string separator = ":";
130#endif
131
132 for( list<path>::const_iterator it = data->m_searchPaths.paths.begin(); it!= data->m_searchPaths.paths.end(); it++ )
133 {
134 if ( pathList.size() > 0 )
135 {
136 pathList += separator + it->string();
137 }
138 else
139 {
140 pathList = it->string();
141 }
142 }
143 throw Exception( "Could not find file '" + filePath + "' at the following paths: " + pathList );
144 }
145
146 ReaderPtr r = Reader::create( resolvedPath.string() );
147 if( !r )
148 {
149 throw Exception( "Could not create reader for '" + resolvedPath.string() + "'" );
150 }
151
152 result = r->read();
153 /// \todo Why would this ever be NULL? Wouldn't we have thrown an exception already if
154 /// we were unable to read the file?
155 if( !result )
156 {
157 throw Exception( "Reader for '" + resolvedPath.string() + "' returned no data" );
158 }
159
160 if( data->m_postProcessor )
161 {

Callers

nothing calls this directly

Calls 12

createFunction · 0.85
inputParameterMethod · 0.80
copyParameterMethod · 0.80
operateMethod · 0.80
registerFileErrorMethod · 0.80
whatMethod · 0.80
findMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected