Sygaldry
Loading...
Searching...
No Matches
sygbp-output_logger.hpp
1/*
2Copyright 2023 Travis J. West, https://traviswest.ca, Input Devices and Music Interaction Laboratory
3(IDMIL), Centre for Interdisciplinary Research in Music Media and Technology
4(CIRMMT), McGill University, Montréal, Canada, and Univ. Lille, Inria, CNRS,
5Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
6
7SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11#include "sygbp-spelling.hpp"
12#include "sygac-metadata.hpp"
13#include "sygac-components.hpp"
14#include "sygah-metadata.hpp"
15#include "sygbp-osc_string_constants.hpp"
16#include "sygup-cstdio_logger.hpp"
17
18namespace sygaldry { namespace sygbp {
23
24template<typename Logger, typename Components>
25struct OutputLogger : name_<"Output Logger">
26{
27 struct inputs_t {} inputs;
28
29 [[no_unique_address]] Logger log;
30
31 void external_destinations(Components& components)
32 {
33 for_each_output(components, [&]<typename T>(T& current_out)
34 {
35 if constexpr (Bang<T> || OccasionalValue<T>)
36 {
37 if (not flag_state_of(current_out)) return;
38 log.println(osc_path_v<T, Components>);
39 }
40 else if constexpr (requires (T t) {current_out == t;})
41 {
42 static T last_out{};
43 if (value_of(current_out) == value_of(last_out)) return;
44 last_out = current_out;
45 log.print(osc_path_v<T, Components>);
46 if constexpr (has_value<T>)
47 log.print(" ", value_of(current_out));
48 log.println();
49 }
50 else return;
51 });
52 }
53};
54
55template<typename Components> using CstdioOutputLogger = OutputLogger<sygup::CstdioLogger, Components>;
56
59} }
Definition sygac-endpoints.hpp:92
Definition sygac-endpoints.hpp:90
Document the name of an entity, e.g. an endpoint, component, or binding.
Definition sygah-metadata.hpp:33
Definition sygbp-output_logger.hpp:27
Definition sygbp-output_logger.hpp:26