/* $Id$ */ /* * Copyright (C) 2006 Richard Braun * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _MTXVALUE_H #define _MTXVALUE_H #include /** * \def MTXVALUE_CLONE_METHOD_DECLARATION * \brief Allows easy decleration of clone() method in derived classes. */ #define MTXVALUE_CLONE_METHOD_DECLARATION(type) virtual type * clone() const /** * \def MTXVALUE_CLONE_METHOD * \brief Allows easy implementation of clone() method in derived classes. */ #define MTXVALUE_CLONE_METHOD(type) \ type * \ type::clone() const \ { \ type *new_object; \ new_object = new type; \ *new_object = *this; \ return new_object; \ } /** * Abstract class for values used by the engine. */ class MtxValue { public: virtual ~MtxValue(); /** * Return a string representation of the value. */ virtual std::string toString() const = 0; /** * Create a copy of the object and return its address. */ virtual MtxValue * clone() const = 0; /** * Add the current value with the given value and return the address of * the result. This result must be deleted by the caller. */ virtual MtxValue * add(const MtxValue *value) const = 0; /** * Subtract the given value from the current value and return the address * of the result. This result must be deleted by the caller. */ virtual MtxValue * subtract(const MtxValue *value) const = 0; /** * Multiply the current value by the given value and return the address * of the result. This result must be deleted by the caller. */ virtual MtxValue * multiply(const MtxValue *value) const = 0; /** * Divide the current value by the given value and return the address * of the result. This result must be deleted by the caller. */ virtual MtxValue * divide(const MtxValue *value) const = 0; /** * Return a pointer to the opposite of the value. * This pointer must be deleted by the caller. */ virtual MtxValue * opposite() const = 0; }; #endif /* _MTXVALUE_H */