/*
  This file is part of Ingen.
  Copyright 2007-2012 David Robillard <http://drobilla.net/>

  Ingen is free software: you can redistribute it and/or modify it under the
  terms of the GNU Affero General Public License as published by the Free
  Software Foundation, either version 3 of the License, or 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 Affero General Public License for details.

  You should have received a copy of the GNU Affero General Public License
  along with Ingen.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef INGEN_GRAPHOBJECT_HPP
#define INGEN_GRAPHOBJECT_HPP

#include "raul/Path.hpp"
#include "raul/SharedPtr.hpp"
#include "ingen/Resource.hpp"

namespace Raul {
class Atom;
class Path;
class Symbol;
}

namespace Ingen {

class Edge;
class Plugin;

/** An object on the audio graph - Patch, Node, Port, etc.
 *
 * @ingroup Ingen
 */
class GraphObject : public Resource
{
public:
	enum GraphType {
		PATCH,
		NODE,
		PORT
	};

	typedef std::pair<const GraphObject*, const GraphObject*> EdgesKey;
	typedef std::map< EdgesKey, SharedPtr<Edge> > Edges;

	// Patches only
	Edges&       edges()       { return _edges; }
	const Edges& edges() const { return _edges; }

	// Nodes and patches only
	virtual uint32_t      num_ports()          const { return 0; }
	virtual GraphObject*  port(uint32_t index) const { return NULL; }
	virtual const Plugin* plugin()             const { return NULL; }

	// All objects
	virtual GraphType           graph_type()   const = 0;
	virtual const Raul::Path&   path()         const = 0;
	virtual const Raul::Symbol& symbol()       const = 0;
	virtual GraphObject*        graph_parent() const = 0;

protected:
	GraphObject(URIs& uris, const Raul::Path& path)
		: Resource(uris, path)
	{}

	Edges _edges;  ///< Patches only
};

} // namespace Ingen

#endif // INGEN_GRAPHOBJECT_HPP