diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-12 03:32:10 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-12 03:32:10 -0500 |
commit | b2b0ae37e82fe6c480b7e6527e67cce168687679 (patch) | |
tree | ed7b900dc18bca311f1423d16b5c02bd42d137c3 | |
parent | b5dca6739687f3672ef0114a70c2f514707dc28b (diff) | |
download | fork-ledger-b2b0ae37e82fe6c480b7e6527e67cce168687679.tar.gz fork-ledger-b2b0ae37e82fe6c480b7e6527e67cce168687679.tar.bz2 fork-ledger-b2b0ae37e82fe6c480b7e6527e67cce168687679.zip |
session_t now holds a std::auto_prt<journal_t>
-rw-r--r-- | src/archive.cc | 20 | ||||
-rw-r--r-- | src/archive.h | 6 | ||||
-rw-r--r-- | src/session.cc | 6 | ||||
-rw-r--r-- | src/session.h | 6 |
4 files changed, 19 insertions, 19 deletions
diff --git a/src/archive.cc b/src/archive.cc index 5ea6cd8e..d36712ca 100644 --- a/src/archive.cc +++ b/src/archive.cc @@ -201,23 +201,23 @@ bool archive_t::should_load(const std::list<path>& data_files) return true; } -bool archive_t::should_save(shared_ptr<journal_t> journal) +bool archive_t::should_save(journal_t& journal) { std::list<path> data_files; DEBUG("archive.journal", "Should the archive be saved?"); - if (journal->was_loaded) { + if (journal.was_loaded) { DEBUG("archive.journal", "No, it's one we loaded before"); return false; } - if (journal->sources.empty()) { + if (journal.sources.empty()) { DEBUG("archive.journal", "No, there were no sources!"); return false; } - foreach (const journal_t::fileinfo_t& i, journal->sources) { + foreach (const journal_t::fileinfo_t& i, journal.sources) { if (i.from_stream) { DEBUG("archive.journal", "No, one source was from a stream"); return false; @@ -241,14 +241,14 @@ bool archive_t::should_save(shared_ptr<journal_t> journal) return true; } -void archive_t::save(shared_ptr<journal_t> journal) +void archive_t::save(journal_t& journal) { INFO_START(archive, "Saved journal file cache"); ofstream stream(file, std::ios::binary); write_header_bits(stream); - sources = journal->sources; + sources = journal.sources; #if defined(DEBUG_ON) foreach (const journal_t::fileinfo_t& i, sources) @@ -263,12 +263,12 @@ void archive_t::save(shared_ptr<journal_t> journal) DEBUG("archive.journal", "Archiving journal with " << sources.size() << " sources"); - oa << *journal; + oa << journal; INFO_FINISH(archive); } -bool archive_t::load(shared_ptr<journal_t> journal) +bool archive_t::load(journal_t& journal) { INFO_START(archive, "Read cached journal file"); @@ -282,8 +282,8 @@ bool archive_t::load(shared_ptr<journal_t> journal) archive_t temp; iarchive >> temp; - iarchive >> *journal.get(); - journal->was_loaded = true; + iarchive >> journal; + journal.was_loaded = true; INFO_FINISH(archive); diff --git a/src/archive.h b/src/archive.h index 60ead5a9..03fc970a 100644 --- a/src/archive.h +++ b/src/archive.h @@ -69,10 +69,10 @@ public: bool read_header(); bool should_load(const std::list<path>& data_files); - bool should_save(shared_ptr<journal_t> journal); + bool should_save(journal_t& journal); - void save(shared_ptr<journal_t> journal); - bool load(shared_ptr<journal_t> journal); + void save(journal_t& journal); + bool load(journal_t& journal); #if defined(HAVE_BOOST_SERIALIZATION) private: diff --git a/src/session.cc b/src/session.cc index 9fb8df46..0d6a6829 100644 --- a/src/session.cc +++ b/src/session.cc @@ -106,7 +106,7 @@ std::size_t session_t::read_data(const string& master_account) if (! (cache && cache->should_load(HANDLER(file_).data_files) && - cache->load(journal))) { + cache->load(*journal.get()))) { #endif // HAVE_BOOST_SERIALIZATION if (price_db_path) { if (exists(*price_db_path)) { @@ -142,8 +142,8 @@ std::size_t session_t::read_data(const string& master_account) assert(xact_count == journal->xacts.size()); #if defined(HAVE_BOOST_SERIALIZATION) - if (cache && cache->should_save(journal)) - cache->save(journal); + if (cache && cache->should_save(*journal.get())) + cache->save(*journal.get()); } #endif // HAVE_BOOST_SERIALIZATION diff --git a/src/session.h b/src/session.h index bde37f46..5c4612a0 100644 --- a/src/session.h +++ b/src/session.h @@ -58,9 +58,9 @@ class session_t : public symbol_scope_t friend void set_session_context(session_t * session); public: - bool flush_on_next_data_file; - date_t::year_type current_year; - shared_ptr<journal_t> journal; + bool flush_on_next_data_file; + date_t::year_type current_year; + std::auto_ptr<journal_t> journal; explicit session_t(); virtual ~session_t() { |