summaryrefslogtreecommitdiff
path: root/src/account.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-27 08:32:42 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-27 08:32:42 -0400
commit027c255a4fa8dd8ab9cf433e6f9491ce7e5658aa (patch)
treeeb5ab88d751ec975681ae748d441f44d4799bd63 /src/account.h
parent7fae606d622d8cd463ce5f81f5d7872a4fdebc60 (diff)
parent3ea7fbd5f6db4d362af79953b23bacc904909cff (diff)
downloadfork-ledger-027c255a4fa8dd8ab9cf433e6f9491ce7e5658aa.tar.gz
fork-ledger-027c255a4fa8dd8ab9cf433e6f9491ce7e5658aa.tar.bz2
fork-ledger-027c255a4fa8dd8ab9cf433e6f9491ce7e5658aa.zip
Merge branch 'next'
Diffstat (limited to 'src/account.h')
-rw-r--r--src/account.h37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/account.h b/src/account.h
index 56c0c72b..428f6c63 100644
--- a/src/account.h
+++ b/src/account.h
@@ -55,7 +55,7 @@ class account_t;
class xact_t;
class post_t;
-typedef std::deque<post_t *> posts_deque;
+typedef std::list<post_t *> posts_list;
typedef std::map<const string, account_t *> accounts_map;
/**
@@ -63,35 +63,37 @@ typedef std::map<const string, account_t *> accounts_map;
*
* Long.
*/
-class account_t : public scope_t
+class account_t : public supports_flags<>, public scope_t
{
- public:
+#define ACCOUNT_NORMAL 0x00 // no flags at all, a basic account
+#define ACCOUNT_KNOWN 0x01
+#define ACCOUNT_TEMP 0x02 // account is a temporary object
+
+public:
account_t * parent;
string name;
optional<string> note;
unsigned short depth;
accounts_map accounts;
- posts_deque posts;
- bool known;
+ posts_list posts;
mutable string _fullname;
account_t(account_t * _parent = NULL,
const string& _name = "",
const optional<string>& _note = none)
- : scope_t(), parent(_parent), name(_name), note(_note),
- depth(static_cast<unsigned short>(parent ? parent->depth + 1 : 0)),
- known(false) {
+ : supports_flags<>(), scope_t(), parent(_parent),
+ name(_name), note(_note),
+ depth(static_cast<unsigned short>(parent ? parent->depth + 1 : 0)) {
TRACE_CTOR(account_t, "account_t *, const string&, const string&");
}
account_t(const account_t& other)
- : scope_t(),
+ : supports_flags<>(other.flags()), scope_t(),
parent(other.parent),
name(other.name),
note(other.note),
depth(other.depth),
- accounts(other.accounts),
- known(other.known) {
+ accounts(other.accounts) {
TRACE_CTOR(account_t, "copy");
}
~account_t();
@@ -116,6 +118,7 @@ class account_t : public scope_t
void add_post(post_t * post) {
posts.push_back(post);
}
+ bool remove_post(post_t * post);
virtual expr_t::ptr_op_t lookup(const string& name);
@@ -140,7 +143,6 @@ class account_t : public scope_t
bool calculated;
bool gathered;
- // The following are only calculated if --totals is enabled
std::size_t posts_count;
std::size_t posts_virtuals_count;
std::size_t posts_cleared_count;
@@ -153,13 +155,12 @@ class account_t : public scope_t
date_t latest_post;
date_t latest_cleared_post;
- std::size_t last_size;
-
- // The following are only calculated if --gather is enabled
std::set<path> filenames;
std::set<string> accounts_referenced;
std::set<string> payees_referenced;
+ optional<posts_list::const_iterator> last_post;
+
details_t()
: calculated(false),
gathered(false),
@@ -169,9 +170,7 @@ class account_t : public scope_t
posts_cleared_count(0),
posts_last_7_count(0),
posts_last_30_count(0),
- posts_this_month_count(0),
-
- last_size(0) {}
+ posts_this_month_count(0) {}
details_t& operator+=(const details_t& other);
@@ -229,7 +228,7 @@ class account_t : public scope_t
const xdata_t::details_t& self_details(bool gather_all = true) const;
const xdata_t::details_t& family_details(bool gather_all = true) const;
- bool has_flags(xdata_t::flags_t flags) const {
+ bool has_xflags(xdata_t::flags_t flags) const {
return xdata_ && xdata_->has_flags(flags);
}
std::size_t children_with_flags(xdata_t::flags_t flags) const;