vValue::Expr::Logic::Condition Class Reference

Stores two other values and returns one of them based on a specific condition. More...

#include <veLogic.h>

Inheritance diagram for vValue::Expr::Logic::Condition:

Inheritance graph
[legend]
Collaboration diagram for vValue::Expr::Logic::Condition:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Condition (BasePtr condvalue, BasePtr truevalue, BasePtr falsevalue)
 Basic constructor.
 Condition (Condition const &other)
 Copy constructor, will not work with any class except another Condition object.
virtual ~Condition ()
Basecopy (void) const
virtual Variant GetValue () const
virtual tString GetString (Base const *other=0) const
virtual int GetInt (void) const
virtual float GetFloat (void) const
bool operator== (Base const &other) const
 compares two values
bool operator!= (Base const &other) const
 compares two values
bool operator>= (Base const &other) const
 compares two values
bool operator<= (Base const &other) const
 compares two values
bool operator> (Base const &other) const
 compares two values
bool operator< (Base const &other) const
 compares two values

Protected Member Functions

Base const & GetExpr () const
 Performs the comparison.

Private Attributes

BasePtr m_condvalue
 The conditional value.
BasePtr m_truevalue
 The value that is used if the condition is true.
BasePtr m_falsevalue
 The value that is used if the condition is false.


Detailed Description

Stores two other values and returns one of them based on a specific condition.

Definition at line 41 of file veLogic.h.


Constructor & Destructor Documentation

vValue::Expr::Logic::Condition::Condition ( BasePtr  condvalue,
BasePtr  truevalue,
BasePtr  falsevalue 
)

Basic constructor.

Constructs a new Condition object with the given parameters

Parameters:
condvalue the value to be used as the condition
truevalue the value to be used if the condition is true
falsevalue the value to be used if the condition is false

Definition at line 47 of file veLogic.cpp.

Referenced by copy().

00047                                                                              :
00048         m_condvalue (condvalue ),
00049         m_truevalue (truevalue ),
00050         m_falsevalue(falsevalue)
00051 {
00052 }

Here is the caller graph for this function:

vValue::Expr::Logic::Condition::Condition ( Condition const &  other  ) 

Copy constructor, will not work with any class except another Condition object.

Initializes the Condition object using the information from another one

Parameters:
other another Condition object

Definition at line 56 of file veLogic.cpp.

00056                                            :
00057         Base        (other             ),
00058         m_condvalue (other.m_condvalue ->copy()),
00059         m_truevalue (other.m_truevalue ->copy()),
00060         m_falsevalue(other.m_falsevalue->copy())
00061 { }

virtual vValue::Expr::Logic::Condition::~Condition (  )  [inline, virtual]

Definition at line 51 of file veLogic.h.

00051 { };


Member Function Documentation

Base const & vValue::Expr::Logic::Condition::GetExpr (  )  const [protected]

Performs the comparison.

Uses a specific type (usually int or float) to perform the comparison

Parameters:
fun the return value of this function is used for the comparison
Returns:
a reference to either m_lvalue or m_rvalue based on if the condition is true or false

Definition at line 72 of file veLogic.cpp.

References m_condvalue, m_falsevalue, and m_truevalue.

Referenced by GetFloat(), GetInt(), GetString(), GetValue(), operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

00072                                      {
00073     bool truth = false;
00074     // In the future, we might want to define some kind of rules for truth
00075     try {
00076         truth = boost::lexical_cast<bool>(m_condvalue->GetValue());
00077     }
00078     catch(boost::bad_lexical_cast &) { }
00079     return truth ? *m_truevalue : *m_falsevalue;
00080 }

Here is the caller graph for this function:

Base * vValue::Expr::Logic::Condition::copy ( void   )  const [virtual]

Overwritten copy function

Returns:
a new copy of the current object

Reimplemented from vValue::Expr::Core::Base.

Definition at line 65 of file veLogic.cpp.

References Condition().

00065                                 {
00066     return new Condition(*this);
00067 }

Here is the call graph for this function:

Variant vValue::Expr::Logic::Condition::GetValue ( void   )  const [virtual]

Performs the comparison and returns the resulting value

