CASObject Class Reference

Pure abstract class from which almost any of the other classes are inherited. More...

#include <casobject.h>

Inheritance diagram for CASObject:

CASNumeric CASSymbolic CASTerm LongInt Fraction Variable Product Sum List of all members.

Public Member Functions

virtual CASObjectAbsolute () const =0
 Returns the object as absolute value.
virtual void AbsoluteIP ()=0
 Makes the absolute value of the object in place.
virtual CASObjectAdd (const CASObject *addend) const =0
 Adds another object to this.
 CASObject ()
 Constructor.
virtual CASObjectClone () const =0
 Clones the object.
virtual CASObjectDivide (const CASObject *divisor) const =0
 Divides this object by another.
virtual CASObjectEvaluate () const =0
 Evaluates the object.
virtual CASObjectGCD (const CASObject *o) const =0
 Computes the GCD of two objects.
virtual void Get (char *s, unsigned long size) const =0
 Retrieves the string representation of the object as a C string.
virtual void Get (std::string &s) const =0
 Retrieves the string representation of the object as a std::string.
virtual CASType GetType () const =0
 Returns the CAS Type of the object.
virtual CASObjectInvert () const =0
 Returns the inverse value of the object.
virtual void InvertIP ()=0
 Inverts the value of the object in place.
virtual bool IsEqual (const CASObject *o) const =0
 Tests whether two objects are equal.
virtual bool IsGT (const CASObject *o) const =0
 Tests whether one object is greater than another object.
virtual bool IsLT (const CASObject *o) const =0
 Tests whether one object is less than another object.
virtual bool IsOne () const =0
 Indicates whether or not the object is one.
virtual bool IsPureNumerical () const =0
 Indicates whether the object is a pure numerical object.
virtual bool IsSimilar (const CASObject *o) const =0
 Indicates whether or not another object is similar to this.
virtual bool IsZero () const =0
 Indicates whether or not the object is zero.
virtual unsigned long Length () const =0
 Returns the length of the object.
virtual CASObjectModulo (const CASObject *divisor) const =0
 Computes the modulus.
virtual CASObjectMultiply (const CASObject *factor) const =0
 Multiplies another object with this object.
virtual CASObjectPower (const CASObject *exponent) const =0
 Raises this object to the x-th power.
virtual void Print () const =0
 Prints the object to stdout.
virtual void Sort ()=0
 Provides a sorting interface.
virtual CASObjectSortWeight () const =0
 Determines the sort weight of two identical CASObject types.
virtual CASObjectSubtract (const CASObject *subtrahend) const =0
 Subtracts another object from this object.
virtual ~CASObject ()
 Destructor.

Public Attributes

CASObjectexponent
 The exponent of the ECAS object.
CASMetaInfo meta
 Object holding meta information regarding the object.

Static Public Attributes

static class CASGarbageGarbage = new CASGarbage()
 The object responsible for handling garbage.

Friends

class CASAbsoluteObjectIP
class CASInvertObjectIP

Detailed Description

This is the heart of ECAS. A pure abstract class from which most of the other classes are derived. It defines many pure abstract methods which have to be implemented by classes inheriting from this class.

Those methods provide a common interface to each ECAS class.

Definition at line 146 of file casobject.h.


Constructor & Destructor Documentation

CASObject::CASObject (  )  [inline]

Constructor. Initializes exponent to 0 ('zero').

Definition at line 532 of file casobject.h.

virtual CASObject::~CASObject (  )  [inline, virtual]

Destructor. Does nothing.

Definition at line 539 of file casobject.h.


Member Function Documentation

virtual CASObject* CASObject::Absolute (  )  const [pure virtual]

Gives the absolute form of the object. The pointer to the CASObject has to be freed by the caller.

Returns:
a CASObject* pointing to the absolute representation of the object. The caller is responsible for freeing the memory occupied by the newly created object.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual void CASObject::AbsoluteIP (  )  [pure virtual]

Makes the object absolute. In contrast to Absolute, this method makes the CASObject absolute in place, e.g. the object is modified.

