summaryrefslogtreecommitdiff
path: root/src/pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pool.h')
-rw-r--r--src/pool.h62
1 files changed, 29 insertions, 33 deletions
diff --git a/src/pool.h b/src/pool.h
index 4b935f69..eb630781 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2010, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2012, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -46,6 +46,9 @@
#ifndef _POOL_H
#define _POOL_H
+#include "history.h"
+#include "annotate.h"
+
namespace ledger {
struct cost_breakdown_t
@@ -64,50 +67,47 @@ public:
* explicitly by calling the create methods of commodity_pool_t, or
* implicitly by parsing a commoditized amount.
*/
- typedef std::map<string, commodity_t *> commodities_map;
-
- commodities_map commodities;
- commodity_t * null_commodity;
- commodity_t * default_commodity;
-
- bool keep_base; // --base
+ typedef std::map<string, shared_ptr<commodity_t> > commodities_map;
+ typedef std::map<std::pair<string, annotation_t>,
+ shared_ptr<annotated_commodity_t> > annotated_commodities_map;
- optional<path> price_db; // --price-db=
- long quote_leeway; // --leeway=
- bool get_quotes; // --download
+ commodities_map commodities;
+ annotated_commodities_map annotated_commodities;
+ commodity_history_t commodity_price_history;
+ commodity_t * null_commodity;
+ commodity_t * default_commodity;
- static shared_ptr<commodity_pool_t> current_pool;
+ bool keep_base; // --base
+ optional<path> price_db; // --price-db=
+ long quote_leeway; // --leeway=
+ bool get_quotes; // --download
function<optional<price_point_t>
- (commodity_t& commodity, const optional<commodity_t&>& in_terms_of)>
+ (commodity_t& commodity, const commodity_t * in_terms_of)>
get_commodity_quote;
- explicit commodity_pool_t();
+ static shared_ptr<commodity_pool_t> current_pool;
+ explicit commodity_pool_t();
virtual ~commodity_pool_t() {
TRACE_DTOR(commodity_pool_t);
- foreach (commodities_map::value_type& pair, commodities)
- checked_delete(pair.second);
}
- string make_qualified_name(const commodity_t& comm,
- const annotation_t& details);
-
commodity_t * create(const string& symbol);
commodity_t * find(const string& name);
commodity_t * find_or_create(const string& symbol);
+ commodity_t * alias(const string& name, commodity_t& referent);
- commodity_t * create(const string& symbol, const annotation_t& details);
- commodity_t * find(const string& symbol, const annotation_t& details);
+ commodity_t * create(const string& symbol,
+ const annotation_t& details);
+ commodity_t * find(const string& symbol,
+ const annotation_t& details);
commodity_t * find_or_create(const string& symbol,
const annotation_t& details);
+ commodity_t * find_or_create(commodity_t& comm, const annotation_t& details);
- commodity_t * create(commodity_t& comm,
- const annotation_t& details,
- const string& mapping_key);
-
- commodity_t * find_or_create(commodity_t& comm,
- const annotation_t& details);
+ annotated_commodity_t * create(commodity_t& comm,
+ const annotation_t& details);
// Exchange one commodity for another, while recording the factored price.
@@ -118,6 +118,7 @@ public:
cost_breakdown_t exchange(const amount_t& amount,
const amount_t& cost,
const bool is_per_unit = false,
+ const bool add_price = true,
const optional<datetime_t>& moment = none,
const optional<string>& tag = none);
@@ -131,12 +132,6 @@ public:
const bool add_prices = true,
const optional<datetime_t>& moment = none);
- // Output the commodity price map for a given date as a DOT file
-
- void print_pricemap(std::ostream& out,
- const keep_details_t& keep,
- const optional<datetime_t>& moment = none);
-
#if defined(HAVE_BOOST_SERIALIZATION)
private:
/** Serialization. */
@@ -147,6 +142,7 @@ private:
void serialize(Archive& ar, const unsigned int /* version */) {
ar & current_pool;
ar & commodities;
+ ar & annotated_commodities;
ar & null_commodity;
ar & default_commodity;
ar & keep_base;