Each result or metadata provider of a plugin needs to access file or solver sources. This data access is done through the DataSources (file path container) or the Streams (class having access to the result files and keeping cached data) input pins. But even when a DataSources is connected instead of a Streams, the first step in the Operator implementation is to transform the DataSources into a Streams instance, since the Stream is the only instance allowed to actually open and access the result file.

To create a Streams from the DataSources when reading an Operator's input pins, use:

CustomStream* GetStream(ansys::dpf::OperatorMain& main, ansys::dpf::Streams& streams)
	{
		if (main.testInput<ansys::dpf::Streams>(ansys::dpf::eStreamPin))
			streams = main.getInputStreams(ansys::dpf::eStreamPin);
		else if (main.testInput<ansys::dpf::DataSources>(ansys::dpf::eDataSourcesPin)) {
			ansys::dpf::DataSources data_sources = main.getInputDataSources(ansys::dpf::eDataSourcesPin);
			ansys::dpf::Operator op("stream_provider");
			op.connect(ansys::dpf::eDataSourcesPin, data_sources);
			streams = op.getOutputStreams(0);
		}

		// TO DO: rename "custom" to the real file extension
		return streams.getExternalStream<CustomStream>("custom");
	}

Often accessed data on the result file can be cached in the Stream to prohibit from rereading the same data several times. The Stream's cache can be implemented as followed:

class CustomStream : ansys::dpf::ExternalStream
	{
	private:

		/// @details Example to cache some data that can be recovered from one operator to
		/// another. File indexing pointers, mesh, time freq support can be cached to improve performances.
		/// Large results data should NOT be cached to not get too high in memory.
		/// TO DO: rename.
		struct CustomStreamCache
		{
			ansys::dpf::MeshedRegion _mesh; ///TO DO : keep only one of _mesh or _meshes
			ansys::dpf::MeshesContainer _meshes; ///TO DO : keep only one of _mesh or _meshes
			ansys::dpf::TimeFreqSupport _time_freq_support;
			ansys::dpf::ResultInfo _result_info;
			ansys::dpf::UnitSytem _unit_system;
			bool _is_adaptive; ///TO DO: remove if not necessary
			// ... /// TO DO: add file indexing and other potentially missing data.

			CustomStreamCache();
			void clear();
		};
		std::shared_ptr<CustomReaderInstance> _reader;
		CustomStreamCache _cache;
};