20 #ifndef RIPPLE_APP_BOOK_OFFER_H_INCLUDED
21 #define RIPPLE_APP_BOOK_OFFER_H_INCLUDED
23 #include <ripple/basics/contract.h>
24 #include <ripple/ledger/View.h>
25 #include <ripple/protocol/Quality.h>
26 #include <ripple/protocol/SField.h>
27 #include <ripple/protocol/STLedgerEntry.h>
33 template <
class TIn,
class TOut>
48 template <
class TIn = STAmount,
class TOut = STAmount>
90 TAmounts<TIn, TOut>
const&
112 Throw<std::logic_error>(
"can't consume more than is available.");
115 Throw<std::logic_error>(
"can't produce more than is available.");
142 template <
class TIn,
class TOut>
146 , m_account(m_entry->getAccountID(
sfAccount))
148 auto const tp = m_entry->getFieldAmount(
sfTakerPays);
149 auto const tg = m_entry->getFieldAmount(
sfTakerGets);
150 m_amounts.in = toAmount<TIn>(tp);
151 m_amounts.out = toAmount<TOut>(tg);
152 this->issIn_ = tp.issue();
153 this->issOut_ = tg.issue();
162 , m_account(m_entry->getAccountID(
sfAccount))
169 template <
class TIn,
class TOut>
176 static_assert(
sizeof(TOut) == -1,
"Must be specialized");
184 m_entry->setFieldAmount(
sfTakerPays, m_amounts.in);
185 m_entry->setFieldAmount(
sfTakerGets, m_amounts.out);
212 template <
class TIn,
class TOut>
223 return m_amounts.in.issue();
226 template <
class TIn,
class TOut>
230 return this->issOut_;
237 return m_amounts.out.issue();
240 template <
class TIn,
class TOut>
244 return os << offer.id();
TAmounts< TIn, TOut > m_amounts
A currency issued by an account.
bool fully_consumed() const
Returns true if no more funds can flow through this offer.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
std::ostream & operator<<(std::ostream &os, TOffer< TIn, TOut > const &offer)
Writeable view to a ledger, for applying a transaction.
const Quality quality() const noexcept
Returns the quality of the offer.
TAmounts< TIn, TOut > const & amount() const
Returns the in and out amounts.
const SF_AMOUNT sfTakerPays
STAmount toSTAmount(IOUAmount const &iou, Issue const &iss)
AccountID const & owner() const
Returns the account id of the offer's owner.
const SF_AMOUNT sfTakerGets
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void consume(ApplyView &view, TAmounts< TIn, TOut > const &consumed)
Adjusts the offer to indicate that we consumed some (or all) of it.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
const SF_ACCOUNT sfAccount