diff options
Diffstat (limited to 'src/libs/engine')
-rw-r--r-- | src/libs/engine/Engine.cpp | 21 | ||||
-rw-r--r-- | src/libs/engine/Engine.hpp | 4 | ||||
-rw-r--r-- | src/libs/engine/GraphObjectImpl.cpp | 14 | ||||
-rw-r--r-- | src/libs/engine/GraphObjectImpl.hpp | 2 | ||||
-rw-r--r-- | src/libs/engine/HTTPEngineReceiver.cpp | 29 | ||||
-rw-r--r-- | src/libs/engine/Makefile.am | 1 | ||||
-rw-r--r-- | src/libs/engine/ObjectStore.cpp | 24 | ||||
-rw-r--r-- | src/libs/engine/ObjectStore.hpp | 8 | ||||
-rw-r--r-- | src/libs/engine/events/AllNotesOffEvent.cpp | 2 |
9 files changed, 77 insertions, 28 deletions
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index 0a6d048a..e7c2545c 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -27,6 +27,7 @@ #include "tuning.hpp" #include "Event.hpp" #include "common/interface/EventType.hpp" +#include "common/interface/Store.hpp" #include "JackAudioDriver.hpp" #include "NodeFactory.hpp" #include "ClientBroadcaster.hpp" @@ -58,11 +59,15 @@ Engine::Engine(Ingen::Shared::World* world) , _maid(new Raul::Maid(maid_queue_size)) , _post_processor(new PostProcessor(*this, /**_maid, */post_processor_queue_size)) , _broadcaster(new ClientBroadcaster()) - , _object_store(new ObjectStore()) , _node_factory(new NodeFactory(world)) , _quit_flag(false) , _activated(false) { + if (world->store) { + assert(PtrCast<ObjectStore>(world->store)); + } else { + world->store = SharedPtr<Store>(new ObjectStore()); + } } @@ -70,13 +75,12 @@ Engine::~Engine() { deactivate(); - for (ObjectStore::Objects::iterator i = _object_store->objects().begin(); - i != _object_store->objects().end(); ++i) { + for (ObjectStore::Objects::iterator i = object_store()->objects().begin(); + i != object_store()->objects().end(); ++i) { if ( ! PtrCast<GraphObjectImpl>(i->second)->parent() ) i->second.reset(); } - delete _object_store; delete _broadcaster; delete _node_factory; delete _osc_driver; @@ -87,6 +91,13 @@ Engine::~Engine() munlockall(); } + + +ObjectStore* +Engine::object_store() const +{ + return dynamic_cast<ObjectStore*>(_world->store.get()); +} Driver* @@ -228,7 +239,7 @@ Engine::activate(size_t parallelism) PatchImpl* root_patch = new PatchImpl(*this, "", 1, NULL, _audio_driver->sample_rate(), _audio_driver->buffer_size(), 1); root_patch->activate(); - _object_store->add(root_patch); + _world->store->add(root_patch); root_patch->compiled_patch(root_patch->compile()); assert(_audio_driver->root_patch() == NULL); diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp index c2a59f3e..1d3b4253 100644 --- a/src/libs/engine/Engine.hpp +++ b/src/libs/engine/Engine.hpp @@ -90,9 +90,10 @@ public: OSCDriver* osc_driver() const { return _osc_driver; } PostProcessor* post_processor() const { return _post_processor; } ClientBroadcaster* broadcaster() const { return _broadcaster; } - ObjectStore* object_store() const { return _object_store; } NodeFactory* node_factory() const { return _node_factory; } + ObjectStore* object_store() const; + /** Return the active driver for the given type */ Driver* driver(DataType type, EventType event_type); @@ -114,7 +115,6 @@ private: Raul::Maid* _maid; PostProcessor* _post_processor; ClientBroadcaster* _broadcaster; - ObjectStore* _object_store; NodeFactory* _node_factory; bool _quit_flag; diff --git a/src/libs/engine/GraphObjectImpl.cpp b/src/libs/engine/GraphObjectImpl.cpp index 62474bfc..5275261f 100644 --- a/src/libs/engine/GraphObjectImpl.cpp +++ b/src/libs/engine/GraphObjectImpl.cpp @@ -29,20 +29,6 @@ GraphObjectImpl::parent_patch() const } -GraphObjectImpl::const_iterator -GraphObjectImpl::children_begin() const -{ - throw; -} - - -GraphObjectImpl::const_iterator -GraphObjectImpl::children_end() const -{ - throw; -} - - SharedPtr<GraphObject> GraphObjectImpl::find_child(const string& name) const { diff --git a/src/libs/engine/GraphObjectImpl.hpp b/src/libs/engine/GraphObjectImpl.hpp index f3c7286a..1eb8acc9 100644 --- a/src/libs/engine/GraphObjectImpl.hpp +++ b/src/libs/engine/GraphObjectImpl.hpp @@ -94,8 +94,6 @@ public: return Path(_parent->path() +"/"+ _name); } - const_iterator children_begin() const; - const_iterator children_end() const; SharedPtr<GraphObject> find_child(const std::string& name) const; protected: diff --git a/src/libs/engine/HTTPEngineReceiver.cpp b/src/libs/engine/HTTPEngineReceiver.cpp index baa522ba..47da1eb1 100644 --- a/src/libs/engine/HTTPEngineReceiver.cpp +++ b/src/libs/engine/HTTPEngineReceiver.cpp @@ -22,6 +22,9 @@ #include <raul/SharedPtr.hpp> #include <raul/AtomLiblo.hpp> #include "interface/ClientInterface.hpp" +#include "module/Module.hpp" +#include "serialisation/serialisation.hpp" +#include "serialisation/Serialiser.hpp" #include "engine/ThreadManager.hpp" #include "HTTPEngineReceiver.hpp" #include "QueuedEventSource.hpp" @@ -43,6 +46,17 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port) cout << "Started HTTP server on port " << soup_server_get_port(_server) << endl; Thread::set_name("HTTP receiver"); + + if (!engine.world()->serialisation_module) + engine.world()->serialisation_module = Ingen::Shared::load_module("ingen_serialisation"); + + if (engine.world()->serialisation_module) + if (!engine.world()->serialiser) + engine.world()->serialiser = SharedPtr<Serialiser>( + Ingen::Serialisation::new_serialiser(engine.world())); + + if (!engine.world()->serialiser) + cerr << "WARNING: Failed to load ingen_serialisation module, HTTP disabled." << endl; } @@ -86,26 +100,37 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const return; } + SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser; + if (!serialiser) { + soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); + return; + } + // FIXME: not thread safe! - ObjectStore* store = me->_engine.object_store(); + SharedPtr<Store> store = me->_engine.world()->store; + assert(store); if (!Path::is_valid(path)) { soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); return; } - ObjectStore::Objects::iterator start = store->find(path); + Store::Objects::const_iterator start = store->find(path); if (start == store->objects().end()) { soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); return; } +#if 0 ObjectStore::Objects::iterator end = store->objects().find_descendants_end(start); string response; for (ObjectStore::Objects::iterator i = start; i != end; ++i) response.append(i->first).append("\n"); +#endif + const string response = serialiser->to_string(start->second, + "http://example.org/whatever", GraphObject::Variables()); soup_message_set_status (msg, SOUP_STATUS_OK); soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY, response.c_str(), response.length()); diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index 0f069e10..938d6817 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -20,6 +20,7 @@ libingen_engine_la_CXXFLAGS = \ libingen_engine_la_LDFLAGS = -no-undefined -module -avoid-version libingen_engine_la_LIBADD = \ ../shared/libingen_shared.la \ + ../module/libingen_module.la \ @GLIBMM_LIBS@ \ @JACK_LIBS@ \ @LASH_LIBS@ \ diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp index 052200fd..3cecb338 100644 --- a/src/libs/engine/ObjectStore.cpp +++ b/src/libs/engine/ObjectStore.cpp @@ -72,11 +72,33 @@ ObjectStore::find_object(const Path& path) } +ObjectStore::Objects::const_iterator +ObjectStore::children_begin(SharedPtr<Shared::GraphObject> o) const +{ + Objects::const_iterator parent = _objects.find(o->path()); + assert(parent != _objects.end()); + ++parent; + return parent; +} + + +ObjectStore::Objects::const_iterator +ObjectStore::children_end(SharedPtr<Shared::GraphObject> o) const +{ + Objects::const_iterator parent = _objects.find(o->path()); + assert(parent != _objects.end()); + return _objects.find_descendants_end(parent); +} + + /** Add an object to the store. Not realtime safe. */ void -ObjectStore::add(GraphObjectImpl* o) +ObjectStore::add(GraphObject* obj) { + GraphObjectImpl* o = dynamic_cast<GraphObjectImpl*>(obj); + assert(o); + assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); if (_objects.find(o->path()) != _objects.end()) { diff --git a/src/libs/engine/ObjectStore.hpp b/src/libs/engine/ObjectStore.hpp index bf85d3e1..edba52f0 100644 --- a/src/libs/engine/ObjectStore.hpp +++ b/src/libs/engine/ObjectStore.hpp @@ -21,6 +21,7 @@ #include <string> #include <raul/PathTable.hpp> #include <raul/SharedPtr.hpp> +#include "interface/Store.hpp" using std::string; using namespace Raul; @@ -44,7 +45,7 @@ class GraphObjectImpl; * Searching with find*() is fast (O(log(n)) binary search on contiguous * memory) and realtime safe, but modification (add or remove) are neither. */ -class ObjectStore +class ObjectStore : public Shared::Store { public: typedef Raul::PathTable< SharedPtr<Shared::GraphObject> > Objects; @@ -56,7 +57,10 @@ public: Objects::iterator find(const Path& path) { return _objects.find(path); } - void add(GraphObjectImpl* o); + Objects::const_iterator children_begin(SharedPtr<Shared::GraphObject> o) const; + Objects::const_iterator children_end(SharedPtr<Shared::GraphObject> o) const; + + void add(Shared::GraphObject* o); void add(const Table<Path, SharedPtr<Shared::GraphObject> >& family); //void add(TreeNode<GraphObjectImpl*>* o); diff --git a/src/libs/engine/events/AllNotesOffEvent.cpp b/src/libs/engine/events/AllNotesOffEvent.cpp index 2e1f45fa..a0b3360f 100644 --- a/src/libs/engine/events/AllNotesOffEvent.cpp +++ b/src/libs/engine/events/AllNotesOffEvent.cpp @@ -19,6 +19,8 @@ #include "Responder.hpp" #include "Engine.hpp" #include "ObjectStore.hpp" +#include "module/World.hpp" +#include "interface/Store.hpp" namespace Ingen { |