# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

operator_script.h

Go to the documentation of this file.
00001 
00008 /* Copyright, 2000 Nevrax Ltd.
00009  *
00010  * This file is part of NEVRAX NEL.
00011  * NEVRAX NEL 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, or (at your option)
00014  * any later version.
00015 
00016  * NEVRAX NEL is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00019  * General Public License for more details. 
00020 
00021  * You should have received a copy of the GNU General Public License
00022  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00023  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00024  * MA 02111-1307, USA.
00025  */
00026 
00027 #ifndef NL_OPERATOR_SCRIPT_H_
00028 #define NL_OPERATOR_SCRIPT_H_
00029 
00030 #include "nel/ai/agent/agent.h"
00031 #include "nel/ai/agent/agent_script.h"
00032 #include "nel/ai/agent/agent_manager.h"
00033 #include "nel/ai/logic/bool_cond.h"
00034 #include "nel/ai/script/type_def.h"
00035 #include "nel/ai/logic/interpret_object_operator.h"
00036 #include "nel/ai/agent/actor_script.h"
00037 
00038 /*
00039 namespace NLAILOGIC {
00040         class CValueSet;
00041 }
00042 */
00043 
00044 namespace NLAIAGENT
00045 {
00046         class COperatorScript  : public CActorScript
00047         {
00048                 protected:
00049                         enum c_funcs_id 
00050                         {
00051                                 fid_modeachieve,
00052                                 fid_modemaintain,
00053                                 fid_isPaused,
00054                                 fid_getPriority,
00055                                 fid_setPriority,
00056                                 fid_isActivable,
00057                                 fid_background,
00058                                 fid_exclusive,
00059                                 fid_achieve,
00060                                 fid_order,
00061                                 fid_last
00062                         };
00063 
00064                 private:
00065                         std::vector<NLAIAGENT::IObjectIA *> _VarValues;                         // Values of the vars for the instanciated operator
00066                         NLAILOGIC::CFactBase                            *_FactBase;                             // The father's factbase
00067                         NLAILOGIC::CGoal                                        *_CurrentGoal;
00068                         sint32                                                          _CyclesBeforeUpdate;    // Number of cycles before the preconditions are checked
00069                         std::list<NLAILOGIC::CGoal *>           _ActivatedGoals;
00070                         bool                                                            _IsActivable;
00071                         bool                                                            _Exclusive;
00072                         bool                                                            _Maintain;
00073                         float                                                           _Priority;
00074                         float                                                           _BasePriority;
00075                 public:
00076                         // Builds and actor with its father
00077                         COperatorScript(IAgentManager *, bool activated = false);
00078                         // copy constructor
00079                         COperatorScript(const COperatorScript &);
00080                         COperatorScript(IAgentManager *, IBasicAgent *, std::list<IObjectIA *> &, NLAISCRIPT::COperatorClass *);
00081                         virtual ~COperatorScript();
00082 
00084                         float priority() const;
00085                         void calcPriority();
00086 
00087 //                      virtual int getBaseMethodCount() const;
00088 
00090                         virtual const NLAIC::IBasicType *clone() const;
00091                         virtual const NLAIC::IBasicType *newInstance() const;
00092                         virtual void getDebugString(std::string &) const;
00093                         virtual bool isEqual(const IBasicObjectIA &a) const;
00094 //                      virtual void processMessages();
00095                         virtual bool checkActivation();
00096                         virtual const CProcessResult &run();
00097                         virtual void processMessages(NLAIAGENT::IMessageBase *msg,NLAIAGENT::IObjectIA *o);
00098 
00099 //                      virtual IObjectIA *run(const IMessageBase &msg);
00100 //                      virtual CProcessResult sendMessage(IObjectIA *);
00101                         virtual const NLAIC::CIdentType &getType() const;
00102 
00103                         static const NLAIC::CIdentType IdOperatorScript;
00104 
00105                         virtual void save(NLMISC::IStream &os);         
00106                         virtual void load(NLMISC::IStream &is);         
00107 
00108                         virtual IObjectIA::CProcessResult runMethodBase(int heritance, int index,IObjectIA *);
00109                         virtual IObjectIA::CProcessResult runMethodBase(int index,IObjectIA *);
00110 
00111 //                      virtual tQueue isMember(const NLAIAGENT::IVarName *, const NLAIAGENT::IVarName *, const IObjectIA &) const;
00112 
00113                         tQueue getPrivateMember(const IVarName *,const IVarName *,const IObjectIA &) const;
00114                         virtual sint32 getMethodIndexSize() const;
00115                         virtual int getBaseMethodCount() const;
00116 
00117                         virtual void onKill(IConnectIA *a);
00118 
00119                         void getFatherComponent(IVarName &);
00120 
00122                         void linkGoalArgs(NLAILOGIC::CGoal *);
00123         
00125                         virtual NLAILOGIC::CGoal *selectGoal();
00126 
00127                         virtual void cancel();
00128 //                      virtual bool isActive();
00129 
00130                         virtual void onSuccess( IObjectIA *);
00131                         virtual void onFailure( IObjectIA *);
00132 
00133                         // Tries to unify the facts
00134                         NLAILOGIC::CFact *buildFromVars(NLAILOGIC::IBaseAssert *, std::vector<sint32> &, NLAILOGIC::CValueSet *);
00135                         std::list<NLAILOGIC::CValueSet *> *propagate(std::list<NLAILOGIC::CValueSet *> &, NLAILOGIC::CValueSet *, std::vector<sint32> &);
00136                         std::list<NLAILOGIC::CFact *> *propagate(std::list<NLAILOGIC::CFact *> &);
00137                         NLAILOGIC::CValueSet *unifyLiaison( const NLAILOGIC::CValueSet *, NLAILOGIC::CValueSet *, std::vector<sint32> &);
00138 
00139                         void lookForGoals();
00140                         bool checkPreconditions();
00141                         void execOnActivate();
00142                         void checkPause();
00143                         bool isExclusive();
00144                         void setPriority(float prio);
00145 
00146                         virtual bool checkTrigMsg();
00147 
00148                         virtual void order( NLAIAGENT::IBaseGroupType *, NLAILOGIC::IGoal *);
00149         };
00150 }
00151 #endif