es.upv.dsic.gti_ia.cAgents
Class CFactory

java.lang.Object
  extended by es.upv.dsic.gti_ia.cAgents.CFactory

public class CFactory
extends Object

A CFactory starts CProcessors in order to manage conversations. Every CFactory has a CProcessor associated that works as a template for the CProcessors that this CFactory will create. Every CFactory also has a message filter that specifies which type of messages can start new conversations

Author:
Ricard Lopez Fogues

Constructor Summary
CFactory(String name, MessageFilter filter, int conversationsLimit, CAgent myAgent)
          Constructor of the class
 
Method Summary
 CProcessor cProcessorTemplate()
          Returns the CProcessor that acts as template and will be cloned in order to create new CProcessors
 MessageFilter getFilter()
          Returns this CFactory's message filter
 int getLimit()
          Returns how many conversations can a CFactory manage simultaneously
 String getName()
          Returns this CFactory's name
protected  boolean isInitiator()
          Returns true if this is initiator, false if this is participant
 void setCProcessor(CProcessor proc)
           
 void setFilter(MessageFilter template)
          Sets the message filter that will make this CFactory to start new CProcessors
protected  void setInitiator(boolean initiator)
          Sets the type of the CFactory
protected  CProcessor startConversation(ACLMessage msg, CProcessor parent, Boolean isSync)
          Creates a new CProcessor that will manage the new conversation
protected  CProcessor startConversationWithID(String id, CProcessor parent, Boolean isSync)
          Creates a new CProcessor that will manage the new conversation
protected  boolean templateIsEqual(ACLMessage template)
          Returns true if the message matches with the message filter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CFactory

public CFactory(String name,
                MessageFilter filter,
                int conversationsLimit,
                CAgent myAgent)
Constructor of the class

Parameters:
name - of the CFactory
filter - message filter that specifies which type of messages can start new conversations
conversationLimit - how many conversations can a CFactory manage simultaneously
myAgent - the agent owner of this factory
Method Detail

getLimit

public int getLimit()
Returns how many conversations can a CFactory manage simultaneously

Returns:
conversation limit

setFilter

public void setFilter(MessageFilter template)
Sets the message filter that will make this CFactory to start new CProcessors

Parameters:
template - message filter that will make this CFactory to start new CProcessors

getFilter

public MessageFilter getFilter()
Returns this CFactory's message filter

Returns:
the message filter that will make this CFactory to start new CProcessors

cProcessorTemplate

public CProcessor cProcessorTemplate()
Returns the CProcessor that acts as template and will be cloned in order to create new CProcessors

Returns:
CProcessor that acts as template and will be cloned in order to create new CProcessors

startConversation

protected CProcessor startConversation(ACLMessage msg,
                                       CProcessor parent,
                                       Boolean isSync)
Creates a new CProcessor that will manage the new conversation

Parameters:
msg - Initial message
parent - CProcessor that start this conversation and acts as parent
isSync - True if it is synchronous, false otherwise
Returns:
the new CProcessor just created

startConversationWithID

protected CProcessor startConversationWithID(String id,
                                             CProcessor parent,
                                             Boolean isSync)
Creates a new CProcessor that will manage the new conversation

Parameters:
id - The conversation identifier of the new conversation
parent - Parent CProcessor
isSync - True if it is synchronous, false otherwise
Returns:
the new CProcessor just created

templateIsEqual

protected boolean templateIsEqual(ACLMessage template)
Returns true if the message matches with the message filter

Returns:
true if the message matches with the message filter, false otherwise

setInitiator

protected void setInitiator(boolean initiator)
Sets the type of the CFactory

Parameters:
initiator - True if this is a initiator CFactory, false if this is a participant one

isInitiator

protected boolean isInitiator()
Returns true if this is initiator, false if this is participant

Returns:
true if this is initiator, false if this is participant

getName

public String getName()
Returns this CFactory's name

Returns:
this CFactory's name

setCProcessor

public void setCProcessor(CProcessor proc)


Copyright © 2012 GTI-IA. All Rights Reserved.