-
Notifications
You must be signed in to change notification settings - Fork 345
/
dsmcccache.h
128 lines (102 loc) · 3.54 KB
/
dsmcccache.h
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
/*
* Copyright (C) David C.J. Matthews 2005, 2006
* Derived from dsmcc by Richard Palmer
*/
#ifndef DSMCC_CACHE_H
#define DSMCC_CACHE_H
#include <QStringList>
#include <QMap>
class BiopBinding;
class DSMCCCacheFile;
class DSMCCCacheDir;
class DSMCCCache;
class Dsmcc;
class DSMCCCacheKey: public QByteArray
{
public:
DSMCCCacheKey() {}
DSMCCCacheKey(const char * data, int size):
QByteArray(data, size) {}
QString toString(void) const;
// Operator used in < for DSMCCCacheReference
friend bool operator < (const DSMCCCacheKey &key1,
const DSMCCCacheKey &key2);
};
class DSMCCCacheReference
{
public:
DSMCCCacheReference() :
m_nCarouselId(0), m_nModuleId(0),
m_nStreamTag(0) {}
DSMCCCacheReference(unsigned long car, unsigned short m,
unsigned short s, const DSMCCCacheKey &k) :
m_nCarouselId(car), m_nModuleId(m),
m_nStreamTag(s), m_Key(k) {}
DSMCCCacheReference(const DSMCCCacheReference &r) :
m_nCarouselId(r.m_nCarouselId), m_nModuleId(r.m_nModuleId),
m_nStreamTag(r.m_nStreamTag), m_Key(r.m_Key) {}
bool Equal(const DSMCCCacheReference &r) const;
bool Equal(const DSMCCCacheReference *p) const;
QString toString(void) const;
public:
unsigned long m_nCarouselId; // Reference info for the module
unsigned short m_nModuleId;
unsigned short m_nStreamTag;
DSMCCCacheKey m_Key;
// Operator required for QMap
friend bool operator < (const DSMCCCacheReference&,
const DSMCCCacheReference&);
};
// A directory
class DSMCCCacheDir
{
public:
DSMCCCacheDir() {}
DSMCCCacheDir(const DSMCCCacheReference &r) : m_Reference(r) {}
// These maps give the cache reference for each name
QMap<QString, DSMCCCacheReference> m_SubDirectories;
QMap<QString, DSMCCCacheReference> m_Files;
DSMCCCacheReference m_Reference;
};
// The contents of a file.
class DSMCCCacheFile
{
public:
DSMCCCacheFile() {}
DSMCCCacheFile(const DSMCCCacheReference &r) : m_Reference(r) {}
DSMCCCacheReference m_Reference;
QByteArray m_Contents; // Contents of the file.
};
class DSMCCCache
{
public:
DSMCCCache(Dsmcc *);
~DSMCCCache();
// Create a new gateway.
DSMCCCacheDir *Srg(const DSMCCCacheReference &ref);
// Create a new directory.
DSMCCCacheDir *Directory(const DSMCCCacheReference &ref);
// Add a file to the directory or gateway.
void AddFileInfo(DSMCCCacheDir *dir, const BiopBinding *);
// Add a directory to the directory or gateway.
void AddDirInfo(DSMCCCacheDir *dir, const BiopBinding *);
// Add the contents of a file.
void CacheFileData(const DSMCCCacheReference &ref, const QByteArray &data);
// Set the gateway reference from a DSI message.
void SetGateway(const DSMCCCacheReference &ref);
// Return the contents.
int GetDSMObject(QStringList &objectPath, QByteArray &result);
protected:
// Find File, Directory or Gateway by reference.
DSMCCCacheFile *FindFileData(DSMCCCacheReference &ref);
DSMCCCacheDir *FindDir(DSMCCCacheReference &ref);
DSMCCCacheDir *FindGateway(DSMCCCacheReference &ref);
DSMCCCacheReference m_GatewayRef; // Reference to the gateway
// The set of directories, files and gateways.
QMap<DSMCCCacheReference, DSMCCCacheDir*> m_Directories;
QMap<DSMCCCacheReference, DSMCCCacheDir*> m_Gateways;
QMap<DSMCCCacheReference, DSMCCCacheFile*> m_Files;
public:
Dsmcc *m_Dsmcc;
};
#endif