[Alephmodular-devel] Fleshing out file types...
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-02-08 21:06:56
|
After getting initial iostreams working for files I decided to handle file types and creator codes before working on FileDescs proper. As I get my head around the creator codes better and write up the classes I thought I would revamp that portion of my file document. -Jeremy Parsons CFileType represents the type of a file CFileSystemDesc is our friend and can use the protected virtual methods for getting type_code, type_extension and the type checking. There are three special cases of CFileType CDirectoryType a plain old directories (a directory that was a bundle would be handled seperately) CUnknownType If we examine a CFileSystemDesc and it matches no known types, then CUnknownType is the tye used for the file CFamilyType A hierarchy of types for checking a file's type against. For instance, checking if a given specific type is a map or a M2 file. CCreatorFamilyType is a subset of the family type which also knows its creator code. All others descend from CTypedFileType which has basic operations A file type generally encapsulates the following: The file's creator: ala M2, Minf, or AlephModular) The four character code associated with a file on MAcintosh: aka TEXT The extension associated with the file on other systems: aka txt (as in README.txt) a test() method for checking whether or not a CFileSystemDesc matches the current type a test_contents() method for checking within a file for a type match Testing CDirectoryType against file decriptions only matches type with directories Testing CUnknownType against file descriptions is always false. It is only assigned when either nothing is known, or everything else fails to match. Testing CFamilyType against file descriptions always fails. Testing CTypedFileTypes against a file succeeds if type and creator match or if the extension matches. Subclasses may perform more complicated tests, such as inspecting the file's contents (by implementing test_contents(FileDesc*)) test_contents() is seperate from test() so that if a first pass by inspecting via test fails to locate a file's type, then that file can be checked over the available types by performing the content tests of the types. FileTypes support a matches(FileType) method to tell if the type who's matching method is being called considers itself to be the type of the argument, or a logical element of that type's set. CMarathon2MapType.matches(CAlephModularMapType) == false CMarathon2MapType.matches(CMarathon2MapType) == true CMarathon2MapType.matches(CMapFamily) == true CMarathon2MapType.matches(CMarathon2Family) == true I admit, on typing I'm trying to figure out if the class is C<whatever>Type and is essentially a singleton. What is a decent way of referring to one specific type or another? A CFileTypeFactory that offers GetTypeFor("<whatever>") with a hash or dictionary within? |