//===========================================================================//
// File:	model.hpp                                                           //
// Project: MUNGA           Brick: Model Manager                             //
// Contents: Interface specification of model class                          //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 01/25/95  JMA  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All Rights reserved //
//                      PROPRIETARY AND CONFIDENTIAL                         //
//===========================================================================//

#if !defined(STATE_HPP)
#	define STATE_HPP

#	if !defined(CMPNNT__HPP)
#		include <cmpnnt.hpp>
#	endif

#	if !defined(SCHAIN_HPP)
#		include <schain.hpp>
#	endif

	//##########################################################################
	//#####################    StateIndicator    ###############################
	//##########################################################################

	class StateIndicator:
		public Node
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction and Destruction
	//
	public:
		StateIndicator();
		StateIndicator(unsigned max_states);
		StateIndicator(const StateIndicator &state_indicator);
		~StateIndicator();

		StateIndicator&
			operator=(const StateIndicator&);

		Logical
			operator==(const StateIndicator&) const;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// State stuff
	//
	public:
		unsigned
			GetState()
				{Check(this); return currentState;}
		unsigned
			GetOldState()
				{Check(this); return oldState;}
		void
			SetState(unsigned new_state);

	protected:
		unsigned
			stateCount,
			oldState,
			currentState;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Watcher stuff
	//
	public:
		void
			AddAudioWatcher(Component *watcher)
				{Check(&audioWatcherSocket);audioWatcherSocket.Add(watcher);}
		void
			AddVideoWatcher(Component *watcher)
				{Check(&videoWatcherSocket);videoWatcherSocket.Add(watcher);}
		void
			AddGaugeWatcher(Component *watcher)
				{Check(&gaugeWatcherSocket);gaugeWatcherSocket.Add(watcher);}

	private:
		SChainOf<Component*>
			audioWatcherSocket;
		SChainOf<Component*>
			videoWatcherSocket;
		SChainOf<Component*>
			gaugeWatcherSocket;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Stream input/output methods
	//
	public:
		friend ostream&
			operator << (
				ostream &strm,
				const StateIndicator &state_indicator
			);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Test Support
	//
	public:
		Logical
			TestInstance() const;
		static Logical
			TestClass();
	};

#endif
