// Copyright (c) 2011 The Foundry Visionmongers Ltd. All Rights Reserved. #ifndef DDImage_DeepRead_h #define DDImage_DeepRead_h #include "DDImage/FileRead.h" #include "DDImage/DeepOp.h" #include "DDImage/ReaderDescription.h" #include "DDImage/MetaData.h" #include "DDImage/DeepReader.h" #include "DDImage/FileOp.h" #include "DDImage/Thread.h" #include "DDImage/Read.h" namespace DD { namespace Image { class DeepReader; class DeepReaderFormat; /** * This is a DeepRead node, that produces Deep data from a file. It * uses subclasses of DeepReader (implemented in plugins) to read the * various formats. * * This interface is not finalized. */ class DeepRead : public DeepReaderOwner, public DeepOnlyOp, public FileRead, public FileOp, public ReadFileKnobOwner { public: DeepRead(Node* node); private: DeepReader* _reader; std::string _readerFilename; DD::Image::Hash _readerHash; //! pointer to DeepReaderFormat (which handles file-format-specific knbos) DeepReaderFormat* _fileformat; std::string _filename; DD::Image::OutputContext _readerContext; const DeepReader::Description* _readerType; const char* _filetype; ReadWriteLock _readerLock; const Format* _formatHint; FormatPair _formatPair; int _outputType; int _first; int _last; MetaData::Bundle _meta; //! make a DeepReader object based upon the filename, and set it to _reader void makeReader(const std::string& filename); //! make a DeepReaderFormat object based upon the filename. void makeFormat(); const DD::Image::OutputContext& readerOutputContext() const { return _readerContext; } void readerInternalError(const char *fmt, ... ) { va_list v; va_start(v, fmt); internalErrorV(fmt, v ); va_end(v); } //! get the firstOp, as a DeepRead DeepRead* firstRead() { return dynamic_cast(firstOp()); } //! get the firstOp, as a DeepRead const DeepRead* firstRead() const { return dynamic_cast(firstOp()); } void expectedFrameRange(int first, int last); void setReadFormat(const DD::Image::Format* format); void setFullSizeFormat(const DD::Image::Format*); const Format* formatHint() const; void setFormat(const DD::Image::Format* form); FormatPair& getFormats(); const Format* getReadFormat() const { return NULL; } bool videosequence() const; void force_near_frame(bool); void frame_for_reader(int); void output_type(int); virtual void append(Hash& hash); virtual void knobs(Knob_Callback); virtual const MetaData::Bundle& _fetchMetaData(const char* keyname); //! implementation of function for FileOp::replace_knobs Op* op() { return this; } //! implementation of function for FileOp::replace_knobs const char* file_type() const { return _filetype; } //! implementation of function for FileOp::replace_knobs FileHandler* handler() const { return firstRead()->_fileformat; } //! handle change of "file" knob int knob_changed(Knob*); virtual void _validate(bool forReal); virtual void _open(); virtual bool doDeepEngine(DD::Image::Box, const DD::Image::ChannelSet&, DD::Image::DeepOutputPlane&); virtual void getDeepRequests(DD::Image::Box, const DD::Image::ChannelSet&, int, std::vector&) { } void close(); const char* getFilename() const; const char* Class() const; const char* node_help() const; static const Op::Description d; }; } } #endif