001: /////////////////////////////////////////////////////////////////////////////

002: //Projectname         : 

003: //Filename                : UKPuzzleAdmin.h 

004: //Classname                : CIUKPuzzleAdmin

005: //                                : CUKPuzzleAdmin

006: //Author                : Ulrich Kraemer [uk]

007: //Date                        : 25.03.2003

008: //Changes                : 

009: //////////////////////////////////////////////////////////////////////////////

010: //Synchronization and error handling is not implemenmted yet

011: 
012: #ifndef UKPUZZLEADMIN_H
013: #define UKPUZZLEADMIN_H
014: 
015: #include "UKPuzzleDef.h"
016: #include "UKPuzzleCore.h"
017: 
018: //////////////////////////////////////////////////////////////////////////////

019: //puzzle administration class

020: class CIUKPuzzleAdmin
021: {
022:         public:
023:                 enum
024:                 {
025:                         enUndefined =0,
026:                         enRunning = 1,
027:                         enPaused = 2,        
028:                         enFinished= 3,
029:                         enError= 4,
030:                 };
031: 
032:                 enum 
033:                 {
034:                         enCmd_Start=1,
035:                         enCmd_Pause=2,
036:                         enCmd_Continue=3,
037:                         enCmd_Stop=4,
038:                 };
039:         protected:
040:                 CIUKPuzzleAdmin(long nFirstStoneOnPos_0=-1,long nLastStoneOnPos_0=-1,LPCTSTR szIniFileName="",LPCTSTR szOutputFileName="");
041:                 ~CIUKPuzzleAdmin();
042: 
043:         public:
044:                 DWORD GetSolutions();
045:                 DWORD GetProgressState();
046: 
047:                 //Commands

048:                 virtual UKPUZ_STATE StartPuzzle(DWORD nTime2Wait=UKPUZ_MAXWAITINGTIME); //Start Thread or Programm

049:                 virtual UKPUZ_STATE PausePuzzle(DWORD nTime2Wait=UKPUZ_MAXWAITINGTIME);
050:                 virtual UKPUZ_STATE ContinuePuzzle(DWORD nTime2Wait=UKPUZ_MAXWAITINGTIME);
051:                 virtual UKPUZ_STATE StopPuzzle(DWORD nTime2Wait=UKPUZ_MAXWAITINGTIME);
052: 
053:                 virtual UKPUZ_STATE CommandSetAndWait(DWORD Cmd,DWORD nTime2Wait);
054:         protected:
055:                 //Information Services

056:                 virtual void Write(LPCTSTR szOutText)=0;
057:                 virtual void WriteLn(LPCTSTR szOutText)=0;
058:                 virtual void SolutionFound()=0;
059: 
060:                 virtual void PuzzleIsRunning();
061:                 virtual void PuzzleHasPaused();
062:                 virtual void PuzzleHasFinished();
063:                 virtual void PuzzleHasStopped();
064: 
065:                 ///////////////////////

066:                 //must be publicated in a derived class

067:                 virtual void MainLoop();
068: 
069:         protected:
070:                 CUKPuzzleCore m_PuzzleCore;
071: 
072:                 DWORD        m_nCmd;
073:                 DWORD        m_nProgressState;
074: };
075: 
076: //////////////////////////////////////////////////////////////////////////////

077: //derived administration class

078: //is used to interact with the Window

079: class CUKPuzzleAdmin
080: :public CIUKPuzzleAdmin
081: {
082:         private:
083:                 CUKPuzzleAdmin();
084:                 CUKPuzzleAdmin(const CUKPuzzleAdmin&);
085:                 CUKPuzzleAdmin& operator=(const CUKPuzzleAdmin&);
086: 
087:         public:
088:                 CUKPuzzleAdmin(CWnd*,long nFirstStoneOnPos_0=-1,long nLastStoneOnPos_0=-1,LPCTSTR szIniFileName="",LPCTSTR szOutputFileName="");
089:                 ~CUKPuzzleAdmin();
090: 
091:         public:
092:                 //Commands

093:                 virtual UKPUZ_STATE StartPuzzle(DWORD nTime2Wait=UKPUZ_MAXWAITINGTIME);//Start thread

094:         protected:
095:                 //Information Services

096:                 virtual void Write(LPCTSTR szOutText);
097:                 virtual void WriteLn(LPCTSTR szOutText);
098:                 virtual void SolutionFound();
099: 
100:                 virtual void PuzzleIsRunning();
101:                 virtual void PuzzleHasPaused();
102:                 virtual void PuzzleHasFinished();
103:                 virtual void PuzzleHasStopped();
104:         private:
105:                 //Thread Function

106:                 static UINT __cdecl RunPuzzleAdmin(LPVOID pVoid);
107: 
108:                 CWnd*        m_pMessageReceiver;
109:         public:
110:                 //Test and Control functions

111: };
112: 
113: #endif