Cleanup
[carla.git] / source / backend / engine / CarlaEngineClient.hpp
blob7beb467077dad7b1765e34ec679e73a6dfc2a6d3
1 /*
2 * Carla Plugin Host
3 * Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_ENGINE_CLIENT_HPP_INCLUDED
19 #define CARLA_ENGINE_CLIENT_HPP_INCLUDED
21 #include "CarlaEngine.hpp"
22 #include "CarlaEnginePorts.hpp"
23 #include "CarlaPlugin.hpp"
25 #include "CarlaStringList.hpp"
27 CARLA_BACKEND_START_NAMESPACE
29 // -----------------------------------------------------------------------
30 // Carla Engine Client Protected Data
32 struct CarlaEngineClient::ProtectedData {
33 const CarlaEngine& engine;
35 bool active;
36 uint32_t latency;
38 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
39 CarlaEngineCVSourcePortsForStandalone cvSourcePorts;
40 EngineInternalGraph& egraph;
41 CarlaPluginPtr plugin;
42 #endif
44 CarlaStringList audioInList;
45 CarlaStringList audioOutList;
46 CarlaStringList cvInList;
47 CarlaStringList cvOutList;
48 CarlaStringList eventInList;
49 CarlaStringList eventOutList;
51 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
52 ProtectedData(const CarlaEngine& eng, EngineInternalGraph& eg, CarlaPluginPtr p) noexcept;
53 #else
54 ProtectedData(const CarlaEngine& eng) noexcept;
55 #endif
56 ~ProtectedData();
58 void addAudioPortName(bool isInput, const char* name);
59 void addCVPortName(bool isInput, const char* name);
60 void addEventPortName(bool isInput, const char* name);
61 void clearPorts();
62 const char* getUniquePortName(const char* name);
64 #ifdef CARLA_PROPER_CPP11_SUPPORT
65 ProtectedData() = delete;
66 CARLA_DECLARE_NON_COPYABLE(ProtectedData)
67 #endif
70 // -----------------------------------------------------------------------
71 // Carla Engine Client
73 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
74 class CarlaEngineClientForStandalone : public CarlaEngineClient
76 public:
77 CarlaEngineClientForStandalone(const CarlaEngine& engine,
78 EngineInternalGraph& egraph,
79 const CarlaPluginPtr plugin)
80 : CarlaEngineClient(new ProtectedData(engine, egraph, plugin)) {}
82 ~CarlaEngineClientForStandalone() noexcept override
84 carla_debug("CarlaEngineClientForStandalone::~CarlaEngineClientForStandalone()");
85 delete pData;
88 protected:
89 inline PatchbayGraph* getPatchbayGraphOrNull() const noexcept
91 return pData->egraph.getPatchbayGraphOrNull();
94 inline CarlaPluginPtr getPlugin() const noexcept
96 return pData->plugin;
99 CARLA_DECLARE_NON_COPYABLE(CarlaEngineClientForStandalone)
101 typedef CarlaEngineClientForStandalone CarlaEngineClientForSubclassing;
102 #else
103 class CarlaEngineClientForBridge : public CarlaEngineClient
105 public:
106 CarlaEngineClientForBridge(const CarlaEngine& engine)
107 : CarlaEngineClient(new ProtectedData(engine)) {}
109 ~CarlaEngineClientForBridge() override
111 carla_debug("CarlaEngineClientForBridge::~CarlaEngineClientForBridge()");
112 delete pData;
115 CARLA_DECLARE_NON_COPYABLE(CarlaEngineClientForBridge)
117 typedef CarlaEngineClientForBridge CarlaEngineClientForSubclassing;
118 #endif
120 // -----------------------------------------------------------------------
122 CARLA_BACKEND_END_NAMESPACE
124 #endif // CARLA_ENGINE_CLIENT_HPP_INCLUDED