Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
server.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#ifndef __ASE_SERVER_HH__
3#define __ASE_SERVER_HH__
4
5#include <ase/gadget.hh>
6#include <ase/memory.hh>
7
8namespace Ase {
9
10class ServerImpl : public GadgetImpl, public virtual Server {
11 FastMemory::Arena telemetry_arena;
12public:
13 static ServerImplP instancep ();
14 explicit ServerImpl ();
15 virtual ~ServerImpl ();
16 bool set_data (const String &key, const Value &v) override;
17 Value get_data (const String &key) const override;
18 String get_version () override;
19 String get_build_id () override;
20 String get_opus_version () override;
21 String get_flac_version () override;
22 String get_clap_version () override;
23 String get_sndfile_version () override;
24 String error_blurb (Error error) const override;
25 String musical_tuning_label (MusicalTuning musicaltuning) const override;
26 String musical_tuning_blurb (MusicalTuning musicaltuning) const override;
27 uint64 user_note (const String &text, const String &channel = "misc", UserNote::Flags flags = UserNote::TRANSIENT, const String &rest = "") override;
28 bool user_reply (uint64 noteid, uint r) override;
29 bool broadcast_telemetry (const TelemetrySegmentS &plan, int32 interval_ms) override;
30 void shutdown () override;
31 ProjectP last_project () override;
32 ProjectP create_project (String projectname) override;
33 PropertyP access_preference (const String &ident) override;
34 StringS list_preferences () override;
36 Block telemem_allocate (uint32 length) const;
37 void telemem_release (Block telememblock) const;
38 ptrdiff_t telemem_start () const;
39};
40extern ServerImpl *SERVER;
41
42// static constexpr const char* telemetry_type (const int64 &field) { return "i64"; }
43static constexpr const char* telemetry_type (const int8 &field) { return "i8"; }
44static constexpr const char* telemetry_type (const int32 &field) { return "i32"; }
45static constexpr const char* telemetry_type (const float &field) { return "f32"; }
46static constexpr const char* telemetry_type (const double &field) { return "f64"; }
47
48template<class T> inline TelemetryField
49telemetry_field (const String &name, const T *field)
50{
51 auto start = ServerImpl::instancep()->telemem_start();
52 const ptrdiff_t offset = ptrdiff_t (field) - start;
53 ASE_ASSERT_RETURN (offset >= 0 && offset < 2147483647, {}); // INT_MAX
54 TelemetryField tfield { name, telemetry_type (*field), int32 (offset), sizeof (*field) };
55 return tfield;
56}
57
58} // Ase
59
60#endif // __ASE_SERVER_HH__
Base type for classes that have a Property.
Definition gadget.hh:12
String get_clap_version() override
Retrieve CLAP support version.
Definition server.cc:76
String get_flac_version() override
Retrieve FLAC handler version.
Definition server.cc:70
String get_build_id() override
Retrieve ASE build id.
Definition server.cc:58
Value get_data(const String &key) const override
Retrieve session data.
Definition server.cc:141
ProjectP last_project() override
Retrieve the last created project.
Definition server.cc:95
PropertyP access_preference(const String &ident) override
Retrieve property handle for a Preference identifier.
Definition server.cc:114
StringS list_preferences() override
Retrieve a list of all preference identifiers.
Definition server.cc:107
ProjectP create_project(String projectname) override
Create a new project (name is modified to be unique if necessary.
Definition server.cc:101
String get_version() override
Retrieve ASE version.
Definition server.cc:52
void shutdown() override
Shutdown ASE.
Definition server.cc:88
String get_sndfile_version() override
Retrieve libsndfile support version.
Definition server.cc:82
bool broadcast_telemetry(const TelemetrySegmentS &plan, int32 interval_ms) override
Broadcast telemetry memory segments to the current Jsonipc connection.
Definition server.cc:481
String get_opus_version() override
Retrieve Opus handler version.
Definition server.cc:64
bool set_data(const String &key, const Value &v) override
Assign session data, prefix ephemerals with '_'.
Definition server.cc:127
Central singleton, serves as API entry point.
Definition api.hh:400
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
Definition cxxaux.hh:82
The Anklang C++ API namespace.
Definition api.hh:9
uint64_t uint64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:25
int32_t int32
A 32-bit signed integer.
Definition cxxaux.hh:28
int8_t int8
An 8-bit signed integer.
Definition cxxaux.hh:26
Error
Enum representing Error states.
Definition api.hh:22
std::string String
Convenience alias for std::string.
Definition cxxaux.hh:35
uint32_t uint32
A 32-bit unsigned integer.
Definition cxxaux.hh:24
uint32_t uint
Provide 'uint' as convenience type.
Definition cxxaux.hh:18
MusicalTuning
Musical tunings, see: http://en.wikipedia.org/wiki/Musical_tuning.
Definition api.hh:83
Memory area (over-)aligned to cache size and utilizing huge pages.
Definition memory.hh:100
Reference for an allocated memory block.
Definition memory.hh:90
Value type used to interface with various property types.
Definition value.hh:54