/* registry.h -*-C++-*- * by Will Wagner * last updated 20 Sep 1997, 17:48:11 wwagner * * This file contains the global registry information, including * command-line options, symbol tables, and registered object, * texture, image, and font types. More types to come later. * * Changes * 24 Jul 1997 * - Moved the Symtbl class into this file. * * 27 Jul 1997 * - Commented out some non-existent stuff to test lexer compilation. * * 28 Jul 1997 * - Made the registry into a class; renamed the Symtbl to a SymbolTable. * * 29 Jul 1997 * - Added a couple methods to the Registry; added the statistics * method pointer and keytype member to the registry structures. * * 18 Aug 1997 * - Added a (commented-out) image type registry structure, to * keep track of which image types are available. * * 20 Aug 1997 * - The registry structures now use instances instead of pointers * to LAST_TOKEN-terminated arrays of instances - it should * simplify walking the lists greatly; renamed LocateIncludeFile * to LocateLibraryFile, which will find any old file in the * library path; also made it const. * * 21 Aug 1997 * - Added some font-registering stuff - none of the classes * actually exist yet, so keep that in mind. * * 06 Sep 1997 * - Minor changes. * * Things to do * */ #ifndef __INC_REGISTRY_H__ #define __INC_REGISTRY_H__ #include #include #include #include "vector.h" #include "frame.h" /* #include "object.h" #include "texture.h" #include "image.h" #include "text.h" */ /* The definitions of the basic POVRay tokens */ #include "y.tab.h" #ifndef DEFAULT_HASH_TABLE_SIZE #define DEFAULT_HASH_TABLE_SIZE 257 #endif class SymbolTable { private: struct symbol_struct { TOKEN number, type; char *name; void *meaning; }; vector< list > hash_table; int min_value, next_token_val, size; int hash(char *) const; static int ss_eql(struct symbol_struct&, char *); public: SymbolTable(int = DEFAULT_HASH_TABLE_SIZE); SymbolTable(const SymbolTable&); ~SymbolTable(); int SetMinValue(int); TOKEN Find(char *) const; TOKEN Add(char *, int = -1); TOKEN Type(char *, TOKEN = -1); void *Means(char *, void * = NULL); }; /* The structure which holds the reserved words in each file before * they are inserted into the hash. */ typedef struct Reserved_Word_Struct { TOKEN Token_Number; char *Token_Name; } RESERVED_WORD; /* Various function pointers (creation and statistics) for the registry. */ typedef Object *(*obj_parse_ptr)(Parser&); /* typedef Texture *(*tex_parse_ptr)(Parser&); typedef Image *(*image_create_ptr)(const char *); typedef Font *(*font_create_ptr)(const char *); */ typedef void (*statistics_ptr)(void); /* The structures which define type-keyword mappings. */ typedef struct object_registry_struct { TOKEN keyword; TOKEN keytype; obj_parse_ptr create; statistics_ptr stats; } object_registry; /* typedef struct texture_registry_struct { TOKEN keyword; TOKEN keytype; tex_parse_ptr create; statistics_ptr stats; } texture_registry; typedef struct image_registry_struct { TOKEN keyword; image_create_ptr create; } image_registry; typedef struct font_registry_struct { TOKEN keyword; font_create_ptr create; } font_registry; */ class Registry { private: SymbolTable reserved, symbols; list obj; /* list tex; list img; list fon; */ list libpaths; ostream *streams[7]; public: Registry(); ~Registry(); void ReadCommandLine(int, char **); void ReadEnvironment(void); void ReadParamFile(const char *); char *LocateLibraryFile(const char *); inline SymbolTable& res(void) { return reserved; }; inline SymbolTable& sym(void) { return symbols; }; inline list& object_list(void) { return obj; }; /* inline list& texture_list(void) { return tex; }; inline list& image_list(void) { return img; }; inline list& font_list(void) { return fon; }; */ inline ostream& banner_stream(void) { return *streams[0]; }; inline ostream& warning_stream(void) { return *streams[1]; }; inline ostream& render_info_stream(void) { return *streams[2]; }; inline ostream& status_info_stream(void) { return *streams[3]; }; inline ostream& debug_info_stream(void) { return *streams[4]; }; inline ostream& fatal_stream(void) { return *streams[5]; }; inline ostream& statistics_stream(void) { return *streams[6]; }; }; /* There can be only one... */ extern Registry registry; #endif /* __INC_REGISTRY_H__ */