Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

agent.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           agent.h  -  description
00003                              -------------------
00004     begin                : Mon Dec 3 2001
00005     copyright            : (C) 2001 by Vlad Mereuta
00006     email                : dizzy@deity.fsnet.co.uk
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020 
00021 #ifndef AGENT_H
00022 #define AGENT_H
00023 
00024 #include <vector>
00025 
00026 #include <dalt_client/entity.h>
00027 #include <dalt_client/action.h>
00028 #include <dalt_client/sense.h>
00029 #include <dalt_client/dalt_client.h>
00030 #include <dalt_client/run_time_info.h>
00031 
00032 #include <zthread/Thread.h>
00033 #include <zthread/Semaphore.h>
00034 #include <zthread/Mutex.h>
00035 #include <zthread/LockedQueue.h>
00036 #include <zthread/Guard.h>
00037 
00038 namespace DALT_Client {
00039 
00040 using namespace ZThread;
00041 using namespace std;
00042 
00049 class Agent : public Entity, public Thread
00050 {
00051 protected:
00053     static Mutex        agent_sync;
00055     Mutex           stay_alive_mutex;
00057     Mutex           method_mutex;
00059     vector<Sense*>  senses;
00061     float               fitness;
00063     bool            is_clonable;
00065     DALTClient*     dalt_client;
00067     Semaphore*      locker;
00069     SOAPMethod* state_change_method;
00070     
00072     bool            stay_alive;
00074     LockedQueue<Action*>            action_queue;
00075 public: 
00076 //  SOAPProxy*  endpoint;
00077 
00079     RunTimeInfo rti;
00080 
00085     Agent(string type, int id, DALTClient* client);
00087     ~Agent();
00088     
00090     virtual void addSense(Sense* sense);
00091     
00094     virtual void senseAndAct()=0;
00095     
00098     virtual void    newCycle();
00099     
00102     virtual void    finishedCycle();
00103     
00106     virtual int executeAction(Action& action)=0;
00109     virtual void    queueAction(Action* act);
00110     
00115     virtual void    clone();
00116     
00118     virtual void kill() throw (Synchronization_Exception);
00119     
00122     virtual void    run() throw();
00123 };
00124 
00125 }
00126 
00127 #endif

Generated at Thu Jan 31 15:20:07 2002 for DALT Client by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001