Returns:
void

Implemented in CASNumeric, Fraction, Product, Sum, and Variable.

virtual CASObject* CASObject::Add ( const CASObject addend  )  const [pure virtual]

Performs an arithmetic addition on the object. The new CASObject returned has to be freed by the caller.

Parameters:
addend Pointer to a CASObject.
Returns:
a pointer to a CASObject holding the sum of this object and addend.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Clone (  )  const [pure virtual]

The Clone() function is responsible for cloning the object. This implies, creating a new copy of the object in the memory and returns a CASObject pointer to the newly created object. The caller is responsible for freeing the memory occupied by that object.

Returns:
a CASObject pointer to the newly created object.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Divide ( const CASObject divisor  )  const [pure virtual]

Performs an arithmetic division on the object. The new CASObject returned has to be freed by the caller.

Parameters:
divisor Pointer to a CASObject.
Returns:
a pointer to a CASObject holding the quotient of this object and divisor.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Evaluate (  )  const [pure virtual]

Evaluates the object and thus gives him the evaluated form. Evaluating means to bring the object into the simplest possible form.

However, evaluation is not done in-place. The method returns a new CASObject representing the evaluated form, which has to be delete from memory by the caller.

Returns:
a CASObject representing the evaluated form. The evaluated form is not necessarily of the same type as this object. Be aware!

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::GCD ( const CASObject o  )  const [pure virtual]

Computes the greatest common divisor of two CASObjects. The new CASObject returned has to be freed by the caller.

Parameters:
o Pointer to a CASObject.
Returns:
the gcd of this object and o.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual void CASObject::Get ( char *  s,
unsigned long  size 
) const [pure virtual]

Retrieves the string representation of the object as a C-type string.

Parameters:
s Pointer to a buffer for storing the string.
size Size of the buffer.
Returns:
void

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual void CASObject::Get ( std::string &  s  )  const [pure virtual]

Retrieves the string representation of the object as a std::string.

Parameters:
s Reference to a std::string which will receive the string representation.
Returns:
void

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASType CASObject::GetType (  )  const [pure virtual]

This method returns the type of the object. It should only be implemented by classes which are not abstract. It is used to determine the type of the object without relying on the RTTI information and thus avoiding unnecessary casts.

See castype.h for a complete list of supported values.

Returns:
an integer as defined in castype.h.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Invert (  )  const [pure virtual]

Gives the inverse form of the object. The pointer to the CASObject has to be freed by the caller.

Returns:
a pointer to a CASObject representing the inverted form of the object.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual void CASObject::InvertIP (  )  [pure virtual]

Inverts the object in place, e.g. the object is modified.

Returns:
void

Implemented in CASNumeric, Fraction, Product, Sum, and Variable.

virtual bool CASObject::IsEqual ( const CASObject o  )  const [pure virtual]

Tests whether this object and o are equal. Both objects have to be in their evaluated form.

Parameters:
o Pointer to a CASObject which is tested for equality.
Returns:
true if both objects are equal, false if they are not equal

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual bool CASObject::IsGT ( const CASObject o  )  const [pure virtual]

Tests whether this object is greater than o. Both objects have to be in their evaluated form.

Parameters:
o Pointer to a CASObject which this is tested against.
Returns:
true if this object is greater than o, false if this object is not greater than o.

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual bool CASObject::IsLT ( const CASObject o  )  const [pure virtual]

Tests whether this object is less than o. Both objects have to be in their evaluated form.

Parameters:
o Pointer to a CASObject which this is tested against.
Returns:
true if this object is less than o, false if this object is not less than o.

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual bool CASObject::IsOne (  )  const [pure virtual]

Indicates whether or not the object is 1 ('one') in its evaluated form.

Returns:
true if the object is equal one, false if it is another value.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual bool CASObject::IsPureNumerical (  )  const [pure virtual]

