// $Source: /usr/local/SimSoft/SoftShop/Basics/Messager/Messager.h,v $
// $Revision: 1.20 $
// $Author: baum $
// $Date: 2001/11/29 15:52:23 $
//
// 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: Messager.h,v $
// Revision 1.20  2001/11/29 15:52:23  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//


#ifndef _MESSAGER_H
#define _MESSAGER_H  1


#include <stdarg.h>
#include <iostream.h>

#ifdef WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif


#ifdef _MESSAGER_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_BASICS_DLL
#  undef _impexp
#  define _impexp __declspec(dllexport)
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

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


//==================================================================
// define the type of the Message-Handler-function
//==================================================================

//##ModelId=3FBCBCC403B9
typedef int MsgHandleFunc (int msgType, const char* txt);


//==================================================================
//		Class-Header
//		for class Messager
//==================================================================

// these are the types of Messages that can be handled
enum { MSG_NONE = 0, MSG_ERROR = 1, MSG_WARNING = 2, MSG_STATUS };

//##ModelId=3FBCBCC403D8
class _impexp Messager
  {
  public:
    // constructor
	//##ModelId=3FBCBCC50000
    Messager ();

    // destructor
	//##ModelId=3FBCBCC50001
    ~Messager ();

    // prepare usage
	//##ModelId=3FBCBCC50002
    static void setup ();

    // end usage
	//##ModelId=3FBCBCC50004
    static void cleanup ();

    // query if initialized
	//##ModelId=3FBCBCC5000F
    static bool isInitialized ();

    // these are the heart of it
	//##ModelId=3FBCBCC50011
    static void Error   (const char* functionName, const char* format, ...);
	//##ModelId=3FBCBCC5001F
    static void Warning (const char* functionName, const char* format, ...);
	//##ModelId=3FBCBCC50024
    static void Status  (const char* format, ...);

    // these provide a stream-interface
	//##ModelId=3FBCBCC50031
    static ostrstream& ErrorS;
	//##ModelId=3FBCBCC50036
    static ostrstream& WarningS;
	//##ModelId=3FBCBCC50042
    static ostrstream& StatusS;

    // redirecting output
	//##ModelId=3FBCBCC50046
    static void setToLog ();
	//##ModelId=3FBCBCC5004F
    static void setMsgHdlFunc (MsgHandleFunc* hdlfunc);

    // indicate end of streamed Message and cause output (use like endl, ends)
	//##ModelId=3FBCBCC50052
    static ostream& endm (ostream&);

    // indicate end of streamed Error-Message
	//##ModelId=3FBCBCC5005E
    static ostream& ende (ostream&);

    // indicate end of streamed Warning-Message
	//##ModelId=3FBCBCC50061
    static ostream& endw (ostream&);

    // indicate end of streamed Status-Message
	//##ModelId=3FBCBCC5006E
    static ostream& endst (ostream&);

  protected:

  private:
    // copy constructor, declared but not defined
	//##ModelId=3FBCBCC50071
    Messager (const Messager&);

    // assignment operator, declared but not defined
	//##ModelId=3FBCBCC5007E
    Messager& operator = (Messager&);

    // used in Mode
	//##ModelId=3FBCBCC500BB
    enum ModeVals { RAW = 0, LOG = 1, HANDLER = 2 };

    // prepare output of next Message
	//##ModelId=3FBCBCC50080
    static void prepareError ();
	//##ModelId=3FBCBCC5008D
    static void prepareWarning ();
	//##ModelId=3FBCBCC5008F
    static void prepareStatus ();
    

    // data members
	//##ModelId=3FBCBCC5009D
    static unsigned       ClassMode;
	//##ModelId=3FBCBCC500A1
    static char*          ClassStr;
	//##ModelId=3FBCBCC500AC
    static MsgHandleFunc* ClassMsgHdlFunc;
  };	// class Messager


// indicate end of streamed Message and cause output (use like endl, ends)
_impexp ostream& endm (ostream&);


// global Messager-object so that users don't need to create their own ones
extern Messager _impexp Msg;


#endif // !_MESSAGER_H

//	$Filename: C:\Software\SoftShop\Basics\Messager\Messager.h $	ends
