SwatDB
file.h
Go to the documentation of this file.
1 /*
2  * SwatDB
3  *
4  * @authors: See Contributors.doc for code contributors
5  *
6  * Copyright (c) 2020 Swarthmore College Computer Science Department
7  * Swarthmore PA, Professors Tia Newhall, Ameet Soni
8  */
9 
10 #pragma once
11 
16 #include <string>
17 #include <vector>
18 #include "swatdb_types.h"
19 
20 // too many circular includes
21 class Catalog;
22 class BufferManager;
23 class Schema;
24 
25 /* The class heirarchy:
26  *
27  * File
28  *
29  * / | \
30  * HeapFile Sorted File IndexFile
31  * / \
32  * BTreeIndex HashIndex
33 */
34 
42 // TODO: not fully implemented
43 class File {
44 
45  public:
46 
62 
68  virtual ~File();
69 
74  virtual void createHeader() = 0;
75 
80  virtual void flushHeader() = 0;
81 
87  FileId getMyFid();
88 
89  // TODO add this method: maybe protected with Catalog friend
90  // void setMyFID(FileId *file_id);
91 
92 
98  Schema* getSchema();
99 
109 
110  protected:
111 
116 
121 
126 
133 
138 
157  void _setMyFid(FileId file_id);
158 
159  friend class Catalog;
160  friend class FileManager;
161 };
virtual void createHeader()=0
Allocates and initializes the header. Is a virtual method to be overridden at each derived class...
void _setMyFid(FileId file_id)
Sets the file_id and the schema fields of this File.
Definition: schema.h:27
Definition: filemgr.h:31
Catalog * catalog
Definition: file.h:120
virtual void flushHeader()=0
Flushes Header Page to disk. Is a virtual method to be overridden at each derived class...
Definition: bufmgr.h:248
PageId getHeaderId()
Returns Header PageId.
PageId header_id
Definition: file.h:137
Definition: swatdb_types.h:50
File(Catalog *catalog, BufferManager *buf_mgr, Schema *schema)
Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema.
FileId getMyFid()
Returns the FileId of the File.
Schema * getSchema()
Returns the schema of the File.
FileId file_id
Definition: file.h:115
virtual ~File()
Destructor. Data members are cleaned up, but none of the dynamically allocated data members are not d...
Definition: catalog.h:134
std::uint32_t FileId
Definition: swatdb_types.h:29
Definition: file.h:43
BufferManager * buf_mgr
Definition: file.h:125
Schema * schema
Definition: file.h:132