summaryrefslogtreecommitdiff
path: root/src/commodity.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-02 17:05:51 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-02 17:05:51 -0500
commite663a13502b8813a28b8aebbc611fbc040d4246b (patch)
treeaece620f1644c495bd024f6f32409bfb6bf962ae /src/commodity.h
parentdea9530cb7d65486143b866b60d9bd1e4914aa56 (diff)
downloadfork-ledger-e663a13502b8813a28b8aebbc611fbc040d4246b.tar.gz
fork-ledger-e663a13502b8813a28b8aebbc611fbc040d4246b.tar.bz2
fork-ledger-e663a13502b8813a28b8aebbc611fbc040d4246b.zip
Changed protection level of many parts of commodity_t
Diffstat (limited to 'src/commodity.h')
-rw-r--r--src/commodity.h167
1 files changed, 82 insertions, 85 deletions
diff --git a/src/commodity.h b/src/commodity.h
index af92271e..25397131 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -86,87 +86,85 @@ class commodity_t
: public delegates_flags<uint_least16_t>,
public equality_comparable1<commodity_t, noncopyable>
{
- friend class commodity_pool_t;
-
public:
- class base_t : public noncopyable, public supports_flags<uint_least16_t>
- {
- base_t() {
- TRACE_CTOR(base_t, "");
- }
+ typedef std::map<const datetime_t, amount_t> history_map;
- public:
- typedef std::map<const datetime_t, amount_t> history_map;
-
- struct history_t
- {
- history_map prices;
+ struct history_t
+ {
+ history_map prices;
- void add_price(commodity_t& source,
- const datetime_t& date,
- const amount_t& price,
- const bool reflexive = true);
- bool remove_price(const datetime_t& date);
+ void add_price(commodity_t& source,
+ const datetime_t& date,
+ const amount_t& price,
+ const bool reflexive = true);
+ bool remove_price(const datetime_t& date);
- optional<price_point_t>
- find_price(const optional<datetime_t>& moment = none,
- const optional<datetime_t>& oldest = none
+ optional<price_point_t>
+ find_price(const optional<datetime_t>& moment = none,
+ const optional<datetime_t>& oldest = none
#if defined(DEBUG_ON)
- , const int indent = 0
+ , const int indent = 0
#endif
- ) const;
+ ) const;
#if defined(HAVE_BOOST_SERIALIZATION)
- private:
- /** Serialization. */
+ private:
+ /** Serialization. */
- friend class boost::serialization::access;
+ friend class boost::serialization::access;
- template<class Archive>
- void serialize(Archive & ar, const unsigned int /* version */) {
- ar & prices;
- }
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /* version */) {
+ ar & prices;
+ }
#endif // HAVE_BOOST_SERIALIZATION
- };
-
- typedef std::map<commodity_t *, history_t> history_by_commodity_map;
-
- struct varied_history_t
- {
- history_by_commodity_map histories;
+ };
- void add_price(commodity_t& source,
- const datetime_t& date,
- const amount_t& price,
- const bool reflexive = true);
- bool remove_price(const datetime_t& date, commodity_t& commodity);
+ typedef std::map<commodity_t *, history_t> history_by_commodity_map;
- optional<price_point_t>
- find_price(const commodity_t& source,
- const optional<commodity_t&>& commodity = none,
- const optional<datetime_t>& moment = none,
- const optional<datetime_t>& oldest = none
+ struct varied_history_t
+ {
+ history_by_commodity_map histories;
+
+ void add_price(commodity_t& source,
+ const datetime_t& date,
+ const amount_t& price,
+ const bool reflexive = true);
+ bool remove_price(const datetime_t& date, commodity_t& commodity);
+
+ optional<price_point_t>
+ find_price(const commodity_t& source,
+ const optional<commodity_t&>& commodity = none,
+ const optional<datetime_t>& moment = none,
+ const optional<datetime_t>& oldest = none
#if defined(DEBUG_ON)
- , const int indent = 0
+ , const int indent = 0
#endif
- ) const;
+ ) const;
- optional<history_t&>
- history(const optional<commodity_t&>& commodity = none);
+ optional<history_t&>
+ history(const optional<commodity_t&>& commodity = none);
#if defined(HAVE_BOOST_SERIALIZATION)
- private:
- /** Serialization. */
+ private:
+ /** Serialization. */
- friend class boost::serialization::access;
+ friend class boost::serialization::access;
- template<class Archive>
- void serialize(Archive & ar, const unsigned int /* version */) {
- ar & histories;
- }
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /* version */) {
+ ar & histories;
+ }
#endif // HAVE_BOOST_SERIALIZATION
- };
+ };
+protected:
+ friend class commodity_pool_t;
+ friend class annotated_commodity_t;
+
+ class base_t : public noncopyable, public supports_flags<uint_least16_t>
+ {
+ public:
#define COMMODITY_STYLE_DEFAULTS 0x000
#define COMMODITY_STYLE_SUFFIXED 0x001
#define COMMODITY_STYLE_SEPARATED 0x002
@@ -188,11 +186,9 @@ public:
mutable bool searched;
- static bool european_by_default;
-
public:
explicit base_t(const string& _symbol)
- : supports_flags<uint_least16_t>(european_by_default ?
+ : supports_flags<uint_least16_t>(commodity_t::european_by_default ?
COMMODITY_STYLE_EUROPEAN :
COMMODITY_STYLE_DEFAULTS),
symbol(_symbol), precision(0), searched(false) {
@@ -203,33 +199,31 @@ public:
}
#if defined(HAVE_BOOST_SERIALIZATION)
- private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive & ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
- ar & symbol;
- ar & precision;
- ar & name;
- ar & note;
- ar & varied_history;
- ar & smaller;
- ar & larger;
- }
+ private:
+ base_t() {
+ TRACE_CTOR(base_t, "");
+ }
+
+ /** Serialization. */
+
+ friend class boost::serialization::access;
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /* version */) {
+ ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
+ ar & symbol;
+ ar & precision;
+ ar & name;
+ ar & note;
+ ar & varied_history;
+ ar & smaller;
+ ar & larger;
+ }
#endif // HAVE_BOOST_SERIALIZATION
};
-public:
static bool symbol_needs_quotes(const string& symbol);
- typedef base_t::history_t history_t;
- typedef base_t::history_map history_map;
- typedef base_t::varied_history_t varied_history_t;
- typedef base_t::history_by_commodity_map history_by_commodity_map;
-
shared_ptr<base_t> base;
commodity_pool_t * parent_;
@@ -237,13 +231,16 @@ public:
optional<string> mapping_key_;
bool annotated;
-public:
explicit commodity_t(commodity_pool_t * _parent,
const shared_ptr<base_t>& _base)
: delegates_flags<uint_least16_t>(*_base.get()), base(_base),
parent_(_parent), annotated(false) {
TRACE_CTOR(commodity_t, "commodity_pool_t *, shared_ptr<base_t>");
}
+
+public:
+ static bool european_by_default;
+
virtual ~commodity_t() {
TRACE_DTOR(commodity_t);
}