/*
 * This file defines the Results and TypedResults structs,
 * which are used to return the results from each compression and/or decompression operation.
 */

#pragma once

#include <cstddef>
#include <map>
#include <string>
#include <limits>
#include <vector>

namespace atc {

	/// This struct is used to return the results of compression and/or decompression operations.
	struct Results {
		/// Compressed data, set during compression when compressing to an ``std::vector<char>``.
		std::vector<char> compressed_data;
		/// Size of compressed object in bytes. Set during compression.
		size_t compressed_size = 0;
		/// The size of the original data divided by the size of the compressed object. Set during compression.
		double compression_factor = 0;
		/// Mode sizes of the decompressed output tensor. Set during decompression.
		std::vector<size_t> decompressed_sizes;
		/**
		 * Actual error after compression/decompression, expressed in the error metric determined by the option ``error_metric``.
		 * Calculated and stored only when requested during ``compress_decompress`` using the option ``calculate_error``.
		 */
		double error = std::numeric_limits<double>::quiet_NaN();
		/// Map of labeled timings, stored in seconds. Set during compression and/or decompression when the option ``timings`` is enabled.
		std::map<std::string, double> timings;
	};
	
	/// This struct extends `atc::Results` with an ``std::vector<dtype>`` field and is used when decompressing to an ``std::vector<dtype>``.
	template<typename dtype>
	struct TypedResults : public Results {
		/// Create a `atc::TypedResults` object using a copy of a base `atc::Results` object.
		TypedResults(const Results& results) : Results(results) {}
		/// Decompressed data, set during decompression when decompressing to an ``std::vector<dtype>``.
		std::vector<dtype> decompressed_data;
	};
	
}
