home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Console_h__
- #define __Console_h__
-
- #include "stdio.h"
-
- #define CON_MAX_CVARS 128
- #define CON_MAX_CCMDS 128
- #define CON_MAX_ALIASES 128
-
- //#define CON_FLAG_READ 0x0001
- //#define CON_FLAG_WRITE 0x0002
- //#define CON_FLAG_EXECUTE 0x0004
- //
- //#define CON_FLAG_CLIENT_READ 0x0001
- //#define CON_FLAG_CLIENT_WRITE 0x0002
- //#define CON_FLAG_CLIENT_EXECUTE 0x0004
- //
- //#define CON_FLAG_SERVER_READ 0x0008
- //#define CON_FLAG_SERVER_WRITE 0x000f
- //#define CON_FLAG_SERVER_EXECUTE 0x0010
-
- #define CON_FLAG_SYSTEM 0x0001
- #define CON_FLAG_USER 0x0002
- #define CON_FLAG_READ_ONLY 0x0004
-
- #define CON_FLAG_ALL_SET 0xffff
- #define CON_FLAG_NONE_SET 0x0000
-
- #define CON_MAX_LINES 1024
- #define CON_MAX_HISTORY_LINES 256
- #define CON_MAX_STRING_LENGTH 256
-
-
- class CVar;
- class CCmd;
- class CAlias;
-
- class Console{
- public:
- CVar* cVars[CON_MAX_CVARS]; /* list with all registered cvars */
- CCmd* cCmds[CON_MAX_CCMDS]; /* list with all registered ccmds */
- CAlias* aliases[CON_MAX_ALIASES]; /* list with all registered aliases */
- char* lines[CON_MAX_LINES]; /* array that holds ALL in-/output */
- // char* historyLines[CON_MAX_HISTORY_LINES]; /* input history */
-
- unsigned short accessFlags; // THINKABOUTME: private?
-
- Console(); /* */
- ~Console(); /* */
-
- void input(const char* inputStr); /* */
- void print(const char* formatString,...); /* prints a format string on the console */
- bool parse(const char* parseStr); /* parses a string (i.e. executes the ccmds stored in it)*/
- void clear(); /* clears all console lines (output) */
- // void clearHistory(); /* clears input history */
-
- bool registerCVar(CVar *cVar); /* registers a CVar; after that the console can work with it. */
- bool unregisterCVar(CVar *cVar); /* this takes a CVar 'out of' the console (i.e. it is not known any more) */
- bool deleteCVar(CVar *cVar); /* this really DELETES a CVar completely */
- CVar* getCVar(const char* name); /* returns the CVar named 'name' or NULL if none exists */
- bool registerCCmd(CCmd *cCmd); /* the following function do the same as their CVar counterparts */
- bool unregisterCCmd(CCmd *cCmd);
- bool deleteCCmd(CCmd *cCmd);
- CCmd* getCCmd(const char* name);
- bool registerAlias(CAlias *alias); /* the following function do the same as their CVar counterparts */
- bool unregisterAlias(CAlias *alias);
- bool deleteAlias(CAlias *alias);
- CAlias* getAlias(const char* name);
-
- bool hasAccessToCVar(CVar* cVar, unsigned int desiredAccess); /* checks whether or not the console has acces to a CVar */
- bool hasAccessToCCmd(CCmd* cCmd, unsigned int desiredAccess); /* dito */
-
- bool logOutput;
-
- void startLog(const char* filename);
- void endLog();
-
- protected:
- FILE* logFile;
-
- void appendLine(const char* line); /* appends a line to the consoles output */
- // void appendHistoryLine(const char* line); /* appends a line to the consoles input history */
- };
-
- extern Console* console;
-
- #endif /* __Console_h__ */
-