00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef CMAP_H
00010 #define CMAP_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include "gtypes.h"
00019 #include "CharTypes.h"
00020
00021 #if MULTITHREADED
00022 #include "GMutex.h"
00023 #endif
00024
00025 class GString;
00026 struct CMapVectorEntry;
00027 class CMapCache;
00028
00029
00030
00031 class CMap {
00032 public:
00033
00034
00035
00036 static CMap *parse(CMapCache *cache, GString *collectionA,
00037 GString *cMapNameA);
00038
00039 ~CMap();
00040
00041 void incRefCnt();
00042 void decRefCnt();
00043
00044
00045 GString *getCollection() { return collection; }
00046
00047
00048
00049 GBool match(GString *collectionA, GString *cMapNameA);
00050
00051
00052
00053
00054 CID getCID(char *s, int len, int *nUsed);
00055
00056
00057 int getWMode() { return wMode; }
00058
00059 private:
00060
00061 CMap(GString *collectionA, GString *cMapNameA);
00062 CMap(GString *collectionA, GString *cMapNameA, int wModeA);
00063 void useCMap(CMapCache *cache, char *useName);
00064 void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
00065 void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end,
00066 Guint nBytes);
00067 void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
00068 void freeCMapVector(CMapVectorEntry *vec);
00069
00070 GString *collection;
00071 GString *cMapName;
00072 int wMode;
00073 CMapVectorEntry *vector;
00074
00075 int refCnt;
00076 #ifdef MULTITHREADED
00077 GMutex mutex;
00078 #endif
00079 };
00080
00081
00082
00083 #define cMapCacheSize 4
00084
00085 class CMapCache {
00086 public:
00087
00088 CMapCache();
00089 ~CMapCache();
00090
00091
00092
00093
00094
00095 CMap *getCMap(GString *collection, GString *cMapName);
00096
00097 private:
00098
00099 CMap *cache[cMapCacheSize];
00100 };
00101
00102 #endif