#ifndef VISITBASE_H
#define VISITBASE_H

#include <cassert>
using namespace std;

#include <typedefs.h>

class visitbase
{
public:

  /** The default call says that w operator/data was not matched. */
  virtual boolc visit( visitbase & w ) 
    { return false; }

  /** Binary operator between the two objects. 
      Return true when a match was found (the expected case).*/
  boolc operator()(visitbase& x)
  {
    if( this->visit(x) )
      return true;
    return x.visit(*this);
  }

  boolc operator()(visitbase* x)
  {
    assert(x!=0);

    if( this->visit(*x) )
      return true;
    return x->visit(*this);
  }

  /** Cleanup */
  virtual ~visitbase() {}

};


#endif


