MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
mostlyharmless_ISharedState.h
Go to the documentation of this file.
1//
2// Created by Syl Morrison on 20/10/2024.
3//
4
5#ifndef MOSTLYHARMLESS_MOSTLYHARMLESS_ISHAREDSTATE_H
6#define MOSTLYHARMLESS_MOSTLYHARMLESS_ISHAREDSTATE_H
7#include <mostly_harmless/core/mostlyharmless_SharedStateContext.h>
10#include <marvin/containers/marvin_FIFO.h>
11#include <vector>
12#include <unordered_map>
13namespace mostly_harmless::core {
14
27 public:
34 explicit ISharedState(SharedStateContext&& context, std::vector<Parameter<float>>&& params);
35
39 virtual ~ISharedState() noexcept = default;
40
46 [[nodiscard]] std::span<Parameter<float>> getRawParameterView() noexcept;
47
53 [[nodiscard]] Parameter<float>* getParameterByIndex(std::uint32_t index) noexcept;
54
59 [[nodiscard]] Parameter<float>* getParameterById(mostly_harmless::ParameterID parameterId);
60
66 [[nodiscard]] Parameter<float>* getParameterById(std::uint32_t pid);
67
72 [[nodiscard]] std::uint32_t getNumParams() const noexcept;
73
78 virtual void loadState(std::string_view loadedData) = 0;
79
84 virtual void saveState(std::ostringstream& dest) = 0;
85
90 [[nodiscard]] marvin::containers::fifos::MPMC<events::ProcToGuiParamEvent>& getProcToGuiQueue() noexcept;
91
96 [[nodiscard]] marvin::containers::fifos::SPSC<events::GuiToProcParamEvent>& getGuiToProcQueue() noexcept;
97
102 void runOnMainThread(std::function<void(void)>&& toRun) const;
103
107 void requestParamFlush() const;
108
112 void rescanParams() const;
113
114 private:
115 SharedStateContext m_context;
116 std::vector<Parameter<float>> m_params;
117 std::unordered_map<std::uint32_t, Parameter<float>*> m_paramLookup;
118 marvin::containers::fifos::MPMC<events::ProcToGuiParamEvent> m_procToGuiQueue;
119 marvin::containers::fifos::SPSC<events::GuiToProcParamEvent> m_guiToProcQueue;
120 };
121
122
123} // namespace mostly_harmless::core
124#endif // MOSTLYHARMLESS_MOSTLYHARMLESS_ISHAREDSTATE_H
marvin::containers::fifos::SPSC< events::GuiToProcParamEvent > & getGuiToProcQueue() noexcept
virtual void loadState(std::string_view loadedData)=0
Parameter< float > * getParameterById(mostly_harmless::ParameterID parameterId)
ISharedState(SharedStateContext &&context, std::vector< Parameter< float > > &&params)
std::span< Parameter< float > > getRawParameterView() noexcept
virtual ~ISharedState() noexcept=default
Parameter< float > * getParameterByIndex(std::uint32_t index) noexcept
std::uint32_t getNumParams() const noexcept
void runOnMainThread(std::function< void(void)> &&toRun) const
marvin::containers::fifos::MPMC< events::ProcToGuiParamEvent > & getProcToGuiQueue() noexcept
virtual void saveState(std::ostringstream &dest)=0
Contains core functionality of the framework.
Definition mostlyharmless_PluginBase.h:15
Contains classes and functions related to events.
Definition mostlyharmless_InputEventContext.h:4
The top-level namespace, contains all things plugin-related.
Definition mostlyharmless_BusConfig.h:3
Convenience class for generating a parameter id.
Definition mostlyharmless_Parameters.h:15
Container class for a single parameter.
Definition mostlyharmless_Parameters.h:41