Add timeline manager

This commit is contained in:
Dan Paulat 2023-05-14 08:36:21 -05:00
parent 5453997208
commit 81eb3b1af3
3 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,48 @@
#include <scwx/qt/manager/timeline_manager.hpp>
#include <scwx/util/logger.hpp>
namespace scwx
{
namespace qt
{
namespace manager
{
static const std::string logPrefix_ = "scwx::qt::manager::timeline_manager";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class TimelineManager::Impl
{
public:
explicit Impl(TimelineManager* self) : self_ {self} {}
~Impl() {}
TimelineManager* self_;
};
TimelineManager::TimelineManager() : p(std::make_unique<Impl>(this)) {}
TimelineManager::~TimelineManager() = default;
std::shared_ptr<TimelineManager> TimelineManager::Instance()
{
static std::weak_ptr<TimelineManager> timelineManagerReference_ {};
static std::mutex instanceMutex_ {};
std::unique_lock lock(instanceMutex_);
std::shared_ptr<TimelineManager> timelineManager =
timelineManagerReference_.lock();
if (timelineManager == nullptr)
{
timelineManager = std::make_shared<TimelineManager>();
timelineManagerReference_ = timelineManager;
}
return timelineManager;
}
} // namespace manager
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,31 @@
#pragma once
#include <memory>
#include <QObject>
namespace scwx
{
namespace qt
{
namespace manager
{
class TimelineManager : public QObject
{
Q_OBJECT
public:
explicit TimelineManager();
~TimelineManager();
static std::shared_ptr<TimelineManager> Instance();
private:
class Impl;
std::unique_ptr<Impl> p;
};
} // namespace manager
} // namespace qt
} // namespace scwx