Integration - TDB

- Renamed TDB2 to TDB.
- Integration of new code complete.
This commit is contained in:
Paul Beckingham 2009-06-14 18:19:00 -04:00
parent 53d0d1cbac
commit 80bb9f0a18
7 changed files with 31 additions and 32 deletions

View file

@ -34,7 +34,7 @@
#include "Subst.h"
#include "Cmd.h"
#include "Task.h"
#include "TDB2.h"
#include "TDB.h"
#include "StringTable.h"
class Context
@ -67,7 +67,7 @@ public:
Sequence sequence;
Subst subst;
Task task;
TDB2 tdb;
TDB tdb;
StringTable stringtable;
std::string program;
std::vector <std::string> args;

View file

@ -2,10 +2,10 @@ bin_PROGRAMS = task
task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \
Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp Task.cpp \
TDB2.cpp Table.cpp Timer.cpp color.cpp command.cpp edit.cpp \
TDB.cpp Table.cpp Timer.cpp color.cpp command.cpp edit.cpp \
import.cpp interactive.cpp valid.cpp recur.cpp report.cpp \
custom.cpp rules.cpp main.cpp text.cpp util.cpp \
Att.h Cmd.h Config.h Context.h Date.h Duration.h Filter.h \
Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \
StringTable.h Subst.h Task.h TDB2.h Table.h Timer.h color.h \
StringTable.h Subst.h Task.h TDB.h Table.h Timer.h color.h \
i18n.h main.h text.h util.h

View file

