/*
 * Author:          Patrick-Christopher Mattulat
 * Co-Author:       Claude Sonnet 4.6 (LLM)
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2020-08-19
 * Changed:         2026-06-23
 *
 * */

#ifndef LS_STD_STORABLE_FILE_HPP
#define LS_STD_STORABLE_FILE_HPP

#include "File.hpp"
#include <ls-std/core/interface/IStorable.hpp>
#include <ls-std/os/dynamic-goal.hpp>
#include <memory>
#include <string>

/*
 * @doc: class(name: 'StorableFile', package: 'io')
 * @doc: io.StorableFile.description('This class can be used to store any serialized information to a file.')
 * */

namespace ls::standard::io
{
  class LS_STD_DYNAMIC_GOAL StorableFile : public ls::standard::core::interface_type::IStorable
  {
    public:

      explicit StorableFile(const ::std::string &_path);
      ~StorableFile() noexcept override;

      [[nodiscard]] ::std::shared_ptr<ls::standard::io::File> getFile() const;
      [[nodiscard]] ls::standard::core::type::byte_field load() override;
      void reset(const ::std::string &_path);
      void save(const ls::standard::core::type::byte_field &_data) override;

    private:

      ::std::shared_ptr<ls::standard::io::File> file{};

      void _init(const ::std::string &_path);
  };
}

#endif
