/*
 * --- GSMP-COPYRIGHT-NOTE-BEGIN ---
 * 
 * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
 * Please add additional copyright information _after_ the line containing
 * the GSMP-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
 * the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
 * 
 * GSMP: dam/utility/regtester/Operations.hh
 * General Sound Manipulation Program is Copyright (C) 2000 - 2004
 *   Valentin Ziegler and René Rebe
 * 
 * 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; version 2. A copy of the GNU General
 * Public License can be found in the file LICENSE.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT-
 * ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 * 
 * --- GSMP-COPYRIGHT-NOTE-END ---
 */
#include "OperationBase.hh"

template <typename RES, typename T, typename SEM>
class OP_Unary : public OP <RES>
{
public:
  OP_Unary (T* _f) {f = _f;}
  virtual RES Evaluate () {return SEM::Op (*f);}
private:
  T* f;
};

template <typename RES, typename T1, typename T2, typename SEM>
class OP_Binary : public OP <RES>
{
public:
  OP_Binary (T1* _a, T2* _b) {a = _a; b = _b;}
  virtual RES Evaluate () {return SEM::Op (*a, *b);}
private:
  T1* a;
  T2* b;
};

template <typename RES>
class ConstValue : public OP<RES>
{
public:
  ConstValue (RES i_value) {value = i_value;}
  virtual RES Evaluate () {return value;}
  RES value;
};


typedef OP<bool> BOP;
typedef OP<int> IOP;

class SEM_BOP_or
{
public:
  static bool Op (BOP& a, BOP& b) {return (a.Evaluate() || b.Evaluate());}
};

class SEM_BOP_xor
{
public:
  static bool Op (BOP& a, BOP& b) {return (a.Evaluate() ^ b.Evaluate());}
};

class SEM_BOP_and
{
public:
  static bool Op (BOP& a, BOP& b) {return (a.Evaluate() && b.Evaluate());}
};

class SEM_BOP_neg
{
public:
  static bool Op (BOP& f) {return (! f.Evaluate());}
};



class SEM_CMP_le
{
public:
  static bool Op (IOP& a, IOP& b) {return (a.Evaluate () < b.Evaluate ());}
};

class SEM_CMP_ge
{
public:
  static bool Op (IOP& a, IOP& b) {return (a.Evaluate () > b.Evaluate ());}
};

class SEM_CMP_eq
{
public:
  static bool Op (IOP& a, IOP& b) {return (a.Evaluate () == b.Evaluate ());}
};

class SEM_CMP_leq
{
public:
  static bool Op (IOP& a, IOP& b) {return (a.Evaluate () <= b.Evaluate ());}
};

class SEM_CMP_geq
{
public:
  static bool Op (IOP& a, IOP& b) {return (a.Evaluate () >= b.Evaluate ());}
};

class SEM_CMP_neq
{
public:
  static bool Op (IOP& a, IOP& b) {return (a.Evaluate () != b.Evaluate ());}
};




class SEM_IOP_add
{
public:
  static int Op (IOP& a, IOP& b) {return (a.Evaluate () + b.Evaluate ());}
};

class SEM_IOP_sub
{
public:
  static int Op (IOP& a, IOP& b) {return (a.Evaluate () - b.Evaluate ());}
};

class SEM_IOP_mul
{
public:
  static int Op (IOP& a, IOP& b) {return (a.Evaluate () * b.Evaluate ());}
};

class SEM_IOP_div
{
public:
  static int Op (IOP& a, IOP& b) {return (a.Evaluate () / b.Evaluate ());}
};

class SEM_IOP_mod
{
public:
  static int Op (IOP& a, IOP& b) {return (a.Evaluate () % b.Evaluate ());}
};

class SEM_IOP_neg
{
public:
  static int Op (IOP& f) {return (- f.Evaluate ());}
};