@ -32,7 +32,7 @@
#include <sys/file.h>
#include "text.h"
#include "util.h"
#include "TDB2.h"
#include "TDB.h"
#include "main.h"
////////////////////////////////////////////////////////////////////////////////
@ -65,7 +65,7 @@
// +- TDB::~TDB
// [TDB::unlock]
//
TDB2::TDB2 ()
TDB::TDB ()
: mLock (true)
, mAllOpenAndLocked (false)
, mId (1)
@ -73,14 +73,14 @@ TDB2::TDB2 ()
}
////////////////////////////////////////////////////////////////////////////////
TDB2::~TDB2 ()
TDB::~TDB ()
{
if (mAllOpenAndLocked)
unlock ();
}
////////////////////////////////////////////////////////////////////////////////
void TDB2::clear ()
void TDB::clear ()
{
mLocations.clear ();
mLock = true;
@ -92,7 +92,7 @@ void TDB2::clear ()
}
////////////////////////////////////////////////////////////////////////////////
void TDB2::location (const std::string& path)
void TDB::location (const std::string& path)
{
if (access (expandPath (path).c_str (), F_OK))
throw std::string ("Data location '") +
@ -103,7 +103,7 @@ void TDB2::location (const std::string& path)
}
////////////////////////////////////////////////////////////////////////////////
void TDB2::lock (bool lockFile /* = true */)
void TDB::lock (bool lockFile /* = true */)
{
mLock = lockFile;
@ -122,7 +122,7 @@ void TDB2::lock (bool lockFile /* = true */)
}
////////////////////////////////////////////////////////////////////////////////
void TDB2::unlock ()
void TDB::unlock ()
{
if (mAllOpenAndLocked)
{
@ -147,7 +147,7 @@ void TDB2::unlock ()
// Returns number of filtered tasks.
// Note: tasks.clear () is deliberately not called, to allow the combination of
// multiple files.
int TDB2::load (std::vector <Task>& tasks, Filter& filter)
int TDB::load (std::vector <Task>& tasks, Filter& filter)
{
loadPending (tasks, filter);
loadCompleted (tasks, filter);
@ -159,7 +159,7 @@ int TDB2::load (std::vector <Task>& tasks, Filter& filter)
// Returns number of filtered tasks.
// Note: tasks.clear () is deliberately not called, to allow the combination of
// multiple files.
int TDB2::loadPending (std::vector <Task>& tasks, Filter& filter)
int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
{
std::string file;
int line_number;
@ -207,7 +207,7 @@ int TDB2::loadPending (std::vector <Task>& tasks, Filter& filter)
// Returns number of filtered tasks.
// Note: tasks.clear () is deliberately not called, to allow the combination of
// multiple files.
int TDB2::loadCompleted (std::vector <Task>& tasks, Filter& filter)
int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
{
std::string file;
int line_number;
@ -257,14 +257,14 @@ int TDB2::loadCompleted (std::vector <Task>& tasks, Filter& filter)
////////////////////////////////////////////////////////////////////////////////
// TODO Write to transaction log.
// Note: mLocations[0] is where all tasks are written.
void TDB2::add (Task& task)
void TDB::add (Task& task)
{
mNew.push_back (task);
}
////////////////////////////////////////////////////////////////////////////////
// TODO Write to transaction log.
void TDB2::update (Task& before, Task& after)
void TDB::update (Task& before, Task& after)
{
mModified.push_back (after);
}
@ -272,8 +272,8 @@ void TDB2::update (Task& before, Task& after)
////////////////////////////////////////////////////////////////////////////////
// TODO Writes all, including comments
// Interestingly, only the pending file gets written to. The completed file is
// only modified by TDB2::gc.
int TDB2::commit ()
// only modified by TDB::gc.
int TDB::commit ()
{
int quantity = mNew.size () + mModified.size ();
@ -320,7 +320,7 @@ int TDB2::commit ()
////////////////////////////////////////////////////////////////////////////////
// TODO -> FF4
void TDB2::upgrade ()
void TDB::upgrade ()
{
// TODO Read all pending
// TODO Write out all pending
@ -328,13 +328,13 @@ void TDB2::upgrade ()
// TODO Read all completed
// TODO Write out all completed
throw std::string ("unimplemented TDB2::upgrade");
throw std::string ("unimplemented TDB::upgrade");
}
////////////////////////////////////////////////////////////////////////////////
// Scans the pending tasks for any that are completed or deleted, and if so,
// moves them to the completed.data file. Returns a count of tasks moved.
int TDB2::gc ()
int TDB::gc ()
{
int count = 0;
/*
@ -372,7 +372,7 @@ int TDB2::gc ()
}
////////////////////////////////////////////////////////////////////////////////
FILE* TDB2::openAndLock (const std::string& file)
FILE* TDB::openAndLock (const std::string& file)
{
// Check for access.
if (access (file.c_str (), F_OK | R_OK | W_OK))

View file

@ -24,8 +24,8 @@
// USA
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_TDB2
#define INCLUDED_TDB2
#ifndef INCLUDED_TDB
#define INCLUDED_TDB
#include <map>
#include <vector>
@ -37,11 +37,11 @@
// Length of longest line.
#define T_LINE_MAX 32768
class TDB2
class TDB
{
public:
TDB2 (); // Default constructor
~TDB2 (); // Destructor
TDB (); // Default constructor
~TDB (); // Destructor
void clear ();
void location (const std::string&);

View file

@ -1,5 +1,4 @@
t.t
t2.t
t.benchmark.t
tdb.t
date.t

View file

@ -1,9 +1,9 @@
PROJECT = t2.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
config.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
cmd.t
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
LFLAGS = -L/usr/local/lib -lncurses
OBJECTS = ../TDB2.o ../Task.o ../valid.o ../text.o ../Date.o ../Table.o \
OBJECTS = ../TDB.o ../Task.o ../valid.o ../text.o ../Date.o ../Table.o \
../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o \
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \
@ -23,8 +23,8 @@ clean:
.cpp.o:
g++ -c $(CFLAGS) $<
t2.t: t2.t.o $(OBJECTS) test.o
g++ t2.t.o $(OBJECTS) test.o $(LFLAGS) -o t2.t
t.t: t.t.o $(OBJECTS) test.o
g++ t.t.o $(OBJECTS) test.o $(LFLAGS) -o t.t
tdb.t: tdb.t.o $(OBJECTS) test.o
g++ tdb.t.o $(OBJECTS) test.o $(LFLAGS) -o tdb.t