#pragma once

#include "socket.h"

class SafeIterator;

typedef int IteratorMemo;

enum
{
	PlugAdded = 0,
	PlugRemoved,
	NextSafeSocketMemo
};

class SafeSocket : public Socket
{
	friend class SafeIterator;

public:
	~SafeSocket();
	Logical TestInstance() const;

protected:
	SafeSocket(Node *node);

	void SendIteratorMemo(IteratorMemo memo, void *content);

private:
	SafeIterator *iteratorHead;
};

class SafeIterator : public SocketIterator
{
	friend class SafeSocket;

public:
	~SafeIterator();
	Logical TestInstance() const;

protected:
	SafeIterator(SafeSocket *safeSocket);

private:
	virtual void ReceiveMemo(IteratorMemo memo, void *content);

	SafeIterator *nextIterator;
	SafeIterator *prevIterator;
};