#include <Computable.h>
Inheritance diagram for util::Computable:

That is, Computable references can be used even though one does not know the actual types they point to.
Public Methods | |
| virtual SmartPtr< Computable > | plus (const Computable &c, bool switched=false) const throw (ComputationException&) |
| Calculate the sum of this and c. | |
| virtual SmartPtr< Computable > | minus (const Computable &c) const throw (ComputationException&) |
| Calculate the difference of this and c. | |
| virtual SmartPtr< Computable > | multiply (const Computable &c, bool switched=false) const throw (ComputationException&) |
| Calculate the product of this and c. | |
| virtual SmartPtr< Computable > | divide (const Computable &c) const throw (ComputationException&) |
| Calculate the quotient of this and c. | |
| virtual SmartPtr< Computable > | modulus (const Computable &c) const throw (ComputationException&) |
| Calculate the modulus of this and c. | |
| SmartPtr< Computable > | operator[] (const Computable &c) const throw (ComputationException&) |
| Array index operator calls arrayIndex(c). | |
| virtual SmartPtr< Computable > | arrayIndex (const Computable &c) const throw (ComputationException&) |
| If this is an array of something, then return the cth something. | |
| SmartPtr< Computable > | operator() (const Computable &c) const throw (ComputationException&) |
| Function call operator calls functionCall(c). | |
| virtual SmartPtr< Computable > | functionCall (const Computable &c) const throw (ComputationException&) |
| If this is a thing that can be called, then call it with c as a parameter. | |
| SmartPtr< Computable > | operator- () const throw (ComputationException&) |
| Negation operator calls negate(). | |
| virtual SmartPtr< Computable > | negate () const throw (ComputationException&) |
| If a negation can be defined for this, then return it. | |
| SmartPtr< Computable > | operator! () const throw (ComputationException&) |
| Complement operator calls complement(). | |
| virtual SmartPtr< Computable > | complement () const throw (ComputationException&) |
| If a complement can be defined for this, then return it. | |
| virtual int | compare (const Computable &c) const throw (ComputationException&) |
| Compare two computable objects. | |
| virtual SmartPtr< Computable > | less (const Computable &c) const throw (ComputationException&) |
| Check if this is less than c. | |
| virtual SmartPtr< Computable > | greater (const Computable &c) const throw (ComputationException&) |
| Check if this is greater than c. | |
| virtual SmartPtr< Computable > | lessOrEqual (const Computable &c) const throw (ComputationException&) |
| Check if this is less than or equal to c. | |
| virtual SmartPtr< Computable > | greaterOrEqual (const Computable &c) const throw (ComputationException&) |
| Check if this is greater than or equal to c. | |
| virtual SmartPtr< Computable > | equal (const Computable &c) const throw (ComputationException&) |
| Check if this is equal to c. | |
| virtual SmartPtr< Computable > | different (const Computable &c) const throw (ComputationException&) |
| Check if this is different from c. | |
| virtual SmartPtr< Computable > | logAnd (const Computable &c) const throw (ComputationException&) |
| Perform a logical and operation on this and c. | |
| virtual SmartPtr< Computable > | logOr (const Computable &c) const throw (ComputationException&) |
| Perform a logical or operation on this and c. | |
| virtual SmartPtr< Computable > | binAnd (const Computable &c) const throw (ComputationException&) |
| Calculate a binary AND operation on this and c. | |
| virtual SmartPtr< Computable > | binOr (const Computable &c) const throw (ComputationException&) |
| Calculate a binary OR operation on this and c. | |
| virtual SmartPtr< Computable > | binXor (const Computable &c) const throw (ComputationException&) |
| Calculate a binary XOR operation on this and c. | |
| virtual | operator bool () const throw (ComputationException&) |
| Cast a computable object to the primitive type 'bool'. | |
Protected Methods | |
| ComputationException | createException (std::string op, const Computable &c) const |
|
|
If this is an array of something, then return the cth something. As a default, if the parameter is a numeric type with a value of 0, then a clone of the object itself is returned. This way it is not necessary to distinguish between one-element vectors and scalars. |
|
|
Compare two computable objects. This method should return a negative number, zero, or a positive number if c is larger than, equal to or smaller than this, respectively. Override this method if a simple one-dimensional comparison is sufficient for your custom type. If not, then you must override the less, greater etc. methods. Reimplemented in util::Number. |
|
|
Check if this is different from c. The default return type is Boolean, and it is formed by calling compare(c). |
|
|
Calculate the quotient of this and c.
Reimplemented in util::Number. |
|
|
Check if this is equal to c. The default return type is Boolean, and it is formed by calling compare(c). |
|
|
Check if this is greater than c. The default return type is Boolean, and it is formed by calling compare(c). |
|
|
Check if this is greater than or equal to c. The default return type is Boolean, and it is formed by calling compare(c). |
|
|
Check if this is less than c. The default return type is Boolean, and it is formed by calling compare(c). |
|
|
Check if this is less than or equal to c. The default return type is Boolean, and it is formed by calling compare(c). |
|
|
Perform a logical and operation on this and c. The default implementation tries to cast both objects to the primitive type 'bool'. It then performs a logical and operation on the primitive types and returns a new Boolean object containing th result. |
|
|
Perform a logical or operation on this and c. The default implementation tries to cast both objects to the primitive type 'bool'. It then performs a logical or operation on the primitive types and returns a new Boolean object containing th result. |
|
|
Calculate the difference of this and c.
Reimplemented in util::Number. |
|
|
Calculate the modulus of this and c.
Reimplemented in util::Number. |
|
||||||||||||
|
Calculate the product of this and c.
Reimplemented in util::Number, and util::String. |
|
||||||||||||
|
Calculate the sum of this and c. Return a pointer to a newly allocated object which may be of any computable type. The caller is responsible for releasing the pointer. If switched is true, the result should be c + (this) instead of (this) + c, although for most types it should not make a difference. The switched helps developers as they do not need to implement the plus operation twice for any new type. The very same routine will calculate both String+Integer and Integer+String, for example, and there is no need to alter both classes.
Reimplemented in util::Number, and util::String. |