summaryrefslogtreecommitdiff
path: root/src/journal.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-30 20:50:57 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-31 00:09:57 -0400
commit2149a8e773cb8bf84aa803ee12373b4861d03714 (patch)
treed73c7bcde5320125c659a4703cfc8edd074b9c13 /src/journal.h
parent63aa8992a81dfaececa4a9b38ba8daf29b57912e (diff)
downloadfork-ledger-2149a8e773cb8bf84aa803ee12373b4861d03714.tar.gz
fork-ledger-2149a8e773cb8bf84aa803ee12373b4861d03714.tar.bz2
fork-ledger-2149a8e773cb8bf84aa803ee12373b4861d03714.zip
Create a --cache option, for using a binary cache
Diffstat (limited to 'src/journal.h')
-rw-r--r--src/journal.h58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/journal.h b/src/journal.h
index 4ad10fd3..03a465f8 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -48,11 +48,10 @@
#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;
@@ -73,11 +72,55 @@ 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;
+ std::size_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;
@@ -123,6 +166,7 @@ private:
ar & xacts;
ar & auto_xacts;
ar & period_xacts;
+ ar & sources;
}
#endif // HAVE_BOOST_SERIALIZATION
};