libASPL
Loading...
Searching...
No Matches
Context.hpp
Go to the documentation of this file.
1// Copyright (c) libASPL authors
2// Licensed under MIT
3
4//! @file aspl/Context.hpp
5//! @brief Context.
6
7#pragma once
8
9#include <aspl/Dispatcher.hpp>
10#include <aspl/Tracer.hpp>
11
12#include <CoreAudio/AudioServerPlugIn.h>
13
14#include <atomic>
15#include <memory>
16
17namespace aspl {
18
19//! Common object context.
20//! Shared between objects which belong to the same driver.
21struct Context
22{
23 //! Object dispatcher.
24 //! Maps object identifiers to objects.
25 //! Object ID is unique within a dispatcher.
26 const std::shared_ptr<Dispatcher> Dispatcher;
27
28 //! Object operation tracer.
29 //! All objects use it for logging.
30 const std::shared_ptr<Tracer> Tracer;
31
32 //! Plugin host.
33 //! Contains method table of HAL.
34 //! Initially host is null. It is set during plugin initialization.
35 std::atomic<AudioServerPlugInHostRef> Host = nullptr;
36
37 //! Create context.
38 //! If dispatcher or tracer is not specified, default one is created.
39 //! Default tracer sends output to syslog.
40 explicit Context(std::shared_ptr<aspl::Tracer> tracer = {},
41 std::shared_ptr<aspl::Dispatcher> dispatcher = {})
42 : Dispatcher(
43 dispatcher ? std::move(dispatcher) : std::make_shared<aspl::Dispatcher>())
44 , Tracer(tracer ? std::move(tracer) : std::make_shared<aspl::Tracer>())
45 {
46 }
47};
48
49} // namespace aspl
Object dispatcher.
Operation tracer.
Common object context. Shared between objects which belong to the same driver.
Definition Context.hpp:22
Context(std::shared_ptr< aspl::Tracer > tracer={}, std::shared_ptr< aspl::Dispatcher > dispatcher={})
Create context. If dispatcher or tracer is not specified, default one is created. Default tracer send...
Definition Context.hpp:40
const std::shared_ptr< Tracer > Tracer
Object operation tracer. All objects use it for logging.
Definition Context.hpp:30
std::atomic< AudioServerPlugInHostRef > Host
Plugin host. Contains method table of HAL. Initially host is null. It is set during plugin initializa...
Definition Context.hpp:35
const std::shared_ptr< Dispatcher > Dispatcher
Object dispatcher. Maps object identifiers to objects. Object ID is unique within a dispatcher.
Definition Context.hpp:26