Magentix2
2.1.1
|
Public Member Functions | |
CFactory (String name, MessageFilter filter, int conversationsLimit, CAgent myAgent) | |
int | getLimit () |
void | setFilter (MessageFilter template) |
MessageFilter | getFilter () |
CProcessor | cProcessorTemplate () |
String | getName () |
void | setCProcessor (CProcessor proc) |
Protected Member Functions | |
CProcessor | startConversation (Queue< ACLMessage > qMsg, CProcessor parent, Boolean isSync) |
CProcessor | startConversationWithID (String id, CProcessor parent, Boolean isSync) |
boolean | templateIsEqual (ACLMessage template) |
void | setInitiator (boolean initiator) |
boolean | isInitiator () |
Package Attributes | |
String | name |
Semaphore | availableConversations |
int | limit |
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
Definition at line 20 of file CFactory.java.
es.upv.dsic.gti_ia.cAgents.CFactory.CFactory | ( | String | name, |
MessageFilter | filter, | ||
int | conversationsLimit, | ||
CAgent | myAgent | ||
) |
Constructor of the class
name | Name of the CFactory |
filter | Message filter that specifies which type of messages can start new conversations. If this is null imply that all messages are accepted. |
conversationLimit | How many conversations can a CFactory manage simultaneously |
myAgent | The agent owner of this factory |
Definition at line 44 of file CFactory.java.
{ this.name = name; this.filter = filter; this.availableConversations = new Semaphore(conversationsLimit, false); this.limit = conversationsLimit; this.myAgent = myAgent; this.myCProcessor = new CProcessor(this.myAgent); }
Returns the CProcessor that acts as template and will be cloned in order to create new CProcessors
Reimplemented in es.upv.dsic.gti_ia.jason.conversationsFactory.ConvCFactory.
Definition at line 90 of file CFactory.java.
{
return this.myCProcessor;
}
Returns this CFactory's message filter
Definition at line 76 of file CFactory.java.
{ try { return (MessageFilter) filter.clone(); }catch(Exception e){ return null; } }
Returns how many conversations can a CFactory manage simultaneously
Definition at line 58 of file CFactory.java.
{ return limit; }
String es.upv.dsic.gti_ia.cAgents.CFactory.getName | ( | ) |
Returns this CFactory's name
Definition at line 192 of file CFactory.java.
{ return this.name; }
boolean es.upv.dsic.gti_ia.cAgents.CFactory.isInitiator | ( | ) | [protected] |
Returns true if this is initiator, false if this is participant
Definition at line 184 of file CFactory.java.
{
return initiator;
}
Definition at line 196 of file CFactory.java.
{ //added by Bexy
myCProcessor = proc;
}
void es.upv.dsic.gti_ia.cAgents.CFactory.setFilter | ( | MessageFilter | template | ) |
void es.upv.dsic.gti_ia.cAgents.CFactory.setInitiator | ( | boolean | initiator | ) | [protected] |
Sets the type of the CFactory
initiator | True if this is a initiator CFactory, false if this is a participant one |
Definition at line 176 of file CFactory.java.
{ this.initiator = initiator; }
CProcessor es.upv.dsic.gti_ia.cAgents.CFactory.startConversation | ( | Queue< ACLMessage > | qMsg, |
CProcessor | parent, | ||
Boolean | isSync | ||
) | [protected] |
Creates a new CProcessor that will manage the new conversation
qMsg | Queue of initial messages |
parent | CProcessor that start this conversation and acts as parent |
isSync | True if it is synchronous, false otherwise |
Definition at line 101 of file CFactory.java.
{ CProcessor cloneProcessor = (CProcessor) myCProcessor.clone(); cloneProcessor.setConversationID(qMsg.peek().getConversationId()); cloneProcessor.setQueue(qMsg); cloneProcessor.setIdle(false); cloneProcessor.setFactory(this); cloneProcessor.setParent(parent); cloneProcessor.setIsSynchronized(isSync); cloneProcessor.setInitiator(this.initiator); myAgent.addProcessor(qMsg.peek().getConversationId(), cloneProcessor); myAgent.exec.execute(cloneProcessor); return (cloneProcessor); }
CProcessor es.upv.dsic.gti_ia.cAgents.CFactory.startConversationWithID | ( | String | id, |
CProcessor | parent, | ||
Boolean | isSync | ||
) | [protected] |
Creates a new CProcessor that will manage the new conversation
id | The conversation identifier of the new conversation |
parent | Parent CProcessor |
isSync | True if it is synchronous, false otherwise |
Definition at line 126 of file CFactory.java.
{ CProcessor cloneProcessor = (CProcessor) myCProcessor.clone(); cloneProcessor.setConversationID(id); //cloneProcessor.addMessage(msg); cloneProcessor.setIdle(false); cloneProcessor.setFactory(this); cloneProcessor.setParent(parent); cloneProcessor.setIsSynchronized(isSync); cloneProcessor.setInitiator(this.initiator); // setParentChildren(cloneProcessor); // ??? myAgent.addProcessor(id, cloneProcessor); myAgent.exec.execute(cloneProcessor); return (cloneProcessor); }
boolean es.upv.dsic.gti_ia.cAgents.CFactory.templateIsEqual | ( | ACLMessage | template | ) | [protected] |
Returns true if the message matches with the message filter
Reimplemented in es.upv.dsic.gti_ia.jason.conversationsFactory.ConvCFactory.
Definition at line 166 of file CFactory.java.
{ if(this.filter == null) return true; return this.filter.compareHeaders(template); }
Semaphore es.upv.dsic.gti_ia.cAgents.CFactory.availableConversations [package] |
Definition at line 26 of file CFactory.java.
int es.upv.dsic.gti_ia.cAgents.CFactory.limit [package] |
Definition at line 27 of file CFactory.java.
String es.upv.dsic.gti_ia.cAgents.CFactory.name [package] |
Definition at line 23 of file CFactory.java.