diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-31 00:55:56 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-31 00:55:56 -0400 |
commit | a2cb549b1dff9024e3f700203e424e496b25fd91 (patch) | |
tree | 1c03e9eb6f649a1446021dfb2a5d93a697f81feb /src/journal.h | |
parent | 349fc5d175bc5c4acbc478b4d78c12dc507c4f58 (diff) | |
parent | a88a4c55b2b11d58d3b9e49bf785be42afe63510 (diff) | |
download | fork-ledger-a2cb549b1dff9024e3f700203e424e496b25fd91.tar.gz fork-ledger-a2cb549b1dff9024e3f700203e424e496b25fd91.tar.bz2 fork-ledger-a2cb549b1dff9024e3f700203e424e496b25fd91.zip |
Merge branch 'next'
Diffstat (limited to 'src/journal.h')
-rw-r--r-- | src/journal.h | 83 |
1 files changed, 71 insertions, 12 deletions
diff --git a/src/journal.h b/src/journal.h index 43309590..88a225c5 100644 --- a/src/journal.h +++ b/src/journal.h @@ -48,11 +48,11 @@ #include "utils.h" #include "hooks.h" +#include "times.h" namespace ledger { -typedef std::list<path> paths_list; - +class commodity_pool_t; class xact_t; class auto_xact_t; class xact_finalizer_t; @@ -72,18 +72,60 @@ typedef std::list<period_xact_t *> period_xacts_list; class journal_t : public noncopyable { public: - account_t * master; - account_t * basket; - xacts_list xacts; - - auto_xacts_list auto_xacts; - period_xacts_list period_xacts; - + struct fileinfo_t + { + optional<path> filename; + uintmax_t size; + datetime_t modtime; + bool from_stream; + + fileinfo_t() : size(0), from_stream(true) { + TRACE_CTOR(journal_t::fileinfo_t, ""); + } + fileinfo_t(const path& _filename) + : filename(_filename), from_stream(false) { + TRACE_CTOR(journal_t::fileinfo_t, "const path&"); + size = file_size(*filename); + modtime = posix_time::from_time_t(last_write_time(*filename)); + } + fileinfo_t(const fileinfo_t& info) + : filename(info.filename), size(info.size), + modtime(info.modtime), from_stream(info.from_stream) + { + TRACE_CTOR(journal_t::fileinfo_t, "copy"); + } + ~fileinfo_t() throw() { + TRACE_DTOR(journal_t::fileinfo_t); + } + +#if defined(HAVE_BOOST_SERIALIZATION) + private: + /** Serialization. */ + + friend class boost::serialization::access; + + template<class Archive> + void serialize(Archive & ar, const unsigned int /* version */) { + ar & filename; + ar & size; + ar & modtime; + ar & from_stream; + } +#endif // HAVE_BOOST_SERIALIZATION + }; + + account_t * master; + account_t * basket; + xacts_list xacts; + auto_xacts_list auto_xacts; + period_xacts_list period_xacts; + std::list<fileinfo_t> sources; + bool was_loaded; + + shared_ptr<commodity_pool_t> commodity_pool; hooks_t<xact_finalizer_t, xact_t> xact_finalize_hooks; - journal_t(account_t * _master = NULL) : master(_master) { - TRACE_CTOR(journal_t, ""); - } + journal_t(); ~journal_t(); // These four methods are delegated to the current session, since all @@ -110,6 +152,23 @@ public: bool strict = false); bool valid() const; + +#if defined(HAVE_BOOST_SERIALIZATION) +private: + /** Serialization. */ + + friend class boost::serialization::access; + + template<class Archive> + void serialize(Archive & ar, const unsigned int /* version */) { + ar & master; + ar & basket; + ar & xacts; + ar & auto_xacts; + ar & period_xacts; + ar & sources; + } +#endif // HAVE_BOOST_SERIALIZATION }; } // namespace ledger |