#pragma once

#include "fs/IStreamSource.h"
#include "fs/Api.h"
#include "tl/flag_set2.h"

namespace fs
{

//Design rationale:
// Sources are throw-away objects representing a data source or sink (the Sink).
// They are not supposed to be reused. 
// There is only one owner of the source, enforced by the tl::unique_ref wrapper. Due to this, sources are NOT thread safe.
// There is no open/close for sources as the open is done in the constructor and close in the destructor. This is to reinforce the idea of throw-away objects.
// If you need a persistent source to be able to reload your data, hold a 
//		path to the source instead of the source. This is to allow the underlying file system to change (due to DLC for example). When you need the source again, request a new one from the file system.

class FS_API ISource : public IStreamSource
{
public:
	enum class Flag : uint8_t
	{
		Unbuffered,
		Uncached,
		SequentialHint, //takes prio over the random hint flag
		RandomHint,
	};
	typedef tl::flag_set2<Flag> Flags;

	ISource() = default;
	~ISource() override = default;

	ISource(ISource&&) = default;
	ISource& operator=(ISource&&) = default;

	//Changes the cursor either to an absolute offset or a relative one
	virtual void seekBeg(uint64_t offset) = 0;
	virtual void seekRel(int64_t offset) = 0;

	//returns the current cursor position. This is always between 0 and size
	virtual uint64_t tell() const = 0;

	//returns the size of the source in bytes
	virtual uint64_t getSize() const = 0;
};

}
