Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

AIWrapper.h

Go to the documentation of this file.
00001 
00002 //      Copyright (C) 2004 Dylan Blair
00003 //
00004 //      email: dblair@alumni.cs.utexas.edu
00005 //
00006 //      This library is free software; you can redistribute it and/or
00007 //      modify it under the terms of the GNU Lesser General Public
00008 //      License as published by the Free Software Foundation; either
00009 //      version 2.1 of the License, or (at your option) any later version.
00010 //
00011 //      This library is distributed in the hope that it will be useful,
00012 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //      Lesser General Public License for more details.
00015 //
00016 //      You should have received a copy of the GNU Lesser General Public
00017 //      License along with this library; if not, write to the Free Software
00018 //      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 #ifndef AIWRAPPER_H
00022 #define AIWRAPPER_H
00023 
00024 #include "AIManager.h"
00025 #include <assert.h>
00026 
00037 class AIWrapper {
00038         struct AIFSMWrapper {
00039                 AIFSM*         _FSM;
00040                 AIState*       _state;
00041                 float          _timeStampStateChange;
00042                 AI_FSM_IDS     _index;
00043                 bool           _isEnabled;
00044 
00045                 AIFSMWrapper();
00046         };
00047 
00048         AIFSMWrapper               _FSMs[AI_FSM_MAX];
00049         std::stack<AIFSMWrapper*>  _stackFSMs;
00050         AI_FSM_IDS                 _currFSMIndex;
00051         AIKB*                      _kb;
00052         bool                       _wasKBCreatedHere;
00053         AILogic*                   _logic;
00054 public:
00058         AIWrapper();
00059 
00061 
00067         virtual void init(AI_LOGIC_IDS LOGICID_, AI_FSM_IDS FSMID_, AIState* state_);
00071         virtual void init(AI_LOGIC_IDS LOGICID_, AI_FSM_IDS FSMID_, AIState* state_, AIKB* kb_);
00073 
00078         virtual bool performLogic(bool includeglobalkb_=false); 
00079 
00083         AIState* getCurrentState() const { return _FSMs[_currFSMIndex]._state; }
00084 
00089         void enableFSM(AI_FSM_IDS FSMID_, AIState* state_=0);
00090 
00094         void disableFSM(AI_FSM_IDS FSMID_) { _FSMs[FSMID_]._isEnabled = false; }
00095 
00105         bool setFSM(AI_FSM_IDS FSMID_, AIState* state_=0, bool autoEnable_=true); //< returns true if successful, false otherwise
00106 
00110         AI_FSM_IDS getFSM() { return _currFSMIndex; }
00111 
00121         bool pushFSM(AI_FSM_IDS FSMID_, AIState* state_=0, bool autoEnable_=true); //< returns true if successful, false otherwise
00122 
00127         bool popFSM(); //< returns true if the current AIFSM changes, false otherwise
00128 
00132         bool setLogic(AI_LOGIC_IDS LOGICID_); //< returns true if successful, false otherwise
00133 
00137         AI_LOGIC_IDS getCurrentLOGICID() { return _logic->getLOGICID(); }
00138 
00142         AIKB* getKB() const { return _kb; }
00143 
00144         virtual void doAction(); 
00145 
00149         virtual ~AIWrapper();
00150 };
00151 
00152 extern bool usedHeap;
00153 
00158 void initAIEngine(std::ifstream* fin_=0);
00159 
00160 void destroyAIEngine();
00161 
00167 void popAllAIExceptions(bool only_add_new=false, bool remove_all=false);
00168 
00169 #endif //AIWRAPPER_H

Generated on Sun Apr 11 05:05:56 2004 for FSM_API by doxygen 1.3.6