From ea7bc6c83e7e9131f6bfb799f4b8e5f864bd1d4f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 Jan 2013 21:43:31 +0000 Subject: Move run context information to Context object and remove Machine::_forge. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4923 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/machina/Context.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++ src/engine/machina/Machine.hpp | 10 +++++----- 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/engine/machina/Context.hpp (limited to 'src/engine/machina') diff --git a/src/engine/machina/Context.hpp b/src/engine/machina/Context.hpp new file mode 100644 index 0000000..270ede7 --- /dev/null +++ b/src/engine/machina/Context.hpp @@ -0,0 +1,44 @@ +/* This file is part of Machina. + * Copyright 2007-2012 David Robillard + * + * Machina is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Machina is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Machina. If not, see . + */ + +#ifndef MACHINA_CONTEXT_HPP +#define MACHINA_CONTEXT_HPP + +#include "raul/Atom.hpp" +#include "raul/TimeSlice.hpp" + +namespace Machina { + +class Context { +public: + Context(Raul::Forge& forge, uint32_t rate, uint32_t ppqn, double bpm) + : _forge(forge) + , _time(rate, ppqn, bpm) + {} + + Raul::Forge& forge() { return _forge; } + const Raul::TimeSlice& time() const { return _time; } + Raul::TimeSlice& time() { return _time; } + +private: + Raul::Forge& _forge; + Raul::TimeSlice _time; +}; + +} // namespace Machina + +#endif // MACHINA_CONTEXT_HPP diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index d65b670..0109742 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -35,6 +35,7 @@ namespace Machina { +class Context; class Controller; class LearnRequest; @@ -42,7 +43,7 @@ class LearnRequest; */ class Machine : public Stateful { public: - Machine(Raul::Forge& forge, TimeUnit unit); + Machine(TimeUnit unit); Machine(const Machine& copy); Machine& operator=(const Machine& other); @@ -66,7 +67,7 @@ public: // Audio context void reset(Raul::TimeStamp time); - uint32_t run(const Raul::TimeSlice& time, SharedPtr updates); + uint32_t run(Context& context, SharedPtr updates); // Any context inline Raul::TimeStamp time() const { return _time; } @@ -87,13 +88,12 @@ private: // Audio context SharedPtr earliest_node() const; - bool enter_node(SharedPtr sink, SharedPtr node, SharedPtr updates); - void exit_node(SharedPtr sink, SharedPtr, SharedPtr updates); + bool enter_node(Context& context, SharedPtr sink, SharedPtr node, SharedPtr updates); + void exit_node(Context& context, SharedPtr sink, SharedPtr, SharedPtr updates); static const size_t MAX_ACTIVE_NODES = 128; std::vector< SharedPtr > _active_nodes; - Raul::Forge& _forge; bool _is_activated; bool _is_finished; Raul::TimeStamp _time; -- cgit v1.2.1