1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 1999-2001 Palm, Inc. or its subsidiaries.
All rights reserved.
This file is part of the Palm OS Emulator.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
\* ===================================================================== */
#ifndef _HORDES_H_
#define _HORDES_H_
#include "EmStructs.h" // HordeInfo, DatabaseInfoList
#include "EmTypes.h" // ErrCode
#include "CGremlins.h" // GremlinEventType
enum HordeFileType
{
kHordeProgressFile = 0x00,
kHordeRootFile = 0x01,
kHordeSuspendFile = 0x02,
kHordeEventFile = 0x03,
kHordeMinimalEventFile = 0x04,
kHordeAutoCurrentFile = 0x05
};
///////////////////////////////////////////////////////////////////////////////////////
// HORDES CLASS
class SessionFile;
// Gremlins::Save, Gremlins::Load
extern long gGremlinSaveFrequency;
extern DatabaseInfoList gGremlinAppList;
extern Bool gWarningHappened;
extern Bool gErrorHappened;
class Hordes
{
public:
static void Initialize (void);
static void Reset (void);
static void Save (SessionFile&);
static void Load (SessionFile&);
static void Dispose (void);
static void New (const HordeInfo& info);
// Support to run a "horde" of just a single Gremlin -- for example, from a session
// file load, or from a UI only supporting single Gremlins. "Gremlins classic":
static void NewGremlin (const GremlinInfo& info);
static void SaveSearchProgress (void);
static void ResumeSearchProgress (const EmFileRef& f);
static Bool IsOn (void);
static Bool InSingleGremlinMode (void);
static Bool QuitWhenDone (void);
static Bool CanNew (void);
static Bool CanSuspend (void);
static Bool CanStep (void);
static Bool CanResume (void);
static Bool CanStop (void);
static void Status (unsigned short* currentNumber,
unsigned long* currentStep,
unsigned long* currentUntil);
static void TurnOn (Bool hordesOn);
static int32 GremlinNumber (void);
static int32 EventCounter (void);
static int32 EventLimit (void);
static void StopEventReached (void);
static void ErrorEncountered (void);
static void RecordErrorStats (StrCode messageID = -1);
static void Suspend (void);
static void Step (void);
static void Resume (void);
static void Stop (void);
static string SuggestFileName (HordeFileType category, uint32 num = 0);
static EmFileRef SuggestFileRef (HordeFileType category, uint32 num = 0);
static void PostLoad (void);
static Bool PostFakeEvent (void);
static void PostFakePenEvent (void);
static Bool SendCharsToType (void);
static void BumpCounter (void);
static uint32 ElapsedMilliseconds (void);
static Bool CanSwitchToApp (UInt16 cardNo, LocalID dbID);
static void SetGremlinsHome (const EmDirRef& gremlinsHome);
static void SetGremlinsHomeToDefault(void);
static Bool GetGremlinsHome (EmDirRef& outPath);
static void AutoSaveState (void);
static void SaveSuspendedState (void);
static void SaveRootState (void);
static ErrCode LoadRootState (void);
static ErrCode LoadSuspendedState (void);
static void LoadEvents (void);
static void SaveEvents (void);
static void StartGremlinFromLoadedRootState (void);
static void StartGremlinFromLoadedSuspendedState(void);
static void SetGremlinStatePathFromControlFile (EmFileRef& controlFile);
static EmDirRef GetGremlinDirectory (void);
static void UseNewAutoSaveDirectory (void);
static DatabaseInfoList GetAppList (void);
static string TranslateErrorCode (UInt32 errCode);
private:
static void NextGremlin();
static void ProposeNextGremlin (long& outNextGremlin,
long& outNextDepth,
long inFromGremlin,
long inFromDepth);
static void EndHordes (void);
static ErrCode LoadState (const EmFileRef& ref);
static void StartLog (void);
static string GremlinsFlagsToString (void);
static void GremlinsFlagsFromString (string& inFlags);
static void ComputeStatistics (int32 &min,
int32 &max,
int32 &avg,
int32 &stdDev,
int32 &smallErrorIndex);
static void GremlinReport (void);
};
#endif /* _HORDES_H_ */
|