From 63aa8992a81dfaececa4a9b38ba8daf29b57912e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 30 Oct 2009 19:03:23 -0400 Subject: Moved ownership of master account into journal_t The journal_t now completely represents the data part of a session. --- src/journal.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/journal.cc') diff --git a/src/journal.cc b/src/journal.cc index fdb49e24..d73d0fb8 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -32,11 +32,34 @@ #include #include "journal.h" +#include "amount.h" +#include "commodity.h" +#include "pool.h" #include "xact.h" #include "account.h" namespace ledger { +journal_t::journal_t() + : master(new account_t), + commodity_pool(new commodity_pool_t) +{ + TRACE_CTOR(journal_t, ""); + + // Add time commodity conversions, so that timelog's may be parsed + // in terms of seconds, but reported as minutes or hours. + if (commodity_t * commodity = commodity_pool->create("s")) + commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET); + else + assert(false); + + // Add a "percentile" commodity + if (commodity_t * commodity = commodity_pool->create("%")) + commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET); + else + assert(false); +} + journal_t::~journal_t() { TRACE_DTOR(journal_t); @@ -52,6 +75,9 @@ journal_t::~journal_t() foreach (period_xact_t * xact, period_xacts) checked_delete(xact); + + checked_delete(master); + commodity_pool.reset(); } void journal_t::add_account(account_t * acct) -- cgit v1.2.3