Returns:
the result as a variant

Reimplemented from vValue::Expr::Core::Base.

Definition at line 84 of file veLogic.cpp.

References GetExpr(), and vValue::Expr::Core::Base::GetValue().

00084                                       {
00085     return GetExpr().GetValue();
00086 }

Here is the call graph for this function:

tString vValue::Expr::Logic::Condition::GetString ( Expr::Base const *  other = 0  )  const [virtual]

Performs the comparison and returns the resulting value

Returns:
the result as a string

Reimplemented from vValue::Expr::Core::Base.

Definition at line 102 of file veLogic.cpp.

References GetExpr(), and vValue::Expr::Core::Base::GetString().

00102                                                         {
00103     return GetExpr().GetString(other);
00104 }

Here is the call graph for this function:

int vValue::Expr::Logic::Condition::GetInt ( void   )  const [virtual]

Performs the comparison and returns the resulting value

Returns:
the result as an integer

Reimplemented from vValue::Expr::Core::Base.

Definition at line 90 of file veLogic.cpp.

References GetExpr(), and vValue::Expr::Core::Base::GetInt().

00090                                 {
00091     return GetExpr().GetInt();
00092 }

Here is the call graph for this function:

float vValue::Expr::Logic::Condition::GetFloat ( void   )  const [virtual]

Performs the comparison and returns the resulting value

Returns:
the result as a float

Reimplemented from vValue::Expr::Core::Base.

Definition at line 96 of file veLogic.cpp.

References GetExpr(), and vValue::Expr::Core::Base::GetFloat().

00096                                     {
00097     return GetExpr().GetFloat();
00098 }

Here is the call graph for this function:

bool vValue::Expr::Logic::Condition::operator== ( Base const &  other  )  const [virtual]

compares two values

Reimplemented from vValue::Expr::Core::Base.

Definition at line 106 of file veLogic.cpp.

References GetExpr().

00106 { return GetExpr() == other; }

Here is the call graph for this function:

bool vValue::Expr::Logic::Condition::operator!= ( Base const &  other  )  const [virtual]

compares two values

Reimplemented from vValue::Expr::Core::Base.

Definition at line 107 of file veLogic.cpp.

References GetExpr().

00107 { return GetExpr() != other; }

Here is the call graph for this function:

bool vValue::Expr::Logic::Condition::operator>= ( Base const &  other  )  const [virtual]

compares two values

Reimplemented from vValue::Expr::Core::Base.

Definition at line 108 of file veLogic.cpp.

References GetExpr().

00108 { return GetExpr() >= other; }

Here is the call graph for this function:

bool vValue::Expr::Logic::Condition::operator<= ( Base const &  other  )  const [virtual]

compares two values

Reimplemented from vValue::Expr::Core::Base.

Definition at line 109 of file veLogic.cpp.

References GetExpr().

00109 { return GetExpr() <= other; }

Here is the call graph for this function:

bool vValue::Expr::Logic::Condition::operator> ( Base const &  other  )  const [virtual]

compares two values

Reimplemented from vValue::Expr::Core::Base.

Definition at line 110 of file veLogic.cpp.

References GetExpr().

00110 { return GetExpr() >  other; }

Here is the call graph for this function:

bool vValue::Expr::Logic::Condition::operator< ( Base const &  other  )  const [virtual]

compares two values

Reimplemented from vValue::Expr::Core::Base.

Definition at line 111 of file veLogic.cpp.

References GetExpr().

00111 { return GetExpr() <  other; }

Here is the call graph for this function:


Member Data Documentation

BasePtr vValue::Expr::Logic::Condition::m_condvalue [private]

The conditional value.

Definition at line 42 of file veLogic.h.

Referenced by GetExpr().

BasePtr vValue::Expr::Logic::Condition::m_truevalue [private]

The value that is used if the condition is true.

Definition at line 43 of file veLogic.h.

Referenced by GetExpr().

BasePtr vValue::Expr::Logic::Condition::m_falsevalue [private]

The value that is used if the condition is false.

Definition at line 44 of file veLogic.h.

Referenced by GetExpr().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:05:55 2008 for Armagetron Advanced by  doxygen 1.5.4