class PreventionAgents
{
	private var m_groupName : CName;
	private var m_requsteredAgents : array< SPreventionAgentData >;

	public function CreateGroup( groupName : CName, ps : weak< PersistentState > )
	{
		m_groupName = groupName;
		AddAgent( ps );
	}

	public const function GetGroupName() : CName
	{
		return m_groupName;
	}

	public const function GetAgentsNumber() : Int32
	{
		return m_requsteredAgents.Size();
	}

	public const function GetAgetntByIndex( index : Int32 ) : weak< PersistentState >
	{
		return m_requsteredAgents[ index ].ps;
	}

	public const function IsAgentalreadyAdded( ps : weak< PersistentState > ) : Bool
	{
		var i : Int32;
		for( i = 0; i < m_requsteredAgents.Size(); i += 1 )
		{
			if( m_requsteredAgents[ i ].ps.GetID() == ps.GetID() )
			{
				return true;
			}
		}
		return false;
	}

	public const function HasAgents() : Bool
	{
		return m_requsteredAgents.Size() > 0;
	}

	public function AddAgent( ps : weak< PersistentState > )
	{
		var newData : SPreventionAgentData;
		newData = new SPreventionAgentData;
		newData.ps = ps;
		m_requsteredAgents.PushBack( newData );
	}

	public function RemoveAgent( ps : weak< PersistentState > )
	{
		var i : Int32;
		for( i = 0; i < m_requsteredAgents.Size(); i += 1 )
		{
			if( m_requsteredAgents[ i ].ps.GetID() == ps.GetID() )
			{
				m_requsteredAgents.Erase( i );
				break;
			}
		}
	}

}

