summaryrefslogtreecommitdiffstats
path: root/src/server/Event.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Event.hpp')
-rw-r--r--src/server/Event.hpp87
1 files changed, 46 insertions, 41 deletions
diff --git a/src/server/Event.hpp b/src/server/Event.hpp
index b2477ce8..de1f2384 100644
--- a/src/server/Event.hpp
+++ b/src/server/Event.hpp
@@ -20,17 +20,23 @@
#include "types.hpp"
#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
#include "ingen/Status.hpp"
-#include "ingen/types.hpp"
+#include "ingen/URI.hpp"
+#include "ingen/paths.hpp"
#include "raul/Deletable.hpp"
#include "raul/Noncopyable.hpp"
-#include "raul/Path.hpp"
#include <atomic>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <utility>
-namespace ingen {
-namespace server {
+namespace raul {
+class Path;
+} // namespace raul
+
+namespace ingen::server {
class Engine;
class RunContext;
@@ -48,7 +54,7 @@ class PreProcessContext;
*
* \ingroup engine
*/
-class Event : public Raul::Deletable, public Raul::Noncopyable
+class Event : public raul::Deletable, public raul::Noncopyable
{
public:
/** Event mode to distinguish normal events from undo events. */
@@ -56,20 +62,20 @@ public:
/** Execution mode for events that block and unblock preprocessing. */
enum class Execution {
- NORMAL, ///< Normal pipelined execution
- ATOMIC, ///< Block pre-processing until this event is executed
- BLOCK, ///< Begin atomic block of events
- UNBLOCK ///< Finish atomic executed block of events
+ NORMAL, ///< Normal pipelined execution
+ ATOMIC, ///< Block pre-processing until this event is executed
+ BLOCK, ///< Begin atomic block of events
+ UNBLOCK ///< Finish atomic executed block of events
};
/** Claim position in undo stack before pre-processing (non-realtime). */
- virtual void mark(PreProcessContext&) {};
+ virtual void mark(PreProcessContext&) {}
/** Pre-process event before execution (non-realtime). */
virtual bool pre_process(PreProcessContext& ctx) = 0;
/** Execute this event in the audio thread (realtime). */
- virtual void execute(RunContext& context) = 0;
+ virtual void execute(RunContext& ctx) = 0;
/** Post-process event after execution (non-realtime). */
virtual void post_process() = 0;
@@ -78,13 +84,13 @@ public:
virtual void undo(Interface& target) {}
/** Return true iff this event has been pre-processed. */
- inline bool is_prepared() const { return _status != Status::NOT_PREPARED; }
+ bool is_prepared() const { return _status != Status::NOT_PREPARED; }
/** Return the time stamp of this event. */
- inline SampleCount time() const { return _time; }
+ SampleCount time() const { return _time; }
/** Set the time stamp of this event. */
- inline void set_time(SampleCount time) { _time = time; }
+ void set_time(SampleCount time) { _time = time; }
/** Get the next event to be processed after this one. */
Event* next() const { return _next.load(); }
@@ -104,20 +110,20 @@ public:
/** Set the undo mode of this event. */
void set_mode(Mode mode) { _mode = mode; }
- inline Engine& engine() { return _engine; }
+ Engine& engine() { return _engine; }
protected:
- Event(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- FrameTime time)
- : _engine(engine)
- , _next(nullptr)
- , _request_client(std::move(client))
- , _request_id(id)
- , _time(time)
- , _status(Status::NOT_PREPARED)
- , _mode(Mode::NORMAL)
+ Event(Engine& engine,
+ std::shared_ptr<Interface> client,
+ int32_t id,
+ FrameTime time) noexcept
+ : _engine(engine)
+ , _next(nullptr)
+ , _request_client(std::move(client))
+ , _request_id(id)
+ , _time(time)
+ , _status(Status::NOT_PREPARED)
+ , _mode(Mode::NORMAL)
{}
/** Constructor for internal events only */
@@ -130,39 +136,38 @@ protected:
, _mode(Mode::NORMAL)
{}
- inline bool pre_process_done(Status st) {
+ bool pre_process_done(Status st) {
_status = st;
return st == Status::SUCCESS;
}
- inline bool pre_process_done(Status st, const URI& subject) {
+ bool pre_process_done(Status st, const URI& subject) {
_err_subject = subject;
return pre_process_done(st);
}
- inline bool pre_process_done(Status st, const Raul::Path& subject) {
+ bool pre_process_done(Status st, const raul::Path& subject) {
return pre_process_done(st, path_to_uri(subject));
}
/** Respond to the originating client. */
- inline Status respond() {
+ Status respond() {
if (_request_client && _request_id) {
_request_client->response(_request_id, _status, _err_subject);
}
return _status;
}
- Engine& _engine;
- std::atomic<Event*> _next;
- SPtr<Interface> _request_client;
- int32_t _request_id;
- FrameTime _time;
- Status _status;
- std::string _err_subject;
- Mode _mode;
+ Engine& _engine;
+ std::atomic<Event*> _next;
+ std::shared_ptr<Interface> _request_client;
+ int32_t _request_id;
+ FrameTime _time;
+ Status _status;
+ std::string _err_subject;
+ Mode _mode;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_EVENT_HPP