/* This file is part of Ingen. * Copyright (C) 2007 Dave Robillard * * Ingen 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 2 of the License, or (at your option) any later * version. * * Ingen 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 details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SERIALIZER_H #define SERIALIZER_H #include #include #include #include #include #include #include #include "raul/SharedPtr.h" #include "raul/Path.h" #include "raul/Atom.h" #include "raul/RDFWriter.h" #include "ObjectModel.h" using std::string; using boost::optional; namespace Ingen { namespace Client { class PluginModel; class PatchModel; class NodeModel; class PortModel; class ConnectionModel; class PresetModel; class ModelEngineInterface; /** Namespace prefix macros. */ #define NS_RDF(x) RdfId(RdfId::RESOURCE, "http://www.w3.org/1999/02/22-rdf-syntax-ns#" x) #define NS_INGEN(x) RdfId(RdfId::RESOURCE, "http://codeson.net/ns/ingen#" x) /** Serializes Ingen objects (patches, nodes, etc) to RDF. * * \ingroup IngenClient */ class Serializer { public: Serializer(); //void path(const string& path) { _patch_search_path = path; } //const string& path() { return _patch_search_path; } //string find_file(const string& filename, const string& additional_path = ""); bool load_patch(bool merge, const string& data_base_uri, const Path& data_path, MetadataMap engine_data, optional engine_parent = optional(), optional engine_name = optional(), optional engine_poly = optional()); void start_to_filename(const string& filename) throw (std::logic_error); void start_to_string() throw (std::logic_error); void serialize(SharedPtr object) throw (std::logic_error); void serialize_connection(SharedPtr c) throw (std::logic_error); string finish() throw (std::logic_error); private: void serialize_plugin(SharedPtr p); void serialize_patch(SharedPtr p, unsigned depth); void serialize_node(SharedPtr n, unsigned depth); void serialize_port(SharedPtr p, unsigned depth); Raul::RdfId path_to_node_id(const Path& path); Raul::RDFWriter _writer; }; } // namespace Client } // namespace Ingen #endif // SERIALIZER_H