# 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  

fo_operator.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU NLIACeral Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * NLIACeral Public License for more details.
00019 
00020  * You should have received a copy of the GNU NLIACeral Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_FOOPERATOR_H
00027 #define NL_FOOPERATOR_H
00028 
00029 #include "nel/ai/agent/agent.h"
00030 #include "nel/ai/logic/operator.h"
00031 
00032 namespace NLAILOGIC
00033 {
00034         class IBaseVar;
00035         class IBaseBoolType;
00036         class IBaseAssert;
00037         class CFactPattern;
00038         class CVarSet;
00039         class CFact;
00040         class CValueSet;
00041 
00042         class CFirstOrderOperator : public IBaseOperator {
00043                 protected:
00044                         std::vector<IBaseVar *>                 _Vars;                          
00045                         std::vector< std::vector<sint32> >      _PosVarsCond;           
00046                         std::vector< std::vector<sint32> >      _PosVarsConc;           
00047 
00049                         void compileFactPattern (CFactPattern   *, std::vector<IBaseAssert *> &, std::vector<sint32> &);
00050 
00052                         sint32 CFirstOrderOperator::getVarPos(IBaseVar *var);
00053                         void getPosListForward(sint32, sint32, std::vector<sint32> &);
00054                         void getPosListBackward(sint32, sint32, std::vector<sint32> &);
00055                         void getAssertPos(IBaseAssert *, std::vector<IBaseAssert *> &, std::vector<sint32> &);
00056                         CValueSet *unifyBackward(std::list<CFact *> &);
00057                         CValueSet *unifyForward(std::list<CFact *> &);
00058 
00059                         // Buils a CFact from its assret and an instanciation for the values of the variables of the rule.
00060                         CFact *buildFromVars(IBaseAssert *, std::vector<sint32> &, CValueSet *);
00061 
00063                         std::list<CValueSet *> *propagate(std::list<CValueSet *> &, CValueSet *, std::vector<sint32> &);
00064 
00066                         CValueSet *unifyLiaison( const CValueSet *, CValueSet *, std::vector<sint32> &);
00067                         
00068                 public:
00069                         CFirstOrderOperator();
00070                         CFirstOrderOperator(const CFirstOrderOperator &);
00071                         ~CFirstOrderOperator();
00072 
00074                         std::list<CFactPattern   *> *forward(CFactPattern   *);
00075 
00077                         std::list<CFactPattern   *> *backward(CFactPattern   *);
00078 
00080                         void addPrecondition(CFactPattern   *);
00081 
00083                         void addPostcondition(CFactPattern   *);
00084 
00086                         std::list<CFact *> *backward(std::list<CFact *> &);
00087 
00089                         std::list<CFact *> *forward(std::list<CFact *> &);
00090 
00092                         std::list<CFact *> *propagate(std::list<CFact *> &);
00093 
00094                         virtual const NLAIC::IBasicType *clone() const;
00095                         virtual const NLAIC::IBasicType *newInstance() const;
00096                         virtual void save(NLMISC::IStream &os);
00097                         virtual void load(NLMISC::IStream &is);
00098                         virtual void getDebugString(std::string &) const;
00099                         virtual bool isEqual(const CFirstOrderOperator &a) const;
00100                         virtual const NLAIAGENT::IObjectIA::CProcessResult &run();
00101                         bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00102                         const NLAIC::CIdentType &getType() const;
00103 
00104                         virtual bool operator==(CFirstOrderOperator *);
00105 
00106                         static const NLAIC::CIdentType IdCFirstOrderOperator;
00107 
00108                         std::list<CFact *> *test(std::list<CFact *> &);
00109 
00111                         virtual bool isTrue() const;
00112                         virtual float truthValue() const;
00113                         virtual bool isValid(CFactBase *);
00114 
00115                         virtual float priority() const;
00116                         virtual void success();
00117                         virtual void failure();
00118                         virtual void success(IBaseOperator *);
00119                         virtual void failure(IBaseOperator *);
00120         };
00121 }
00122 #endif