#pragma once

#include "plug.h"

class Node;

class Socket SIGNATURED
{
public:
	virtual ~Socket();
	Logical TestInstance() const;

	void AddPlug(Plug *plug)	{ AddImplementation(plug); }

	Node *GetReleaseNode()	{ return socketsNode; }
	void SetReleaseNode(Node *release_node)	{ socketsNode = release_node; }

protected:
	Socket(Node *node);

	virtual void AddImplementation(Plug *plug);

	Node *socketsNode;
};

#if 0
	typedef int (*IteratorFunction)(Plug *plug, void *info);

	const int IteratorFunctionNullReturn = 0;
#endif

class SocketIterator : public Iterator
{
public:
	~SocketIterator();
	Logical TestInstance() const;

	Plug *ReadAndNextPlug()		{ return (Plug*)ReadAndNextImplementation(); }
	Plug *ReadAndPreviousPlug()	{ return (Plug*)ReadAndPreviousImplementation(); }
	Plug *GetCurrentPlug()		{ return (Plug*)GetCurrentImplementation(); }
	Plug *GetNthPlug(CollectionSize index)	{ return (Plug*)GetNthImplementation(index); }

	void InsertPlug(Plug *plug)	{ InsertImplementation(plug); }

	virtual void Remove();

	Logical IsPlugMember(Plug *plug);

	void RemovePlug(Plug *plug);

	void DeletePlugs(Logical defeat_release_node = true);

#if 0
	int SendPlugCommand(Plug::CommandID plugCommand, void *info);
#endif

protected:
	SocketIterator(Socket *socket);

#if 0
	int RunIteratorFunction(IteratorFunction iteratorFunction, void *info);
#endif

	virtual void InsertImplementation(Plug*);

	Socket *socket;
};