void LocalFileFormat::BuildFileOps(OpRcPtrVec & ops, const Config& config, const ConstContextRcPtr & /*context*/, CachedFileRcPtr untypedCachedFile, const FileTransform& fileTransform, TransformDirection dir) const { LocalCachedFileRcPtr cachedFile = DynamicPtrCast<LocalCachedFile>(untypedCachedFile); // This should never happen. if(!cachedFile) { std::ostringstream os; os << "Cannot build .cc Op. Invalid cache type."; throw Exception(os.str().c_str()); } TransformDirection newDir = CombineTransformDirections(dir, fileTransform.getDirection()); if(newDir == TRANSFORM_DIR_UNKNOWN) { std::ostringstream os; os << "Cannot build file format transform,"; os << " unspecified transform direction."; throw Exception(os.str().c_str()); } BuildCDLOps(ops, config, *cachedFile->transform, newDir); }
void BuildOps(OpRcPtrVec & ops, const Config & config, const ConstContextRcPtr & context, const ConstTransformRcPtr & transform, TransformDirection dir) { // A null transform is valid, and corresponds to a no-op. if(!transform) return; if(ConstAllocationTransformRcPtr allocationTransform = \ DynamicPtrCast<const AllocationTransform>(transform)) { BuildAllocationOps(ops, config, *allocationTransform, dir); } else if(ConstCDLTransformRcPtr cdlTransform = \ DynamicPtrCast<const CDLTransform>(transform)) { BuildCDLOps(ops, config, *cdlTransform, dir); } else if(ConstColorSpaceTransformRcPtr colorSpaceTransform = \ DynamicPtrCast<const ColorSpaceTransform>(transform)) { BuildColorSpaceOps(ops, config, context, *colorSpaceTransform, dir); } else if(ConstDisplayTransformRcPtr displayTransform = \ DynamicPtrCast<const DisplayTransform>(transform)) { BuildDisplayOps(ops, config, context, *displayTransform, dir); } else if(ConstExponentTransformRcPtr exponentTransform = \ DynamicPtrCast<const ExponentTransform>(transform)) { BuildExponentOps(ops, config, *exponentTransform, dir); } else if(ConstFileTransformRcPtr fileTransform = \ DynamicPtrCast<const FileTransform>(transform)) { BuildFileOps(ops, config, context, *fileTransform, dir); } else if(ConstGroupTransformRcPtr groupTransform = \ DynamicPtrCast<const GroupTransform>(transform)) { BuildGroupOps(ops, config, context, *groupTransform, dir); } else if(ConstLogTransformRcPtr logTransform = \ DynamicPtrCast<const LogTransform>(transform)) { BuildLogOps(ops, config, *logTransform, dir); } else if(ConstMatrixTransformRcPtr matrixTransform = \ DynamicPtrCast<const MatrixTransform>(transform)) { BuildMatrixOps(ops, config, *matrixTransform, dir); } else if(ConstTruelightTransformRcPtr truelightTransform = \ DynamicPtrCast<const TruelightTransform>(transform)) { BuildTruelightOps(ops, config, *truelightTransform, dir); } else { std::ostringstream os; os << "Unknown transform type for Op Creation."; throw Exception(os.str().c_str()); } }
void LocalFileFormat::BuildFileOps(OpRcPtrVec & ops, const Config& config, const ConstContextRcPtr & context, CachedFileRcPtr untypedCachedFile, const FileTransform& fileTransform, TransformDirection dir) const { LocalCachedFileRcPtr cachedFile = DynamicPtrCast<LocalCachedFile>(untypedCachedFile); // This should never happen. if(!cachedFile) { std::ostringstream os; os << "Cannot build .cdl Op. Invalid cache type."; throw Exception(os.str().c_str()); } TransformDirection newDir = CombineTransformDirections(dir, fileTransform.getDirection()); if(newDir == TRANSFORM_DIR_UNKNOWN) { std::ostringstream os; os << "Cannot build ASC FileTransform,"; os << " unspecified transform direction."; throw Exception(os.str().c_str()); } // Below this point, we should throw ExceptionMissingFile on // errors rather than Exception // This is because we've verified that the cdl file is valid, // at now we're only querying whether the specified cccid can // be found. // // Using ExceptionMissingFile enables the missing looks fallback // mechanism to function properly. // At the time ExceptionMissingFile was named, we errently assumed // a 1:1 relationship between files and color corrections, which is // not true for .cdl files. // // In a future OCIO release, it may be more appropriate to // rename ExceptionMissingFile -> ExceptionMissingCorrection. // But either way, it's what we should throw below. std::string cccid = fileTransform.getCCCId(); cccid = context->resolveStringVar(cccid.c_str()); if(cccid.empty()) { std::ostringstream os; os << "You must specify which cccid to load from the ccc file"; os << " (either by name or index)."; throw ExceptionMissingFile(os.str().c_str()); } bool success=false; // Try to parse the cccid as a string id CDLTransformMap::const_iterator iter = cachedFile->transformMap.find(cccid); if(iter != cachedFile->transformMap.end()) { success = true; BuildCDLOps(ops, config, *(iter->second), newDir); } // Try to parse the cccid as an integer index // We want to be strict, so fail if leftover chars in the parse. if(!success) { int cccindex=0; if(StringToInt(&cccindex, cccid.c_str(), true)) { int maxindex = ((int)cachedFile->transformVec.size())-1; if(cccindex<0 || cccindex>maxindex) { std::ostringstream os; os << "The specified cccindex " << cccindex; os << " is outside the valid range for this file [0,"; os << maxindex << "]"; throw ExceptionMissingFile(os.str().c_str()); } success = true; BuildCDLOps(ops, config, *cachedFile->transformVec[cccindex], newDir); } } if(!success) { std::ostringstream os; os << "You must specify a valid cccid to load from the ccc file"; os << " (either by name or index). id='" << cccid << "' "; os << "is not found in the file, and is not parsable as an "; os << "integer index."; throw ExceptionMissingFile(os.str().c_str()); } }