#pragma once

#include "cmpnnt.h"
#include "schain.h"

class StateIndicator : public Node
{
public:
	StateIndicator();
	StateIndicator(unsigned max_states);
	StateIndicator(const StateIndicator &state_indicator);
	~StateIndicator();

	StateIndicator& operator=(const StateIndicator&);

	Logical operator==(const StateIndicator&) const;

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

protected:
	unsigned stateCount, oldState, currentState;

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;

public:
	friend std::ostream& operator << (std::ostream &strm, const StateIndicator &state_indicator);

public:
	Logical TestInstance() const;
	static Logical TestClass();
};