00001 /*************************************************************************** 00002 contextbase.h - Definition of ContextBase class. 00003 ------------------- 00004 begin : June 21 2002 00005 copyright : (C) 2003 by Vojtìch Toman 00006 email : vtoman@lit.cz 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00025 #ifndef CONTEXTBASE_H 00026 #define CONTEXTBASE_H 00027 00028 00029 #include "defs.h" 00030 #include "arithcodec.h" 00031 00032 00033 00039 enum ContextType 00040 { 00042 StaticContext, 00043 00045 DynamicContext 00046 }; 00047 00048 00049 00050 00051 00052 00056 class ContextBase 00057 { 00058 public: 00060 ContextBase(void) { initialized = false; } 00061 00063 enum OperationResult 00064 { 00066 Ok = 0, 00067 00069 NotKnown = -1, 00070 00072 TooManySymbols = -2, 00073 00075 NoMemory = -3 00076 }; 00077 00079 int endOfMessage; 00080 00081 00083 virtual void setType(int, ContextType) = 0; 00084 00086 virtual int initialize(void) = 0; 00087 00089 virtual int lastFixedSymbol(void) = 0; 00090 00092 virtual bool isInitialized(void) { return initialized; } 00093 00095 virtual void setArithCodec(ArithCodec *ac) { arithCodec = ac; } 00096 00098 virtual int encode(int) throw (ExaltContextNotInitializedException, ExaltIOException) = 0; 00099 00101 virtual int encodeEndOfMessage() throw (ExaltContextNotInitializedException, ExaltIOException)= 0; 00102 00104 virtual int decode(void) throw (ExaltContextNotInitializedException, ExaltIOException) = 0; 00105 00107 virtual int installSymbol(int) = 0; 00108 00110 virtual void purgeContext(void) = 0; 00111 00112 protected: 00114 ArithCodec *arithCodec; 00115 00117 bool initialized; 00118 }; //ContextBase 00119 00120 00121 #endif //CONTEXTBASE_H