DB-MANAGER HEADER FILE ---------------------- #ifndef _DB_H #define _DB_H #include #include #include "page.h" // Each database is basically a UNIX file and consists of several relations // (viewed as heapfiles and their indexes) within it. // Class definition for DB which manages a database. // This is the maximum length of the name of a "file" within a database. const int MAX_NAME = 50; enum dbErrCodes { DB_FULL, DUPLICATE_ENTRY, UNIX_ERROR, BAD_PAGE_NO, FILE_IO_ERROR, FILE_NOT_FOUND, FILE_NAME_TOO_LONG, NEG_RUN_SIZE, }; // oooooooooooooooooooooooooooooooooooooo class DB { public: // Constructors // Create a database with the specified number of pages where the page // size is the default page size. DB( const char* name, unsigned num_pages, Status& status ); // Open the database with the given name. DB( const char* name, Status& status ); // Destructor: closes the database ~DB(); // Destroy the database, removing the file that stores it. Status db_destroy(); // Read the contents of the specified page into the given memory area. Status read_page(PageId pageno, Page* pageptr); // Write the contents of the specified page. Status write_page(PageId pageno, Page* pageptr); // Allocate a set of pages where the run size is taken to be 1 by default. // Gives back the page number of the first page of the allocated run. Status allocate_page(PageId& start_page_num, int run_size = 1); // Deallocate a set of pages starting at the specified page number and // a run size can be specified. Status deallocate_page(PageId start_page_num, int run_size = 1); // oooooooooooooooooooooooooooooooooooooo // Adds a file entry to the header page(s). Status add_file_entry(const char* fname, PageId start_page_num); // Delete the entry corresponding to a file from the header page(s). Status delete_file_entry(const char* fname); // Get the entry corresponding to the given file. Status get_file_entry(const char* name, PageId& start_pg); // Functions to return some characteristics of the database. const char* db_name() const; int db_num_pages() const; int db_page_size() const; // Print out the space map of the database. // The space map is a bitmap showing which // pages of the db are currently allocated. Status dump_space_map(); }; // oooooooooooooooooooooooooooooooooooooo #endif // _DB_H