<commit_before>#ifndef CYCLUS_TRADER_MANAGEMENT_H_
#define CYCLUS_TRADER_MANAGEMENT_H_

#include "material.h"
#include "generic_resource.h"
#include "trader.h"

namespace cyclus {

// template specializations to support inheritance and virtual functions
template<class T> std::set< RequestPortfolio<T> > QueryRequests(Trader* t) {
  return std::set< RequestPortfolio<T> >();
}

template<> std::set< RequestPortfolio<Material> >
    QueryRequests<Material>(Trader* t) {
  return t->AddMatlRequests();
}

template<> std::set< RequestPortfolio<GenericResource> >
    QueryRequests<GenericResource>(Trader* t) {
  return t->AddGenRsrcRequests();
}

template<class T> class ExchangeContext;
  
template<class T> std::set< BidPortfolio<T> >
    QueryBids(Trader* t, ExchangeContext<T>* ec) {
  return std::set< BidPortfolio<T> >();
}
  
template<> std::set< BidPortfolio<Material> >
    QueryBids<Material>(Trader* t, ExchangeContext<Material>* ec) {
  return t->AddMatlBids(ec);
}

template<> std::set< BidPortfolio<GenericResource> >
    QueryBids<GenericResource>(Trader* t, ExchangeContext<GenericResource>* ec) {
  return t->AddGenRsrcBids(ec);
}

template<class T>
    typename T::Ptr ExecTradeOffer(const Trade<T>& trade) {
  return typename T::Ptr(new T());
}

template<> Material::Ptr ExecTradeOffer<Material>(const Trade<Material>& trade) {
  return trade.bid->bidder->OfferMatlTrade(trade);
}

template<> GenericResource::Ptr
    ExecTradeOffer<GenericResource>(const Trade<GenericResource>& trade) {
  return trade.bid->bidder->OfferGenRsrcTrade(trade);
}

template<class T>
    void ExecTradeAccept(const Trade<T>& trade, typename T::Ptr rsrc) { }

template<> void ExecTradeAccept<Material>(
    const Trade<Material>& trade,
    Material::Ptr rsrc) {
  return trade.request->requester->AcceptMatlTrade(trade, rsrc);
}

template<> void ExecTradeAccept<GenericResource>(
    const Trade<GenericResource>& trade,
    GenericResource::Ptr rsrc) {
  return trade.request->requester->AcceptGenRsrcTrade(trade, rsrc);
}

template<class T> void ExecuteTrade(const Trade<T>& trade) {
  typename T::Ptr rsrc = ExecTradeOffer(trade);
  ExecTradeAccept(trade, rsrc);
}

} // namespace cyclus

#endif // ifndef CYCLUS_TRADER_MANAGEMENT_H_<commit_msg>inlined trader management functions<commit_after>#ifndef CYCLUS_TRADER_MANAGEMENT_H_
#define CYCLUS_TRADER_MANAGEMENT_H_

#include "material.h"
#include "generic_resource.h"
#include "trader.h"

namespace cyclus {
    
// template specializations to support inheritance and virtual functions
template<class T>
inline std::set< RequestPortfolio<T> > QueryRequests(Trader* t) {
  return std::set< RequestPortfolio<T> >();
}

template<>
inline std::set< RequestPortfolio<Material> >
    QueryRequests<Material>(Trader* t) {
  return t->AddMatlRequests();
}

template<>
inline std::set< RequestPortfolio<GenericResource> >
    QueryRequests<GenericResource>(Trader* t) {
  return t->AddGenRsrcRequests();
}

template<class T> class ExchangeContext;
  
template<class T>
inline std::set< BidPortfolio<T> >
    QueryBids(Trader* t, ExchangeContext<T>* ec) {
  return std::set< BidPortfolio<T> >();
}
  
template<>
inline std::set< BidPortfolio<Material> >
    QueryBids<Material>(Trader* t, ExchangeContext<Material>* ec) {
  return t->AddMatlBids(ec);
}

template<>
inline std::set< BidPortfolio<GenericResource> >
    QueryBids<GenericResource>(Trader* t, ExchangeContext<GenericResource>* ec) {
  return t->AddGenRsrcBids(ec);
}

template<class T>
inline typename T::Ptr ExecTradeOffer(const Trade<T>& trade) {
  return typename T::Ptr(new T());
}

template<>
inline Material::Ptr
    ExecTradeOffer<Material>(const Trade<Material>& trade) {
  return trade.bid->bidder->OfferMatlTrade(trade);
}

template<>
inline GenericResource::Ptr
    ExecTradeOffer<GenericResource>(const Trade<GenericResource>& trade) {
  return trade.bid->bidder->OfferGenRsrcTrade(trade);
}

template<class T>
inline void ExecTradeAccept(const Trade<T>& trade,
                                   typename T::Ptr rsrc) { }

template<>
inline void ExecTradeAccept<Material>(const Trade<Material>& trade,
                                             Material::Ptr rsrc) {
  return trade.request->requester->AcceptMatlTrade(trade, rsrc);
}

template<>
inline void ExecTradeAccept<GenericResource>(
    const Trade<GenericResource>& trade,
    GenericResource::Ptr rsrc) {
  return trade.request->requester->AcceptGenRsrcTrade(trade, rsrc);
}

template<class T>
inline void ExecuteTrade(const Trade<T>& trade) {
  typename T::Ptr rsrc = ExecTradeOffer(trade);
  ExecTradeAccept(trade, rsrc);
}

} // namespace cyclus

#endif // ifndef CYCLUS_TRADER_MANAGEMENT_H_
{'fraction_non_alphanumeric': 0.1292255027813436, 'fraction_numerical': 0.0, 'mean_word_length': 5.621813031161473, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4976261', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1535, 'n_words': 312}