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 "Subst.h"
#include "Cmd.h" #include "Cmd.h"
#include "Task.h" #include "Task.h"
#include "TDB2.h" #include "TDB.h"
#include "StringTable.h" #include "StringTable.h"
class Context class Context
@ -67,7 +67,7 @@ public:
Sequence sequence; Sequence sequence;
Subst subst; Subst subst;
Task task; Task task;
TDB2 tdb; TDB tdb;
StringTable stringtable; StringTable stringtable;
std::string program; std::string program;
std::vector <std::string> args; 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 \ task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \
Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \ Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp Task.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 \ import.cpp interactive.cpp valid.cpp recur.cpp report.cpp \
custom.cpp rules.cpp main.cpp text.cpp util.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 \ 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 \ 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 i18n.h main.h text.h util.h

View file

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

View file

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

View file

@ -1,5 +1,4 @@
t.t t.t
t2.t
t.benchmark.t t.benchmark.t
tdb.t tdb.t
date.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 \ config.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
cmd.t cmd.t
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
LFLAGS = -L/usr/local/lib -lncurses 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 \ ../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o \
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \ ../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \ ../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \
@ -23,8 +23,8 @@ clean:
.cpp.o: .cpp.o:
g++ -c $(CFLAGS) $< g++ -c $(CFLAGS) $<
t2.t: t2.t.o $(OBJECTS) test.o t.t: t.t.o $(OBJECTS) test.o
g++ t2.t.o $(OBJECTS) test.o $(LFLAGS) -o t2.t g++ t.t.o $(OBJECTS) test.o $(LFLAGS) -o t.t
tdb.t: tdb.t.o $(OBJECTS) test.o tdb.t: tdb.t.o $(OBJECTS) test.o
g++ tdb.t.o $(OBJECTS) test.o $(LFLAGS) -o tdb.t g++ tdb.t.o $(OBJECTS) test.o $(LFLAGS) -o tdb.t