Indicates whether or not this object is a pure numerical object. An object is called pure numerical, if there is no symbolic component in it, e.g. '(a/2)' is not a pure numerical object, but '(2/3)' is. However, it might depend on the use of the class, what is considered pure numerical. But in most cases the afore mentioned convention is sufficient.

Returns:
true if this is a pure numerical object, false if it is not.

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual bool CASObject::IsSimilar ( const CASObject o  )  const [pure virtual]

Indicates whether or not another object is similar to this. This is not a strict mathematical function. For instance, '(a+b)' should be considered similar to '(a+b)^2' in its unevaluated form. This method is mostly used for collecting operands. What is considered similar depends on the usage of this method.

Parameters:
o pointer to a CASObject.
Returns:
true if this and o are similar, false otherwise.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual bool CASObject::IsZero (  )  const [pure virtual]

Indicates whether or not the object is 0 ('zero') in its evaluated form.

Returns:
true if the object is equal zero, false if it is another value.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual unsigned long CASObject::Length (  )  const [pure virtual]

Calculates the length of the object in its string representation.

Returns:
the length of the object if represented as string.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Modulo ( const CASObject divisor  )  const [pure virtual]

Computes the modulus of a (mod b) where a is this object and b is divisor. The new CASObject returned has to be freed by the caller.

Parameters:
divisor Pointer to a CASObject.
Returns:
a pointer to a CASObject holding the modulus.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Multiply ( const CASObject factor  )  const [pure virtual]

Performs an arithmetic multiplication on the object. The new CASObject returned has to be freed by the caller.

Parameters:
factor Pointer to a CASObject.
Returns:
a pointer to a CASObject holding the product of this object and factor.

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual CASObject* CASObject::Power ( const CASObject exponent  )  const [pure virtual]

Raises this object to the x-th power where x is exponent. The new CASObject returned has to be freed by the caller.

Parameters:
exponent Pointer to a CASObject.
Returns:
a pointer to a CASObject holding the x-th power of this object.

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual void CASObject::Print (  )  const [pure virtual]

Prints the string representation of the object to stdout.

Returns:
void

Implemented in Fraction, LongInt, Product, Sum, and Variable.

virtual void CASObject::Sort (  )  [pure virtual]

Sorts the object where applicable.

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual CASObject* CASObject::SortWeight (  )  const [pure virtual]

This method evolved from the circumstance, that if one sorts a list of CASObjects of the same type, it could be difficult to decide which one is greater than one other. Assume the case we have to sort the products '(a*b)' and '(a*c)' in a sum '(a*b)+(a*c)', we cannot decide which one is greater using the IsGT() or IsLT() method, we would have to alter its mathematical meaning. Therefore each descendant of the CASObject class has to define a SortWeight() method, returning an LongInt which is then used to decide how to sort.

Returns:
Although CASObject is the return type, it is assumed that it is a pointer to a LongInt. The caller is responsible for freeing the memory occupied by object.

Implemented in CASTerm, Fraction, LongInt, and Variable.

virtual CASObject* CASObject::Subtract ( const CASObject subtrahend  )  const [pure virtual]

Performs an arithmetic subtraction on the object. The new CASObject returned has to be freed by the caller.

Parameters:
subtrahend Pointer to a CASObject.
Returns:
a pointer to a CASObject holding the difference of this object and subtrahend.

Implemented in Fraction, LongInt, Product, Sum, and Variable.


Member Data Documentation

CASObject* CASObject::exponent

This object holds the exponent of the object. In any case, it is expected to be initialized to an appropriate value or an LongInt object with value 1 (`one').

Definition at line 155 of file casobject.h.

CASGarbage * CASObject::Garbage = new CASGarbage() [static]

Throughout ECAS, objects are deleted from memory by putting them into the garbage. The garbage trasher thread takes care of removing them from memory.

Definition at line 173 of file casobject.h.

CASMetaInfo CASObject::meta

See CASMetaInfo for the possible information stored in that object.

Definition at line 164 of file casobject.h.


The documentation for this class was generated from the following files:
Generated on Sun Dec 31 01:57:31 2006 for ECAS by  doxygen 1.4.7