//===========================================================================//
// File:	intorgn.hh                                                          //
// Project: MUNGA           Brick: Interest Manager	                       //
// Contents: Interface specifications for interest manager						  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  -----------------------------------------------------------//
// 11/04/94  ECH  Initial coding.                                            //
// 11/29/94  JMA  Changed Identities to IDs                                  //
// 02/10/95  CPB  Added GaugeInterestType                                    //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if !defined(INTORGN_HPP)
# define INTORGN_HPP

#	if !defined(NETWORK_HPP)
#		include <network.hpp>
#	endif

#	if !defined(LATTICE_HPP)
#		include <lattice.hpp>
#	endif

	//##########################################################################
	//#######################    InterestOrigin    #############################
	//##########################################################################

   class Entity;

	class InterestOrigin:
		public Node
	{
      friend class InterestManager;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Destructor, and Testing
	//
	public:
		~InterestOrigin();

		Logical
			TestInstance() const;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Update
	//
	public:
		//
		//-----------------------------------------------------------------------
		// Update
		//
		// Updates the interest origins internal data structures for the
		// interest zone ID.  This method is most likely called by the
		// renderer manager.
		//-----------------------------------------------------------------------
		//
		virtual void
			Update(InterestZoneID interest_zone_ID);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Accessors
	//
	private:
   	InterestZoneID
      	GetInterestZoneID();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructor
	//
	protected:
		InterestOrigin(
			InterestZoneID interest_zone_ID,
			InterestType interest_type,
			InterestDepth depth_calibration
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Interest Manager support
	//
	private:
		virtual void
			AddInterestingEntity(Entity *interesting_entity);
		virtual void
			RemoveUninterestingEntity(Entity *uninteresting_entity);
		virtual void
			RemoveUninterestingEntities();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Private data
	//
	private:
		InterestZoneID
			interestZoneID;
		InterestType
			interestType;
		InterestDepth
			depthCalibration;
		SlotOf<InterestArena*>
      	interestArenaSocket;
	};

	//~~~~~~~~~~~~~~~~~~~~~~~ InterestOrigin inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~

   inline InterestZoneID
   	InterestOrigin::GetInterestZoneID()
   {
   	Check(this);
      return interestZoneID;
   }

#if 0
	//##########################################################################
	//#######################    InterestOrigin    #############################
	//##########################################################################

	class InterestOrigin:
		public Node
	{
      friend class InterestManager;
		friend class InterestOrigin__InterestingEntityIterator;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Public types
	//
	public:
		typedef InterestOrigin__InterestingEntityIterator
			InterestingEntityIterator;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructor, Destructor, and Testing
	//
	public:
		InterestOrigin(
			const EntityID &entity_ID,
			InterestType interest_type,
			InterestDepth depth_calibration
		);
		~InterestOrigin();

		Logical
			TestInstance() const;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Renderer support
	//
	public:
		//
		//--------------------------------------------------------------------
		// UpdateInterestOrigin
		//
		// Updates the interest managers internal data structures for the
		// interest origin entity.  This method is most likely called by the
		// renderer manager.  It prepares the data that will be accessed by
		// InterestingEntityIterator.
		//--------------------------------------------------------------------
		//
		virtual void
			Update();

      InterestArena*
      	GetInterestArena();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Interest Manager support
	//
	protected:
		virtual void
			AddInterestingEntity(Entity *interesting_entity);
		virtual void
			RemoveUninterestingEntity(Entity *uninteresting_entity);
		virtual void
			RemoveUninterestingEntities();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Private data
	//
	private:
		EntityID
			entityID;
		InterestType
			interestType;
		InterestDepth
			depthCalibration;
		SlotOf<InterestArena*>
      	interestArenaSocket;
		SChainOf<Entity*>
			interestingEntitySocket;
	};

   //~~~~~~~~~~~~~~~~~~~~~~~~ InterestOrigin inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~

   inline InterestArena*
      InterestOrigin::GetInterestArena()
   {
      Check(this);
      return interestArenaSocket.GetCurrent();
   }
#endif

#endif

