2025-12-28 03:54:22 -04:00
|
|
|
#ifndef COMPONENT_H
|
|
|
|
|
#define COMPONENT_H
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <spinscale/callback.h>
|
|
|
|
|
#include <spinscale/puppetApplication.h>
|
|
|
|
|
|
|
|
|
|
namespace sscl {
|
|
|
|
|
|
|
|
|
|
class ComponentThread;
|
2026-02-18 02:03:19 -04:00
|
|
|
class PuppetThread;
|
|
|
|
|
|
|
|
|
|
/** EXPLANATION:
|
|
|
|
|
* Components are API-exposing sub-components of an application. They are used
|
|
|
|
|
* aggregate the resources and API of some logically distinct sub-system into
|
|
|
|
|
* a single abstract entity. Basically, a component is a way to bind some APIs
|
|
|
|
|
* and resources to a particular thread. Ideally, all accesses to the resources
|
|
|
|
|
* of a component should be made through the component's APIs.
|
|
|
|
|
*
|
|
|
|
|
* Multiple components can share the same thread; and for this reason, each
|
|
|
|
|
* component must be supplied with a reference to the thread it shares.
|
|
|
|
|
* This amounts to saying that a single thread may expose and serve multiple
|
|
|
|
|
* APIs.
|
|
|
|
|
*/
|
2025-12-28 03:54:22 -04:00
|
|
|
class Component
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Component(const std::shared_ptr<ComponentThread> &thread);
|
|
|
|
|
~Component() = default;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
std::shared_ptr<ComponentThread> thread;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PuppetComponent
|
|
|
|
|
: public Component
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PuppetComponent(
|
|
|
|
|
PuppetApplication &parent,
|
2026-02-18 02:03:19 -04:00
|
|
|
const std::shared_ptr<PuppetThread> &thread);
|
2025-12-28 03:54:22 -04:00
|
|
|
~PuppetComponent() = default;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
PuppetApplication &parent;
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-19 19:53:41 -04:00
|
|
|
namespace pptr {
|
|
|
|
|
|
|
|
|
|
class PuppeteerComponent
|
|
|
|
|
: public Component
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PuppeteerComponent(const std::shared_ptr<PuppeteerThread> &thread);
|
|
|
|
|
~PuppeteerComponent() = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace pptr
|
|
|
|
|
|
2025-12-28 03:54:22 -04:00
|
|
|
} // namespace sscl
|
|
|
|
|
|
|
|
|
|
#endif // COMPONENT_H
|