10class SignalSourceContainer;
45 return safe_any_cast<T>(it->second);
46 }
catch (
const std::bad_any_cast&) {
75 return static_cast<FileReadOptions>(
static_cast<uint32_t
>(a) |
static_cast<uint32_t
>(b));
80 return static_cast<FileReadOptions>(
static_cast<uint32_t
>(a) &
static_cast<uint32_t
>(b));
129 [[nodiscard]]
virtual bool can_read(
const std::string& filepath)
const = 0;
148 [[nodiscard]]
virtual bool is_open()
const = 0;
154 [[nodiscard]]
virtual std::optional<FileMetadata>
get_metadata()
const = 0;
166 [[nodiscard]]
virtual std::vector<FileRegion>
get_regions()
const = 0;
172 virtual std::vector<Kakshya::DataVariant>
read_all() = 0;
211 virtual bool seek(
const std::vector<uint64_t>& position) = 0;
269 static std::unordered_map<std::string, Kakshya::RegionGroup>
301 for (
const auto& ext : extensions) {
311 std::unique_ptr<FileReader>
create_reader(
const std::string& filepath)
const
313 auto ext = std::filesystem::path(filepath).extension().string();
314 if (!ext.empty() && ext[0] ==
'.') {
std::unique_ptr< FileReader > create_reader(const std::string &filepath) const
Create appropriate reader for a file based on extension.
static FileReaderRegistry & instance()
Get the singleton instance of the registry.
void register_reader(const std::vector< std::string > &extensions, const FileReaderFactory &factory)
Register a file reader factory for one or more extensions.
std::unordered_map< std::string, FileReaderFactory > m_factories
Registry for file reader implementations.
virtual bool open(const std::string &filepath, FileReadOptions options=FileReadOptions::ALL)=0
Open a file for reading.
virtual std::vector< std::string > get_supported_extensions() const =0
Get supported file extensions for this reader.
virtual bool seek(const std::vector< uint64_t > &position)=0
Seek to a specific position in the file.
virtual std::vector< FileRegion > get_regions() const =0
Get semantic regions from the file.
virtual std::type_index get_container_type() const =0
Get the container type this reader creates.
virtual std::vector< uint64_t > get_dimension_sizes() const =0
Get size of each dimension in the file data.
virtual ~FileReader()=default
virtual std::vector< Kakshya::DataVariant > read_all()=0
Read all data from the file into memory.
virtual bool supports_streaming() const =0
Check if streaming is supported for the current file.
virtual size_t get_num_dimensions() const =0
Get the dimensionality of the file data.
virtual uint64_t get_preferred_chunk_size() const =0
Get the preferred chunk size for streaming.
virtual std::vector< Kakshya::DataVariant > read_region(const FileRegion ®ion)=0
Read a specific region of data.
virtual bool can_read(const std::string &filepath) const =0
Check if a file can be read by this reader.
static std::unordered_map< std::string, Kakshya::RegionGroup > regions_to_groups(const std::vector< FileRegion > ®ions)
Convert file regions to region groups.
virtual std::string get_last_error() const =0
Get the last error message.
virtual std::optional< FileMetadata > get_metadata() const =0
Get metadata from the open file.
virtual bool is_open() const =0
Check if a file is currently open.
virtual void close()=0
Close the currently open file.
virtual std::shared_ptr< Kakshya::SignalSourceContainer > create_container()=0
Create and initialize a container from the file.
virtual bool load_into_container(std::shared_ptr< Kakshya::SignalSourceContainer > container)=0
Load file data into an existing container.
virtual std::type_index get_data_type() const =0
Get the data type this reader produces.
virtual std::vector< uint64_t > get_read_position() const =0
Get current read position in primary dimension.
Abstract interface for reading various file formats into containers.
std::function< std::unique_ptr< FileReader >()> FileReaderFactory
FileReadOptions
Generic options for file reading behavior.
@ EXTRACT_METADATA
Extract file metadata.
@ ALL
All options enabled.
@ HIGH_PRECISION
Use highest precision available.
@ EXTRACT_REGIONS
Extract semantic regions (format-specific)
@ NONE
No special options.
@ STREAMING
Enable streaming mode.
@ PARSE_STRUCTURE
Parse internal structure.
@ DECOMPRESS
Decompress if compressed.
@ VERIFY_INTEGRITY
Verify file integrity/checksums.
@ LAZY_LOAD
Don't load all data immediately.
FileReadOptions operator&(FileReadOptions a, FileReadOptions b)
FileReadOptions operator|(FileReadOptions a, FileReadOptions b)
std::vector< uint64_t > start_coordinates
N-dimensional start position (e.g., frame, x, y)
Kakshya::Region to_region() const
Convert this FileRegion to a Region for use in processing.
std::string name
Human-readable name for the region.
std::string type
Region type identifier (e.g., "cue", "scene", "block")
std::unordered_map< std::string, std::any > attributes
Region-specific metadata.
std::vector< uint64_t > end_coordinates
N-dimensional end position (inclusive)
Generic region descriptor for any file type.
Represents a point or span in N-dimensional space.