[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HashTable specialization

Ok, like I said in one of the other mails I want HashTable to serialize
itself, but be aware of *where* it serializes itself to (a PakFile / ZIP
file / whatever). I looked a bit around in the code and I think the best
way to accomplish this is to dump the MISC template parameter and replace
it with an inheritance relationship. Example:

(HashTable only takes the first three template parameters)
We do a

typedef HashTable <File *,      File::Key,      ppu32> FileHashTable;
typedef HashTable <Directory *, Directory::Key, ppu32> DirHashTable;

Now Directory just contains 
FileHashTable *m_pFileTable;
DirHashTable  *m_pDirTable;

which it gets from the virtual factory methods
FileHashTable *Directory::CreateFileTable ();
DirHashTable  *Directory::CreateDirTable  ():

Now we have types 
PakFileHashTable derived from FileHashTable, and
PakDirHashTable  derived from DirHashTable

Both know about how File * and Directory * can be treated (e.g. that both
have the GetVFSInterface () mthod which can be used to determine whether
they can be safely serialized etc and know how to properly serialize
themselves to PakFiles.

The factory methods are implemented by PakFileDir etc.

That way HashTables know how to properly serialize themselves to the target
stream and Directory can still encapsulate the HashTable accessing
functionality (file searching/adding/removing etc)

What do you think? Is there again something I didn't see? ;)


Drive A: not responding...Formatting C: instead