design: Revisit the database design

Update the style and make sure everything still makes sense when reading
it.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2013-08-07 22:00:14 -04:00 committed by Anna Schumaker
parent 1cfd9588f9
commit 857598dea7
2 changed files with 30 additions and 14 deletions

View File

@ -311,7 +311,7 @@ Database: (lib/database.cpp)
unsigned int insert(T);
void delete(unsigned int);
const unsigned int &size();
const T &operator[](unsigned int);
T &operator[](unsigned int);
};
File << db.size() << endl
@ -323,19 +323,27 @@ Database: (lib/database.cpp)
Database.Database(filename);
Initializes database to use ~/.ocarina{-debug}/filename. Pass
an empty string if you do not want this database to be saved.
Database.load();
void Database.load();
Reads data from file. Call after static initialization of
Ocarina to ensure idle tasks are configured so loading can
happen at a later time.
Database.save();
void Database.save();
Saves data to file.
Database.insert(T &);
template <class T>
unsigned int Database.insert(T &);
Adds a new item to the db, returns the id of the item
Database.delete(unsigned int index);
void Database.delete(unsigned int index);
Mark db[index] as invalid (quick deletion)
Database.size();
unsigned Database.size();
Returns number of valid rows in the database
Database.operator[unsigned int index]
template <class T>
T &Database.operator[unsigned int index]
Return a reference to db[index]

View File

@ -55,7 +55,7 @@ Database: (lib/database.cpp)
unsigned int insert(T);
void delete(unsigned int);
const unsigned int &size();
const T &operator[](unsigned int);
T &operator[](unsigned int);
};
File << db.size() << endl
@ -67,17 +67,25 @@ Database: (lib/database.cpp)
Database.Database(filename);
Initializes database to use ~/.ocarina{-debug}/filename. Pass
an empty string if you do not want this database to be saved.
Database.load();
void Database.load();
Reads data from file. Call after static initialization of
Ocarina to ensure idle tasks are configured so loading can
happen at a later time.
Database.save();
void Database.save();
Saves data to file.
Database.insert(T &);
template <class T>
unsigned int Database.insert(T &);
Adds a new item to the db, returns the id of the item
Database.delete(unsigned int index);
void Database.delete(unsigned int index);
Mark db[index] as invalid (quick deletion)
Database.size();
unsigned Database.size();
Returns number of valid rows in the database
Database.operator[unsigned int index]
template <class T>
T &Database.operator[unsigned int index]
Return a reference to db[index]