//===========================================================================//
// File:	sfeskt.hh                                                           //
// Project: MUNGA           Brick: Connection Engine                         //
// Contents: Interface definition for safe socket class                      //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 09/29/94  ECH  Initial coding.                                            //
// 10/28/94  JMA  Made compatible with SGI CC and merged with iterator       //
// 11/03/94  ECH  Made compatible with BC4.0                                 //
// 12/12/94  ECH  Changed release mechanism											  //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
//                      PROPRIETARY AND CONFIDENTIAL                         //
//===========================================================================//

#if !defined(SFESKT_HPP)
#	define SFESKT_HPP

#	if !defined(SOCKET_HPP)
#		include <socket.hpp>
#	endif
	
	class SafeIterator;
	
	typedef int IteratorMemo;

	enum
	{
		PlugAdded = 0,
		PlugRemoved,
		NextSafeSocketMemo
	};

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SafeSocket ~~~~~~~~~~~~~~~~~~~~~~~~~~~

	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;
	};

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SafeIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~

	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;
	};

#endif
