Magentix2  2.1.1
es.upv.dsic.gti_ia.cAgents.CFactory Class Reference
Inheritance diagram for es.upv.dsic.gti_ia.cAgents.CFactory:
Collaboration diagram for es.upv.dsic.gti_ia.cAgents.CFactory:

List of all members.

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

Detailed Description

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

Definition at line 20 of file CFactory.java.


Constructor & Destructor Documentation

es.upv.dsic.gti_ia.cAgents.CFactory.CFactory ( String  name,
MessageFilter  filter,
int  conversationsLimit,
CAgent  myAgent 
)

Constructor of the class

Parameters:
nameName of the CFactory
filterMessage filter that specifies which type of messages can start new conversations. If this is null imply that all messages are accepted.
conversationLimitHow many conversations can a CFactory manage simultaneously
myAgentThe 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);
        }

Member Function Documentation

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

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

Returns:
the message filter that will make this CFactory to start new CProcessors. It can be null.

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

Returns:
conversation limit

Definition at line 58 of file CFactory.java.

                              {
                return limit;
        }

Returns this CFactory's name

Returns:
this CFactory's name

Definition at line 192 of file CFactory.java.

                               {
                return this.name;
        }

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

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;
        }

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

Parameters:
templatemessage filter that will make this CFactory to start new CProcessors

Definition at line 66 of file CFactory.java.

                                                      {
                this.myAgent.lock();
                this.filter = template;
                this.myAgent.unlock();
        }
void es.upv.dsic.gti_ia.cAgents.CFactory.setInitiator ( boolean  initiator) [protected]

Sets the type of the CFactory

Parameters:
initiatorTrue 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

Parameters:
qMsgQueue of initial messages
parentCProcessor that start this conversation and acts as parent
isSyncTrue if it is synchronous, false otherwise
Returns:
the new CProcessor just created

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

Parameters:
idThe conversation identifier of the new conversation
parentParent CProcessor
isSyncTrue if it is synchronous, false otherwise
Returns:
the new CProcessor just created

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);
        }

Returns true if the message matches with the message filter

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

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);
        }

Member Data Documentation

Definition at line 26 of file CFactory.java.

Definition at line 27 of file CFactory.java.

Definition at line 23 of file CFactory.java.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables