# 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  

boolval.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/boolval.h"
00021 
00022 namespace NLAILOGIC
00023 {
00024         using namespace NLAIAGENT;
00025 
00026 
00027         IBaseBoolType::IBaseBoolType() 
00028         {                       
00029         }
00030 
00031         IBaseBoolType::~IBaseBoolType()
00032         {
00033         }       
00034 
00035 // ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00036 // ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00037 
00038 
00039         
00040 
00041         CBoolType::CBoolType(bool value) : _Value( value )
00042         {
00043         }
00044 
00045         CBoolType::CBoolType(const CBoolType &cp)
00046         {
00047                 _Value = cp._Value;
00048         }
00049 
00050         CBoolType::~CBoolType()
00051         {
00052         }
00053         
00054         const NLAIC::IBasicType *CBoolType::clone() const
00055         {
00056                 NLAIC::IBasicInterface *m = new CBoolType( *this );
00057                 return m;
00058         }
00059 
00060         const NLAIC::IBasicType *CBoolType::newInstance() const
00061         {
00062 
00063                 return clone();
00064         }
00065 
00066 
00067         void CBoolType::save(NLMISC::IStream &os)
00068         {                       
00069                 IObjectIA::save(os);
00070                 os.serial( (bool &) _Value );
00071         }
00072 
00073         void CBoolType::load(NLMISC::IStream &is)
00074         {
00075                 IObjectIA::load( is );
00076 //              is >> _Value;   
00077         }
00078 
00079         void CBoolType::getDebugString(std::string &text) const
00080         {
00081                 text += "CBoolType<";
00082                 if ( _Value )
00083                         text += "true";
00084                 else
00085                         text += "false";
00086                 text += ">";
00087         }
00088 
00089         bool CBoolType::isTrue() const
00090         {
00091                 return _Value;
00092         }
00093 
00094         float CBoolType::truthValue() const
00095         {
00096                 if ( _Value )
00097                         return 1.0;
00098                 else
00099                         return 0.0;
00100 
00101         }
00102 
00103         const IObjectIA::CProcessResult &CBoolType::run()
00104         {
00105                 return IObjectIA::ProcessRun;
00106         }
00107 
00108         bool CBoolType::isEqual(const CBoolType &a) const
00109         {
00110                 return ( a._Value == _Value );
00111         }
00112 
00113         bool CBoolType::isEqual(const IBasicObjectIA &a) const
00114         {
00115                 return ( ((CBoolType &)a)._Value == _Value );
00116         }
00117 
00118         std::vector<IBaseVar *> *CBoolType::getVars()
00119         {
00120                 return NULL;
00121         }
00122 
00123         const NLAIC::CIdentType &CBoolType::getType() const
00124         {
00125                 return IdBoolType;
00126         }
00127 
00128         IObjetOp &CBoolType::operator += (const IObjetOp &a)
00129         {
00130                 _Value = _Value || ((CBoolType &)a)._Value;
00131                 return ( *this );
00132         }
00133 
00134         IObjetOp &CBoolType::operator -= (const IObjetOp &a)
00135         {
00136                 _Value = _Value && ((CBoolType &)a)._Value;
00137                 return ( *this );
00138         }
00139 
00140         IObjetOp &CBoolType::operator *= (const IObjetOp &a)
00141         {
00142                 _Value = _Value ^ ((CBoolType &)a)._Value;
00143                 return ( *this );
00144         }
00145 
00146 
00147         IObjetOp *CBoolType::operator < (IObjetOp &a) const
00148         {
00149                 CBoolType *result = new CBoolType( _Value && !((CBoolType &)a)._Value );
00150                 return result;
00151         }
00152 
00153         IObjetOp *CBoolType::operator > (IObjetOp &a) const
00154         {
00155                 CBoolType *result = new CBoolType( !_Value && ((CBoolType &)a)._Value );
00156                 return result;
00157         }
00158 
00159         IObjetOp *CBoolType::operator <= (IObjetOp &a) const
00160         {
00161 
00162                 CBoolType *result = new CBoolType( !_Value || ((CBoolType &)a)._Value );
00163                 return result;
00164         }
00165 
00166         IObjetOp *CBoolType::operator >= (IObjetOp &a) const
00167         {
00168                 CBoolType *result = new CBoolType( _Value || !((CBoolType &)a)._Value );
00169                 return result;
00170         }
00171 
00172         IObjetOp *CBoolType::operator ! () const
00173         {
00174                 CBoolType *result = new CBoolType( !_Value );
00175                 return result;
00176         }
00177 
00178         IObjetOp *CBoolType::operator != (IObjetOp &a) const
00179         {
00180                 // Le truc pas beau qui embête Sam qui fait que des trucs beaux:
00181                 CBoolType *result = new CBoolType( _Value ^ ((CBoolType &)a)._Value );
00182                 return result;
00183         }
00184 
00185         CBoolTrue::CBoolTrue() : CBoolType( true )
00186         {
00187         }
00188 
00189         CBoolFalse::CBoolFalse() : CBoolType( false )
00190         {
00191         }
00192 
00193         IObjetOp *CBoolType::operator == (IObjetOp &a) const
00194         {
00195                 CBoolType *result = new CBoolType( _Value == ((CBoolType &)a)._Value );
00196                 return result;
00197         }
00198 }