00001
00002
00003
00004
00005 #ifndef DSMCC_CACHE_H
00006 #define DSMCC_CACHE_H
00007
00008 #include <QStringList>
00009 #include <QMap>
00010
00011 class BiopBinding;
00012
00013 class DSMCCCacheFile;
00014 class DSMCCCacheDir;
00015 class DSMCCCache;
00016 class Dsmcc;
00017
00018 class DSMCCCacheKey: public QByteArray
00019 {
00020 public:
00021 DSMCCCacheKey() {}
00022 DSMCCCacheKey(const char * data, int size):
00023 QByteArray(data, size) {}
00024 QString toString(void) const;
00025
00026 friend bool operator < (const DSMCCCacheKey &key1,
00027 const DSMCCCacheKey &key2);
00028 };
00029
00030 class DSMCCCacheReference
00031 {
00032 public:
00033 DSMCCCacheReference() :
00034 m_nCarouselId(0), m_nModuleId(0),
00035 m_nStreamTag(0) {}
00036
00037 DSMCCCacheReference(unsigned long car, unsigned short m,
00038 unsigned short s, const DSMCCCacheKey &k) :
00039 m_nCarouselId(car), m_nModuleId(m),
00040 m_nStreamTag(s), m_Key(k) {}
00041
00042 DSMCCCacheReference(const DSMCCCacheReference &r) :
00043 m_nCarouselId(r.m_nCarouselId), m_nModuleId(r.m_nModuleId),
00044 m_nStreamTag(r.m_nStreamTag), m_Key(r.m_Key) {}
00045
00046 bool Equal(const DSMCCCacheReference &r) const;
00047 bool Equal(const DSMCCCacheReference *p) const;
00048
00049 QString toString(void) const;
00050
00051 public:
00052 unsigned long m_nCarouselId;
00053 unsigned short m_nModuleId;
00054 unsigned short m_nStreamTag;
00055 DSMCCCacheKey m_Key;
00056
00057
00058 friend bool operator < (const DSMCCCacheReference&,
00059 const DSMCCCacheReference&);
00060 };
00061
00062
00063 class DSMCCCacheDir
00064 {
00065 public:
00066 DSMCCCacheDir() {}
00067 DSMCCCacheDir(const DSMCCCacheReference &r) : m_Reference(r) {}
00068
00069
00070 QMap<QString, DSMCCCacheReference> m_SubDirectories;
00071 QMap<QString, DSMCCCacheReference> m_Files;
00072
00073 DSMCCCacheReference m_Reference;
00074 };
00075
00076
00077 class DSMCCCacheFile
00078 {
00079 public:
00080 DSMCCCacheFile() {}
00081 DSMCCCacheFile(const DSMCCCacheReference &r) : m_Reference(r) {}
00082
00083 DSMCCCacheReference m_Reference;
00084 QByteArray m_Contents;
00085 };
00086
00087 class DSMCCCache
00088 {
00089 public:
00090 DSMCCCache(Dsmcc *);
00091 ~DSMCCCache();
00092
00093
00094 DSMCCCacheDir *Srg(const DSMCCCacheReference &ref);
00095
00096 DSMCCCacheDir *Directory(const DSMCCCacheReference &ref);
00097
00098 void AddFileInfo(DSMCCCacheDir *dir, const BiopBinding *);
00099
00100 void AddDirInfo(DSMCCCacheDir *dir, const BiopBinding *);
00101
00102
00103 void CacheFileData(const DSMCCCacheReference &ref, const QByteArray &data);
00104
00105
00106 void SetGateway(const DSMCCCacheReference &ref);
00107
00108
00109 int GetDSMObject(QStringList &objectPath, QByteArray &result);
00110
00111 protected:
00112
00113 DSMCCCacheFile *FindFileData(DSMCCCacheReference &ref);
00114 DSMCCCacheDir *FindDir(DSMCCCacheReference &ref);
00115 DSMCCCacheDir *FindGateway(DSMCCCacheReference &ref);
00116
00117 DSMCCCacheReference m_GatewayRef;
00118
00119
00120 QMap<DSMCCCacheReference, DSMCCCacheDir*> m_Directories;
00121 QMap<DSMCCCacheReference, DSMCCCacheDir*> m_Gateways;
00122 QMap<DSMCCCacheReference, DSMCCCacheFile*> m_Files;
00123
00124 public:
00125 Dsmcc *m_Dsmcc;
00126 };
00127
00128 #endif