#pragma once

#include "trackDefs.h"

#include <chrono>
#include <cstdint>
#include <filesystem>
#include <mutex>
#include <span>
#include <string>
#include <vector>

namespace track
{
//--------------------------------------------------------------
class Track
{
  friend class TrackLockProxy;     // Allow TrackLockProxy to access private members of Track

  public:
  Track()                                = default;     // Default constructor
  virtual ~Track()                       = default;     // Default destructor
  Track(const Track &obj)                = default;     // Copy constructor
  Track(Track &&obj) noexcept            = default;     // Move constructor
  Track &operator=(const Track &obj)     = default;     // Copy assignment operator
  Track &operator=(Track &&obj) noexcept = default;     // Move assignment operator

  void logInfo(const std::string &message) const;      // Log an informational message
  void logError(const std::string &message) const;     // Log an error message

  void                  loadFromFile(const std::filesystem::path &filePath);     // Load a MIDI file from disk
  void                  loadFromMemory(std::span<uint8_t> midiBytes);            // Load a MIDI file from memory
  [[nodiscard]] bool    isEmpty() const;                                         // Check if a MIDI file is loaded
  [[nodiscard]] Seconds getDuration() const;                                     // Get the duration of the track

  void debug() const;     // Debug function to print the track data

  protected:
  NotesBuffer m_notes;     // Vector to store notes
};
//--------------------------------------------------------------
}     // namespace track
