//==================================================================================================
// D i s p l a y                                                                          Interface
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library 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 Library General Public License for more details (http://www.gnu.org).

/*DESCRIPTION*/
/* This module provides an abstract class representing a display for the B++ Library. A default
   subclass is provided in the <CODE>Display/Console</CODE> module where the display is performed
   through the standard output stream. If you want the display in a graphic window, you have to
   write your own subclass. For more information, see "How to Create a Program Based on the
   B++ Library ?". */

// File Name //-------------------------------------------------------------------------------------
#line __LINE__ "display.hpp"

// Guardian //--------------------------------------------------------------------------------------
#ifndef guDisplay
#define guDisplay

// Headers //---------------------------------------------------------------------------------------
#include <cstdlib> /*INCLUDE*/
#include <fstream> /*INCLUDE*/
#include <bpp/standard/keyword.hpp> /*INCLUDE*/

namespace bpp {

// Importation/Exportation //-----------------------------------------------------------------------
#ifdef DISPLAY_DLL
 #define dll_export DLL_EXPORT
#else
 #define dll_export DLL_IMPORT
#endif

// Namespaces //------------------------------------------------------------------------------------
#define public_area  display
#define private_area display_private

namespace public_area  { /*NAMESPACE*/ using namespace standardKeyword; }
namespace private_area { using namespace public_area; }

// Macrocommands //---------------------------------------------------------------------------------

// Types & Classes //-------------------------------------------------------------------------------
namespace public_area {
 //------------------------------------------------------------------------------------------Classes
 class clDisplay;
 //-----------------------------------------------------------------------------------Variable Types
 /*TYPE*/ /* Character (signed or unsigned integer). */
 typedef CHARACTER_TYPE tyCharacter;

 /*TYPE*/ /* Program result (<CODE>success</CODE> or <CODE>failure</CODE>). */
 enumeration { success, failure } tyProgramResult;

 /*TYPE*/ /* Standard return type of the basic C functions. */
 typedef RETURN_TYPE tyReturn;

 /*TYPE*/ /* Array of characters. */
 typedef tyCharacter * tyString;
 //-----------------------------------------------------------------------------------Constant Types
 typedef const clDisplay ctDisplay;

 typedef const tyCharacter     tcCharacter;
 typedef const tyProgramResult tcProgramResult;
 typedef const tyReturn        tcReturn;
 typedef const tyCharacter *   tcString;
}

namespace private_area { typedef std::ofstream clOutFile; }

// Functions Interface //---------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// Errors //----------------------------------------------------------------------------------------
namespace public_area {}

// Constants & Variables //-------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// D i s p l a y  Interface //----------------------------------------------------------------------
namespace public_area {
 /*CLASS clDisplay */
 /* Represents a display in text mode. It is an abstract class. */
 class clDisplay {
  //-----------------------------------------------------------------------------------------Private
  private_property private_area::clOutFile atOutputFile;

  private_property constructor clDisplay(const clDisplay &);
  private_property clDisplay & operator = (ctDisplay &);
  //------------------------------------------------------------------------------------------Public
  /*ATTRIBUTE clDisplay */ /* Current non terminated line of the display. */
  read_only_attribute(tyString,atCurrentLine,currentLine);

  /*ATTRIBUTE clDisplay */ /* Name of the output file that mirrors the display. */
  read_only_attribute(tcString,atOutputFileName,outputFileName);

  /*ATTRIBUTE clDisplay */ /* Name of the file containing the parameters of the library. */
  read_only_attribute(tcString,atParameterFileName,parameterFileName);

  public_property constructor clDisplay(void);
  public_property virtual destructor clDisplay(void);

  /*AMETHOD clDisplay */ /* Activates the display, if not already done. Abstract method. */
  public_property virtual void activate(void) = 0;

  /*AMETHOD clDisplay */ /* Closes the display. Abstract method. */
  public_property virtual void close(void) = 0;

  /*AMETHOD clDisplay */ /* Jumps to the next line. Abstract method. */
  public_property virtual void nextLine(void) = 0;

  /*AMETHOD clDisplay */ /* Opens the display. Abstract method. */
  public_property virtual void open(void) = 0;

  /*AMETHOD clDisplay */ /* Quits the program. Abstract method. */
  public_property virtual tyReturn quit(tyProgramResult agResult) = 0;

  /*AMETHOD clDisplay */ /* Refreshes the display. Abstract method. */
  public_property virtual void refresh(void) = 0;
 };
}

// Functions Inline //------------------------------------------------------------------------------
namespace public_area  {}
namespace private_area {}

// D i s p l a y  Inline //-------------------------------------------------------------------------
namespace public_area {
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD clDisplay */ /* Builds a display. */
 inline clDisplay::clDisplay(void)
 : atOutputFile(),atCurrentLine(nil),atOutputFileName(nil),atParameterFileName(nil) {}
 //---------------------------------------------------------------------------------------Destructor
 /*METHOD clDisplay */ /* Destructs the display. */
 inline clDisplay::~clDisplay(void) {}
}

// End //-------------------------------------------------------------------------------------------
}
#undef dll_export
#undef public_area
#undef private_area
#endif