/* Class declaration for the Index_File class The Index_File class can be used independently or as part of the MiniDB project. Copyright (C) 2007 Hossein Hakimzadeh Comments and bug fixes can be sent to hhakimza@iusb.edu This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef INDEX_FILE_H #define INDEX_FILE_H //-----------------------------------------------------------------------// #include "Random_IO.h" #define ACTIVE 'A' #define DELETED 'D' //-----------------------------------------------------------------------// struct idx_record { unsigned long Key; // Key to search for (alternatively this could be an unsigned long.) unsigned long Address; // physical location of the record in the .DTA file char Flag; // A = ACTIVE, D=DELETED) }; //-----------------------------------------------------------------------// class Index_File { char FileName[256]; // *.idx Random_IO RandomFile; int CurrentMaxRecords; // Maximum number of index records in the file int Verbose; // ON / OFF public: Index_File(char *filename); //Constructor ~Index_File(); //Destructor, also closes the file void Initialize(int max_records); // set the max records and open the file void Expand(int highest_record); // Expand the size of the Index_File void InsertIndexRecord(idx_record *idx); // Insert an Index record int SearchIndexRecord(unsigned long Key, idx_record *idx); // Search and return idx record, -1 if not found int MaximumIndexRecords(); // Return the maximum number of index records void DumpIndexFile(void); }; #endif