Base template class for user-defined stream providers that can be used during file parsing or formatting. More...
#include <cadex/Base_FileStreamProvider.hxx>
Inherited by cadex::internal::Base_IFileStreamProvider.
Public Member Functions | |
virtual | ~Base_StreamProvider () |
Destructor. | |
virtual bool | IsOpen () const =0 |
Returns true if the underlying stream has been successfully open and is available for access. | |
virtual T & | Stream ()=0 |
Returns underlying stream. | |
virtual void | Open (const Base_UTF16String &theFileName)=0 |
Opens the stream per its file name. | |
virtual void | Close ()=0 |
Closes the stream. | |
Base template class for user-defined stream providers that can be used during file parsing or formatting.
An instance of provider is created by Base_StreamProviderFactory which is supplied into Base_Reader::ReadFile().
Template instantiation Base_IStreamProvider instantiates a provider for input streams (std::istream).
Provider's lifespan can be large enough so the stream must remain valid throughout lifespan of the provider that provides it. The stream may be closed and reopened again during life-span. Thus, it should not be closed earlier than in the destructor.
The redefined virtual methods may be called by CAD Exchanger SDK once or multiple times for every file name, custom implementation should not make any assumptions on the number or timing of calls.
Subclasses should provide specific implementation to encapsulate stream objects (in the form of std::istream) for a particular data storage (e.g. cloud). This approach can be specifically useful when working with files with external references (such as JT) residing in specific data storage.
Below is a sample implementation:
|
inlinevirtual |
Destructor.
Subclasses should typically close the stream here (e.g. by destroying an object wrapping the stream).
|
pure virtual |
Closes the stream.
This method will only be called if the stream needs to be closed (e.g. to reduce the number of simultaneously open files in Operating System) but the stream itself could be used later on. This may happen for instance when parsing JT files when each JT file contains multiple data segments which will be parsed at different moments on 'as needed' basis.
|
pure virtual |
Returns true if the underlying stream has been successfully open and is available for access.
This method is guaranteed to be called before Stream().
|
pure virtual |
Opens the stream per its file name.
This method will only be called if either the provider has been created by the factory without specified file name or if the stream has been closed with the Close() method.
|
pure virtual |
Returns underlying stream.
This method will only be called if IsOpen() returned true.