59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
namespace Echoion::Api
|
|
{
|
|
|
|
// Opaque handle types to avoid including full headers
|
|
// These are used in interfaces to break dependencies
|
|
|
|
// Forward declarations for Core types (Plugin never needs full definition)
|
|
struct AppConfig;
|
|
struct HotReloadState;
|
|
struct PlaybackState;
|
|
struct TrackInfo;
|
|
struct QueueEntry;
|
|
|
|
// Opaque handle wrapper - type-safe void pointer replacement
|
|
template <typename T> class OpaqueHandle
|
|
{
|
|
public:
|
|
|
|
OpaqueHandle() = default;
|
|
explicit OpaqueHandle(std::shared_ptr<T> ptr) : ptr_(std::move(ptr))
|
|
{
|
|
}
|
|
|
|
[[nodiscard]] bool isValid() const { return ptr_ != nullptr; }
|
|
[[nodiscard]] T* get() const { return ptr_.get(); }
|
|
[[nodiscard]] T& operator*() const { return *ptr_; }
|
|
[[nodiscard]] T* operator->() const { return ptr_.get(); }
|
|
|
|
void reset() { ptr_.reset(); }
|
|
void reset(T* ptr) { ptr_.reset(ptr); }
|
|
|
|
[[nodiscard]] std::shared_ptr<T> toSharedPtr() const
|
|
{
|
|
return ptr_;
|
|
}
|
|
|
|
private:
|
|
|
|
std::shared_ptr<T> ptr_;
|
|
};
|
|
|
|
// Specific handle types
|
|
using AppConfigHandle = OpaqueHandle<AppConfig>;
|
|
using HotReloadStateHandle = OpaqueHandle<HotReloadState>;
|
|
using PlaybackStateHandle = OpaqueHandle<PlaybackState>;
|
|
using TrackInfoHandle = OpaqueHandle<TrackInfo>;
|
|
using QueueEntryHandle = OpaqueHandle<QueueEntry>;
|
|
|
|
// Serialization helpers for cross-boundary communication
|
|
using SerializedConfig = std::string; // JSON string
|
|
using SerializedState = std::string; // JSON string
|
|
|
|
} // namespace Echoion::Api
|