package de.uka.ipd.consensus.foundation.evolution;

import de.uka.ipd.consensus.foundation.AbstractConsensusFoundationEvent;
import de.uka.ipd.consensus.foundation.ConsensusFoundationManager;
import de.uka.ipd.consensus.foundation.schema.Concept;
import de.uka.ipd.consensus.foundation.schema.Topic;
import de.uka.ipd.consensus.foundation.schema.User;

/**
 * Event objects of this type are passed to EvolutionListeners.
 * @author Thomas Much
 * @version 2006-06-14
 * @see EvolutionListener
 */
public class EvolutionEvent extends AbstractConsensusFoundationEvent {
	
	private Topic topic;
	private User  user;


	public EvolutionEvent(ConsensusFoundationManager cfm, Concept source, User user, Topic topic) {
		super(cfm,source);
		this.topic = topic;
		this.user  = user;
	}
	

	public EvolutionEvent(ConsensusFoundationManager cfm, Concept source, User user) {
		this(cfm,source,user,null);
	}

	
	/**
	 * All evolution events happen on a base concept that is returned by this method.
	 * @return the base concept that the event happened on
	 */
	public Concept getConcept() {
		return (Concept)getSource();
	}
	
	
	/**
	 * Returns the user who caused the event, i.e. the user who deleted or merged topics etc.
	 * @return the user who caused the event
	 */
	public User getUser() {
		return this.user;
	}

	
	/**
	 * If an event happens on a topic aditionally to the base concept (e.g. if two topics are merged), this method returns the additional topic.
	 * @return the additional topic if the event includes a topic in addition to another base concept
	 * @see #getConcept()
	 */
	public Topic getTopic() {
		return this.topic;
	}
	
}
