// $Source: /usr/local/SimSoft/SoftShop/TestTool/Tester/Tester.h,v $
// $Revision: 1.20 $
// $Author: baum $
// $Date: 2001/11/29 15:52:24 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: Tester.h,v $
// Revision 1.20  2001/11/29 15:52:24  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//


#ifndef _TESTER_H
#define _TESTER_H


#include <stddef.h>


#ifdef _TESTER_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_TTOOL_DLL
#  undef _impexp
#  define _impexp
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUC__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif


// this first part deals with I/O-stuff

class _impexp Keyboard
  {
  public:
    static unsigned availableStrokes ();
    static void     clearBuf ();

    static void     hitReturn ();
    static void     setReturnText (char* newText);

  protected:
    // static data
    static char* ClassReturnText;
  };	// class Keyboard

extern Keyboard _impexp keyboard;


class _impexp Screen
  {
  public:
    static void moveCursorUp    (unsigned rows = 1);
    static void moveCursorDown  (unsigned rows = 1);
    static void moveCursorRight (unsigned cols = 1);
    static void moveCursorLeft  (unsigned cols = 1);

    static void placeCursor     (unsigned row = 1, unsigned col = 1);
    static void placeCursorHome ();
    static void clearCursorHome ();

    static void saveCursor      ();
    static void restoreCursor   ();

    static unsigned Lines ();
    static unsigned Columns ();

  protected:
    // static data
    static unsigned ClassLines;
    static unsigned ClassColumns;
  };	// class Screen

extern Screen screen;


class _impexp Terminal
  : public Keyboard, public Screen
  {
  public:
    // get information about the terminal type
    static bool isKnownType ();
    static const char* const TypeName ();

    // setting/cleaning things up
    static void setup ();
    static void cleanup ();
    static bool isInitialized ();

  private:
    // static data
    static char* ClassTypeName;
    static bool  ClassIsInitialized;
  };	// class Terminal

extern Terminal terminal;


// this second part deals with Testers

// maximum Number of Callbacks a Tester can hold
#define	MAXCALLBACKS	9

// define the type of the callback-functions
typedef void CallbackFunc ();

class MenuePoint;	// for class Tester's internal purposes

class _impexp Tester
  {
  public:
    // constructor
    Tester (char* headline = NULL, int stop = 1, int clear = 1, int home = 0);

    //destructor
    ~Tester ();

    // add a MenuePoint with the given callback and name, return non-0 on
    // success, else 0
    int addMenuePoint (CallbackFunc* callback, char* name);

    // remove the MenuePoint with the given (pointer to) callback
    // return non-0 on success, else 0
    int rmMenuePoint (CallbackFunc* callback);

    // remove the MenuePoint with the given name,
    // return non-0 on success, else 0
    int rmMenuePoint (char* name);

    // start the execution loop
    void loop ();

    // set the headline to newHeadline
    void setHeadline (char* newHeadline);

    // set the Stop-flag to newValue
    int setStop (int newValue);

    // return the current value of the Stop-flag
    int doesStop ();

    // set the Clear-flag to newValue
    int setClear (int newValue);

    // return the current value of the Clear-flag
    int doesClear ();

    // set the Home-flag to newValue
    int setHome (int newValue);

    // return the current value of the Home-flag
    int doesHome ();

  private:
    Tester (const Tester&);
    Tester& operator = (const Tester&);

    int rmMenuePoint (int pos);
    void displayMenue ();
    MenuePoint* selectMenuePoint ();

    // data members
    char* ObjHeadline;
    MenuePoint* ObjAction [MAXCALLBACKS + 1];
    unsigned ObjCounter;
    unsigned ObjFlags;
  };	// class Tester

#endif	// !defined _TESTER_H

//	$Filename: C:\Software\SoftShop\TestTool\Tester\Tester.h $	ends
