-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParameterManager.h
48 lines (40 loc) · 1.09 KB
/
ParameterManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "Osc.h"
#include <format>
enum DroneStage
{
Idle,
Sending,
Sent,
Finished,
};
class ParameterManager
{
public:
void Start();
void MoveDrone(int axis, float value);
bool IsAvailable();
template <typename T>
void SetParameter(const char* parameter, T value);
void HandleMsg(OSCPP::Server::Message const&);
private:
template <typename T>
bool CheckDuplicate(const char* parameter, T value);
private:
std::atomic<DroneStage> m_droneStage = Idle;
std::unique_ptr<Osc> m_osc{ nullptr };
std::map<std::string, std::string> m_parameters;
};
template<typename T>
inline void ParameterManager::SetParameter(const char* parameter, T value)
{
if (CheckDuplicate(parameter, value)) return;
OutputDebugStringA(std::format("SetParameter: {} {}\n", parameter, std::to_string(value)).c_str());
m_osc->SetParameter(std::format("danceCam/{}", parameter).c_str(), value);
}
template<typename T>
inline bool ParameterManager::CheckDuplicate(const char* parameter, T value)
{
auto it = m_parameters.find(parameter);
return it != m_parameters.end() && it->second == std::to_string(value);
}