Refactor services into classes (#183)
This commit is contained in:
committed by
GitHub
parent
bb7e79886f
commit
3be251d8fb
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "service/ServiceContext.h"
|
||||
#include "service/Service.h"
|
||||
|
||||
namespace tt::service {
|
||||
|
||||
@@ -9,19 +10,21 @@ class ServiceInstance : public ServiceContext {
|
||||
private:
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Normal);
|
||||
const service::ServiceManifest& manifest;
|
||||
std::shared_ptr<void> data = nullptr;
|
||||
std::shared_ptr<const ServiceManifest> manifest;
|
||||
std::shared_ptr<Service> service;
|
||||
|
||||
public:
|
||||
|
||||
explicit ServiceInstance(const service::ServiceManifest& manifest);
|
||||
explicit ServiceInstance(std::shared_ptr<const service::ServiceManifest> manifest);
|
||||
~ServiceInstance() override = default;
|
||||
|
||||
/** @return a reference ot the service's manifest */
|
||||
const service::ServiceManifest& getManifest() const override;
|
||||
std::shared_ptr<void> getData() const override;
|
||||
void setData(std::shared_ptr<void> newData) override;
|
||||
|
||||
/** Retrieve the paths that are relevant to this service */
|
||||
std::unique_ptr<Paths> getPaths() const override;
|
||||
|
||||
std::shared_ptr<Service> getService() const { return service; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ class ServiceInstancePaths final : public Paths {
|
||||
|
||||
private:
|
||||
|
||||
const ServiceManifest& manifest;
|
||||
std::shared_ptr<const ServiceManifest> manifest;
|
||||
|
||||
public:
|
||||
|
||||
explicit ServiceInstancePaths(const ServiceManifest& manifest) : manifest(manifest) {}
|
||||
explicit ServiceInstancePaths(std::shared_ptr<const ServiceManifest> manifest) : manifest(std::move(manifest)) {}
|
||||
~ServiceInstancePaths() final = default;
|
||||
|
||||
std::string getDataDirectory() const final;
|
||||
|
||||
Reference in New Issue
Block a user