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

#include <ls-std/core/Class.hpp>
#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
#if defined(unix) || defined(__APPLE__)
  #include <ls-std/time/system-time/PosixClock.hpp>
#endif
#include <ls-std/time/system-time/SystemTime.hpp>
#include <ls-std/time/system-time/SystemTimeParameter.hpp>
#ifdef _WIN32
  #include <ls-std/time/system-time/WindowsClock.hpp>
#endif
#include <memory>

using ls::standard::core::Class;
using ls::standard::core::NullPointerArgumentEvaluator;
using ls::standard::time::DateParameter;
#if defined(unix) || defined(__APPLE__)
using ls::standard::time::PosixClock;
#endif
using ls::standard::time::SystemTime;
using ls::standard::time::SystemTimeParameter;
#ifdef _WIN32
using ls::standard::time::WindowsClock;
#endif
using ls::standard::time::type::UnixTimestamp;
using std::make_shared;
using std::shared_ptr;
using std::string;

SystemTime::SystemTime(const shared_ptr<SystemTimeParameter> &_parameter) : Class(_fetchClassName()), parameter(_parameter)
{
  NullPointerArgumentEvaluator{_parameter}.evaluate();
}

SystemTime::SystemTime() : Class(_fetchClassName())
{
  this->_generateParameter();
}

SystemTime::~SystemTime() noexcept = default;

bool SystemTime::set(const DateParameter &_dateParameter) const
{
  return this->parameter->getClock()->setTime(_dateParameter);
}

string SystemTime::_fetchClassName()
{
  static const string className = "SystemTime";
  return className;
}

void SystemTime::_generateParameter()
{
  this->parameter = make_shared<SystemTimeParameter>();

#if defined(unix) || defined(__APPLE__)
  this->parameter->setClock(make_shared<PosixClock>());
#endif
#ifdef _WIN32
  this->parameter->setClock(make_shared<WindowsClock>());
#endif
}
