From 80bb9f0a184555d7e50f593de50c34e1e0be8691 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 14 Jun 2009 18:19:00 -0400 Subject: [PATCH] Integration - TDB - Renamed TDB2 to TDB. - Integration of new code complete. --- src/Context.h | 4 ++-- src/Makefile.am | 4 ++-- src/{TDB2.cpp => TDB.cpp} | 36 ++++++++++++++++----------------- src/{TDB2.h => TDB.h} | 10 ++++----- src/tests/.gitignore | 1 - src/tests/Makefile | 8 ++++---- src/tests/{t2.t.cpp => t.t.cpp} | 0 7 files changed, 31 insertions(+), 32 deletions(-) rename src/{TDB2.cpp => TDB.cpp} (93%) rename src/{TDB2.h => TDB.h} (95%) rename src/tests/{t2.t.cpp => t.t.cpp} (100%) diff --git a/src/Context.h b/src/Context.h index 765de97a9..0ad6511f7 100644 --- a/src/Context.h +++ b/src/Context.h @@ -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 args; diff --git a/src/Makefile.am b/src/Makefile.am index 1212259c1..d3e6bd4d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/TDB2.cpp b/src/TDB.cpp similarity index 93% rename from src/TDB2.cpp rename to src/TDB.cpp index 43cc4688b..a299d4672 100644 --- a/src/TDB2.cpp +++ b/src/TDB.cpp @@ -32,7 +32,7 @@ #include #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 & tasks, Filter& filter) +int TDB::load (std::vector & tasks, Filter& filter) { loadPending (tasks, filter); loadCompleted (tasks, filter); @@ -159,7 +159,7 @@ int TDB2::load (std::vector & 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 & tasks, Filter& filter) +int TDB::loadPending (std::vector & tasks, Filter& filter) { std::string file; int line_number; @@ -207,7 +207,7 @@ int TDB2::loadPending (std::vector & 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 & tasks, Filter& filter) +int TDB::loadCompleted (std::vector & tasks, Filter& filter) { std::string file; int line_number; @@ -257,14 +257,14 @@ int TDB2::loadCompleted (std::vector & 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)) diff --git a/src/TDB2.h b/src/TDB.h similarity index 95% rename from src/TDB2.h rename to src/TDB.h index 04ae194da..1af552d16 100644 --- a/src/TDB2.h +++ b/src/TDB.h @@ -24,8 +24,8 @@ // USA // //////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_TDB2 -#define INCLUDED_TDB2 +#ifndef INCLUDED_TDB +#define INCLUDED_TDB #include #include @@ -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&); diff --git a/src/tests/.gitignore b/src/tests/.gitignore index 09b9555f7..dd6441689 100644 --- a/src/tests/.gitignore +++ b/src/tests/.gitignore @@ -1,5 +1,4 @@ t.t -t2.t t.benchmark.t tdb.t date.t diff --git a/src/tests/Makefile b/src/tests/Makefile index 95c1f6d6f..2d5a6b96b 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -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 diff --git a/src/tests/t2.t.cpp b/src/tests/t.t.cpp similarity index 100% rename from src/tests/t2.t.cpp rename to src/tests/t.t.cpp