All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bdi.planlib.PlanFinishedTaskCondition Maven / Gradle / Ivy

Go to download

The Jadex applib BDI package contain ready to use functionalities for BDI agents mostly in form of modules called capabilities.

There is a newer version: 2.4
Show newest version
package jadex.bdi.planlib;

import jadex.bdi.runtime.AgentEvent;
import jadex.bdi.runtime.IPlan;
import jadex.bdi.runtime.IPlanListener;
import jadex.commons.IBooleanCondition;

/**
 *  Finished condition for a space object task to be removed
 *  when a plan is finished.
 */
public class PlanFinishedTaskCondition implements IBooleanCondition
{
	//-------- attributes --------
	
	/** The finished flag. */
	protected boolean	finished;
	
	//-------- constructors --------
	
	/**
	 *  Create a plan finished task condition.
	 *  @param plan	The plan.
	 */
	public PlanFinishedTaskCondition(IPlan plan)
	{
		plan.addPlanListener(new IPlanListener()
		{	
			public void planFinished(AgentEvent ae)
			{
				finished	= true;
			}
			
			public void planAdded(AgentEvent ae){}
		});
	}
	
	//-------- IBooleanCondition interface --------
	
	/**
	 *  Get the current state of the condition.
	 *  @return	True, if the condition is valid.
	 */
	public boolean isValid()
	{
		return !finished;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy