# 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  

bool_assert.cpp

Go to the documentation of this file.
00001 /* Copyright, 2000 Nevrax Ltd.
00002  *
00003  * This file is part of NEVRAX <MODULE_NAME>.
00004  * NEVRAX <MODULE_NAME> is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2, or (at your option)
00007  * any later version.
00008 
00009  * NEVRAX <MODULE_NAME> is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012  * General Public License for more details.
00013 
00014  * You should have received a copy of the GNU General Public License
00015  * along with NEVRAX <MODULE_NAME>; see the file COPYING. If not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00017  * MA 02111-1307, USA.
00018  */
00019 
00020 #include "nel/ai/logic/bool_assert.h"
00021 #include "nel/ai/logic/boolval.h"
00022 #include "nel/ai/logic/fact.h"
00023 #include "nel/ai/logic/varset.h"
00024 
00025 namespace NLAILOGIC
00026 {
00027         using namespace NLAIAGENT;
00028 
00029         CBoolAssert::CBoolAssert( const IVarName &n, bool truth) : IBaseAssert( n )
00030         {
00031                 _Value = truth;
00032         }
00033         
00034         CBoolAssert::CBoolAssert( const CBoolAssert &a) : IBaseAssert( *a._Name)
00035         {
00036                 _Value = a._Value;
00037         }
00038 
00039         CBoolAssert::~CBoolAssert()
00040         {
00041         }
00042 
00043         void CBoolAssert::addFact(CVarSet *f)
00044         {
00045                 _Value =( (CBoolType *) (*f)[0] )->isTrue();            
00046         }
00047 
00048         void CBoolAssert::addFact(CFact *f)
00049         {
00050                 _Value =( (CBoolType *) f->getValue(0) )->isTrue();
00051         }
00052 
00053         void CBoolAssert::removeFact(CFact *f)
00054         {
00055                 _Value = ! ( (CBoolType *) f->getValue(0) )->isTrue();
00056         }
00057 
00058 
00059         void CBoolAssert::addFact(CValueSet *val)
00060         {
00061                 _Value =( (CBoolType *) val->getValue(0) )->isTrue();
00062         }
00063 
00064         bool CBoolAssert::isTrue() const
00065         {
00066                 return _Value;
00067         }
00068 
00069         const NLAIC::CIdentType &CBoolAssert::getType() const 
00070         {
00071                 return IdBoolAssert;
00072         }
00073 
00074         const NLAIC::IBasicType *CBoolAssert::clone() const
00075         {
00076                 CBoolAssert *clone = new CBoolAssert( *this );
00077                 return clone;
00078         }
00079 
00080         const NLAIC::IBasicType *CBoolAssert::newInstance() const
00081         {
00082           NLAIAGENT::CStringVarName x("");
00083                 CBoolAssert *instance = new CBoolAssert(x);
00084                 return instance;
00085         }
00086 
00087         void CBoolAssert::save(NLMISC::IStream &os)
00088         {
00089                 IObjetOp::save( os );
00090                 os.serial( (bool &) _Value );
00091         }
00092 
00093         void CBoolAssert::load(NLMISC::IStream &is)
00094         {
00095                 IObjetOp::load( is );
00096                 is.serial( _Value );
00097         }
00098 
00099 
00100         void CBoolAssert::getDebugString(std::string &text) const
00101         {
00102                 text += "<CBoolAssert> = ";
00103                 if ( _Value )
00104                         text += "true" ;
00105                 else
00106                         text += "false" ;
00107         }
00108 
00109         bool CBoolAssert::isEqual(const IBasicObjectIA &a) const
00110         {
00111                 return ( ((CBoolAssert &)a)._Value == _Value );
00112         }
00113 
00114         const IObjectIA::CProcessResult &CBoolAssert::run()
00115         {
00116                 return IObjectIA::ProcessRun;
00117         }
00118 
00119         sint32 CBoolAssert::nbVars() const
00120         {
00121                 return 0;
00122         }
00123 
00124         std::list<CFact *> *CBoolAssert::getFacts() const
00125         {
00126                 return new std::list<CFact *>;  
00127         }
00128 }