From 019eeff6a7d051427ad62a288f350e66471a0462 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Aug 2020 13:43:01 +0200 Subject: Remove std::unique_ptr alias --- include/ingen/AtomForge.hpp | 5 ++- include/ingen/Serialiser.hpp | 3 +- include/ingen/memory.hpp | 3 -- src/World.cpp | 36 +++++++++--------- src/server/BlockImpl.hpp | 4 +- src/server/Engine.cpp | 2 +- src/server/Engine.hpp | 77 ++++++++++++++++++++------------------- src/server/JackDriver.hpp | 3 +- src/server/LV2Block.cpp | 3 +- src/server/LV2Block.hpp | 4 +- src/server/RunContext.hpp | 11 +++--- src/server/Worker.hpp | 19 +++++----- src/server/events/CreateGraph.hpp | 15 ++++---- src/server/events/Delete.hpp | 21 ++++++----- src/server/events/Delta.hpp | 5 ++- src/server/events/Disconnect.hpp | 4 +- src/server/events/Mark.cpp | 7 ++-- src/server/events/Undo.cpp | 6 ++- src/server/ingen_lv2.cpp | 14 +++---- tests/ingen_test.cpp | 3 +- 20 files changed, 131 insertions(+), 114 deletions(-) diff --git a/include/ingen/AtomForge.hpp b/include/ingen/AtomForge.hpp index ac8d15aa..372fd29d 100644 --- a/include/ingen/AtomForge.hpp +++ b/include/ingen/AtomForge.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace ingen { @@ -69,8 +70,8 @@ public: private: struct SratomDeleter { void operator()(Sratom* s) { sratom_free(s); } }; - using AtomPtr = UPtr>; - using SratomPtr = UPtr; + using AtomPtr = std::unique_ptr>; + using SratomPtr = std::unique_ptr; /// Append some data and return a reference to its start intptr_t append(const void* data, uint32_t len) { diff --git a/include/ingen/Serialiser.hpp b/include/ingen/Serialiser.hpp index 7311d6ce..103a4822 100644 --- a/include/ingen/Serialiser.hpp +++ b/include/ingen/Serialiser.hpp @@ -23,6 +23,7 @@ #include "ingen/memory.hpp" #include "sord/sordmm.hpp" +#include #include namespace Raul { class Path; } @@ -98,7 +99,7 @@ public: private: struct Impl; - UPtr me; + std::unique_ptr me; }; } // namespace ingen diff --git a/include/ingen/memory.hpp b/include/ingen/memory.hpp index 82a1e2a6..bec86c43 100644 --- a/include/ingen/memory.hpp +++ b/include/ingen/memory.hpp @@ -30,9 +30,6 @@ void NullDeleter(T* ptr) {} template struct FreeDeleter { void operator()(T* const ptr) { free(ptr); } }; -template > -using UPtr = std::unique_ptr; - template using SPtr = std::shared_ptr; diff --git a/src/World.cpp b/src/World.cpp index 5552230f..4b502e6e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -72,7 +72,7 @@ ingen_load_library(Log& log, const string& name) return nullptr; } - UPtr library = make_unique(path); + std::unique_ptr library = make_unique(path); if (*library) { return library; } @@ -179,23 +179,23 @@ public: using LilvWorldUPtr = std::unique_ptr; - int* argc; - char*** argv; - LV2Features* lv2_features; - UPtr rdf_world; - LilvWorldUPtr lilv_world; - URIMap uri_map; - Forge forge; - URIs uris; - Configuration conf; - Log log; - SPtr interface; - SPtr engine; - SPtr serialiser; - SPtr parser; - SPtr store; - std::mutex rdf_mutex; - std::string jack_uuid; + int* argc; + char*** argv; + LV2Features* lv2_features; + std::unique_ptr rdf_world; + LilvWorldUPtr lilv_world; + URIMap uri_map; + Forge forge; + URIs uris; + Configuration conf; + Log log; + SPtr interface; + SPtr engine; + SPtr serialiser; + SPtr parser; + SPtr store; + std::mutex rdf_mutex; + std::string jack_uuid; }; World::World(LV2_URID_Map* map, LV2_URID_Unmap* unmap, LV2_Log_Log* log) diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index 0fd44989..ffe2aaf9 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -107,7 +107,9 @@ public: virtual LilvState* load_preset(const URI& uri) { return nullptr; } /** Restore `state`. */ - virtual void apply_state(const UPtr& worker, const LilvState* state) {} + virtual void + apply_state(const std::unique_ptr& worker, const LilvState* state) + {} /** Save current state as preset. */ virtual boost::optional diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index fb600644..ae5b297f 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -176,7 +176,7 @@ void Engine::listen() { #ifdef HAVE_SOCKET - _listener = UPtr(new SocketListener(*this)); + _listener = make_unique(*this); #endif } diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 08ecac98..445ac649 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -136,20 +137,20 @@ public: ingen::World& world() const { return _world; } Log& log() const; - const SPtr& interface() const { return _interface; } - const SPtr& event_writer() const { return _event_writer; } - const UPtr& atom_interface() const { return _atom_interface; } - const UPtr& block_factory() const { return _block_factory; } - const UPtr& broadcaster() const { return _broadcaster; } - const UPtr& buffer_factory() const { return _buffer_factory; } - const UPtr& control_bindings() const { return _control_bindings; } - const SPtr& driver() const { return _driver; } - const UPtr& post_processor() const { return _post_processor; } - const UPtr& maid() const { return _maid; } - const UPtr& undo_stack() const { return _undo_stack; } - const UPtr& redo_stack() const { return _redo_stack; } - const UPtr& worker() const { return _worker; } - const UPtr& sync_worker() const { return _sync_worker; } + const SPtr& interface() const { return _interface; } + const SPtr& event_writer() const { return _event_writer; } + const std::unique_ptr& atom_interface() const { return _atom_interface; } + const std::unique_ptr& block_factory() const { return _block_factory; } + const std::unique_ptr& broadcaster() const { return _broadcaster; } + const std::unique_ptr& buffer_factory() const { return _buffer_factory; } + const std::unique_ptr& control_bindings() const { return _control_bindings; } + const SPtr& driver() const { return _driver; } + const std::unique_ptr& post_processor() const { return _post_processor; } + const std::unique_ptr& maid() const { return _maid; } + const std::unique_ptr& undo_stack() const { return _undo_stack; } + const std::unique_ptr& redo_stack() const { return _redo_stack; } + const std::unique_ptr& worker() const { return _worker; } + const std::unique_ptr& sync_worker() const { return _sync_worker; } GraphImpl* root_graph() const { return _root_graph; } void set_root_graph(GraphImpl* graph); @@ -182,30 +183,30 @@ public: private: ingen::World& _world; - SPtr _options; - UPtr _buffer_factory; - UPtr _maid; - SPtr _driver; - UPtr _worker; - UPtr _sync_worker; - UPtr _broadcaster; - UPtr _control_bindings; - UPtr _block_factory; - UPtr _undo_stack; - UPtr _redo_stack; - UPtr _post_processor; - UPtr _pre_processor; - UPtr _listener; - SPtr _event_writer; - SPtr _interface; - UPtr _atom_interface; - GraphImpl* _root_graph; - - std::vector> _notifications; - std::vector> _run_contexts; - uint64_t _cycle_start_time; - Load _run_load; - Clock _clock; + SPtr _options; + std::unique_ptr _buffer_factory; + std::unique_ptr _maid; + SPtr _driver; + std::unique_ptr _worker; + std::unique_ptr _sync_worker; + std::unique_ptr _broadcaster; + std::unique_ptr _control_bindings; + std::unique_ptr _block_factory; + std::unique_ptr _undo_stack; + std::unique_ptr _redo_stack; + std::unique_ptr _post_processor; + std::unique_ptr _pre_processor; + std::unique_ptr _listener; + SPtr _event_writer; + SPtr _interface; + std::unique_ptr _atom_interface; + GraphImpl* _root_graph; + + std::vector> _notifications; + std::vector> _run_contexts; + uint64_t _cycle_start_time; + Load _run_load; + Clock _clock; std::mt19937 _rand_engine; std::uniform_real_distribution _uniform_dist; diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index 34d25f65..8f5cead5 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace Raul { class Path; } @@ -143,7 +144,7 @@ protected: using Ports = boost::intrusive::slist>; - using AudioBufPtr = UPtr>; + using AudioBufPtr = std::unique_ptr>; Engine& _engine; Ports _ports; diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 0bdcacc2..c555ac4a 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -650,7 +650,8 @@ LV2Block::load_state(World& world, const FilePath& path) } void -LV2Block::apply_state(const UPtr& worker, const LilvState* state) +LV2Block::apply_state(const std::unique_ptr& worker, + const LilvState* state) { World& world = parent_graph()->engine().world(); SPtr sched; diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp index 00530862..0413a245 100644 --- a/src/server/LV2Block.hpp +++ b/src/server/LV2Block.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace ingen { @@ -80,7 +81,8 @@ public: LilvState* load_preset(const URI& uri) override; - void apply_state(const UPtr& worker, const LilvState* state) override; + void apply_state(const std::unique_ptr& worker, + const LilvState* state) override; boost::optional save_preset(const URI& uri, const Properties& props) override; diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp index cf2bfe10..10414bde 100644 --- a/src/server/RunContext.hpp +++ b/src/server/RunContext.hpp @@ -24,6 +24,7 @@ #include "raul/RingBuffer.hpp" #include +#include #include namespace ingen { @@ -143,11 +144,11 @@ public: protected: void run(); - Engine& _engine; ///< Engine we're running in - Raul::RingBuffer* _event_sink; ///< Port updates from process context - Task* _task; ///< Currently executing task - UPtr _thread; ///< Thread (null for main run context) - unsigned _id; ///< Context ID + Engine& _engine; ///< Engine we're running in + Raul::RingBuffer* _event_sink; ///< Updates from process context + Task* _task; ///< Currently executing task + std::unique_ptr _thread; ///< Thread (or null for main) + unsigned _id; ///< Context ID FrameTime _start; ///< Start frame of this cycle, timeline relative FrameTime _end; ///< End frame of this cycle, timeline relative diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp index ae7e9f1e..cc79629c 100644 --- a/src/server/Worker.hpp +++ b/src/server/Worker.hpp @@ -24,6 +24,7 @@ #include "raul/Semaphore.hpp" #include +#include #include namespace ingen { @@ -59,15 +60,15 @@ public: private: SPtr _schedule; - Log& _log; - Raul::Semaphore _sem; - Raul::RingBuffer _requests; - Raul::RingBuffer _responses; - uint8_t* const _buffer; - const uint32_t _buffer_size; - UPtr _thread; - bool _exit_flag; - bool _synchronous; + Log& _log; + Raul::Semaphore _sem; + Raul::RingBuffer _requests; + Raul::RingBuffer _responses; + uint8_t* const _buffer; + const uint32_t _buffer_size; + std::unique_ptr _thread; + bool _exit_flag; + bool _synchronous; void run(); }; diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp index b755d8f2..7fbf9bdc 100644 --- a/src/server/events/CreateGraph.hpp +++ b/src/server/events/CreateGraph.hpp @@ -25,6 +25,7 @@ #include #include +#include namespace ingen { namespace server { @@ -57,13 +58,13 @@ public: private: void build_child_events(); - const Raul::Path _path; - Properties _properties; - ClientUpdate _update; - GraphImpl* _graph; - GraphImpl* _parent; - MPtr _compiled_graph; - std::list> _child_events; + const Raul::Path _path; + Properties _properties; + ClientUpdate _update; + GraphImpl* _graph; + GraphImpl* _parent; + MPtr _compiled_graph; + std::list> _child_events; }; } // namespace events diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp index f4ad278b..c556bbd9 100644 --- a/src/server/events/Delete.hpp +++ b/src/server/events/Delete.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -61,16 +62,16 @@ private: using IndexChange = std::pair; using IndexChanges = std::map; - const ingen::Del _msg; - Raul::Path _path; - SPtr _block; ///< Non-null iff a block - SPtr _port; ///< Non-null iff a port - EnginePort* _engine_port; - MPtr _ports_array; ///< New (external) ports for Graph - MPtr _compiled_graph; ///< Graph's new process order - UPtr _disconnect_event; - Store::Objects _removed_objects; - IndexChanges _port_index_changes; + const ingen::Del _msg; + Raul::Path _path; + SPtr _block; ///< Non-null iff a block + SPtr _port; ///< Non-null iff a port + EnginePort* _engine_port; + MPtr _ports_array; ///< New (external) ports for Graph + MPtr _compiled_graph; ///< Graph's new process order + std::unique_ptr _disconnect_event; + Store::Objects _removed_objects; + IndexChanges _port_index_changes; std::vector _removed_bindings; }; diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index b5559d84..c4199262 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -27,6 +27,7 @@ #include #include +#include #include namespace ingen { @@ -95,11 +96,11 @@ private: LOADED_BUNDLE }; - using SetEvents = std::vector>; + using SetEvents = std::vector>; void init(); - UPtr _create_event; + std::unique_ptr _create_event; SetEvents _set_events; std::vector _types; std::vector _remove_types; diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index 4b5f6aea..d6a455c8 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -22,6 +22,8 @@ #include "PortImpl.hpp" #include "types.hpp" +#include + namespace ingen { namespace server { @@ -67,7 +69,7 @@ public: private: const ingen::Disconnect _msg; GraphImpl* _graph; - UPtr _impl; + std::unique_ptr _impl; MPtr _compiled_graph; }; diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp index 103c5b3c..d7eb1804 100644 --- a/src/server/events/Mark.cpp +++ b/src/server/events/Mark.cpp @@ -20,6 +20,7 @@ #include "PreProcessContext.hpp" #include "UndoStack.hpp" +#include #include namespace ingen { @@ -47,9 +48,9 @@ Mark::Mark(Engine& engine, void Mark::mark(PreProcessContext&) { - const UPtr& stack = ((_mode == Mode::UNDO) - ? _engine.redo_stack() - : _engine.undo_stack()); + const std::unique_ptr& stack = ((_mode == Mode::UNDO) + ? _engine.redo_stack() + : _engine.undo_stack()); switch (_type) { case Type::BUNDLE_BEGIN: diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp index 9a60c15f..c855dbfb 100644 --- a/src/server/events/Undo.cpp +++ b/src/server/events/Undo.cpp @@ -46,8 +46,10 @@ Undo::Undo(Engine& engine, bool Undo::pre_process(PreProcessContext&) { - const UPtr& stack = _is_redo ? _engine.redo_stack() : _engine.undo_stack(); - const Event::Mode mode = _is_redo ? Event::Mode::REDO : Event::Mode::UNDO; + const std::unique_ptr& stack = + _is_redo ? _engine.redo_stack() : _engine.undo_stack(); + + const Event::Mode mode = _is_redo ? Event::Mode::REDO : Event::Mode::UNDO; if (stack->empty()) { return Event::pre_process_done(Status::NOT_FOUND); diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 9b66fe7c..cc42b3ac 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -451,12 +451,12 @@ ingen_lv2_main(const SPtr& engine, const SPtr& driver) } struct IngenPlugin { - UPtr world; - SPtr engine; - UPtr main; - LV2_URID_Map* map = nullptr; - int argc = 0; - char** argv = nullptr; + std::unique_ptr world; + SPtr engine; + std::unique_ptr main; + LV2_URID_Map* map = nullptr; + int argc = 0; + char** argv = nullptr; }; static Lib::Graphs @@ -539,7 +539,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, auto* plugin = new IngenPlugin(); plugin->map = map; - plugin->world = UPtr(new ingen::World(map, unmap, log)); + plugin->world = make_unique(map, unmap, log); plugin->world->load_configuration(plugin->argc, plugin->argv); LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength); diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index fbcc5cc0..5634f513 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,7 @@ ingen_try(bool cond, const char* msg) static FilePath real_file_path(const char* path) { - UPtr> real_path{realpath(path, nullptr)}; + std::unique_ptr> real_path{realpath(path, nullptr)}; return FilePath{real_path.get()}; } -- cgit v1.2.1