CYCLUS
Loading...
Searching...
No Matches
trader_management.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_TRADER_MANAGEMENT_H_
2#define CYCLUS_SRC_TRADER_MANAGEMENT_H_
3
4#include "error.h"
5#include "exchange_context.h"
6#include "product.h"
7#include "material.h"
8#include "trader.h"
9
10namespace cyclus {
11
12// template specializations to support inheritance and virtual functions
13template<class T>
14inline static std::set<typename RequestPortfolio<T>::Ptr>
16 throw StateError("Non-specialized version of QueryRequests not supported");
17}
18
19template<>
20inline std::set<RequestPortfolio<Material>::Ptr>
21 QueryRequests<Material>(Trader* t) {
22 return t->GetMatlRequests();
23}
24
25template<>
26inline std::set<RequestPortfolio<Product>::Ptr>
27 QueryRequests<Product>(Trader* t) {
28 return t->GetProductRequests();
29}
30
31template<class T>
32inline static std::set<typename BidPortfolio<T>::Ptr>
34 throw StateError("Non-specialized version of QueryBids not supported");
35}
36
37template<>
38inline std::set<BidPortfolio<Material>::Ptr>
40 return t->GetMatlBids(map);
41}
42
43template<>
44inline std::set<BidPortfolio<Product>::Ptr>
46 return t->GetProductBids(map);
47}
48
49template<class T>
50inline static void PopulateTradeResponses(
52 const std::vector< Trade<T> >& trades,
53 std::vector< std::pair<Trade<T>, typename T::Ptr> >& responses) {
54 throw StateError("Non-specialized version of "
55 "PopulateTradeResponses not supported");
56}
57
58template<>
61 const std::vector< Trade<Material> >& trades,
62 std::vector<std::pair<Trade<Material>, Material::Ptr> >& responses) {
63 dynamic_cast<Trader*>(trader)->GetMatlTrades(trades, responses);
64}
65
66template<>
69 const std::vector< Trade<Product> >& trades,
70 std::vector<std::pair<Trade<Product>, Product::Ptr> >& responses) {
72}
73
74template<class T>
75inline static void AcceptTrades(
77 const std::vector< std::pair<Trade<T>, typename T::Ptr> >& responses) {
78 throw StateError("Non-specialized version of AcceptTrades not supported");
79}
80
81template<>
82inline void AcceptTrades(
84 const std::vector< std::pair<Trade<Material>, Material::Ptr> >& responses) {
85 dynamic_cast<Trader*>(trader)->AcceptMatlTrades(responses);
86}
87
88template<>
89inline void AcceptTrades(
91 const std::vector< std::pair<Trade<Product>, Product::Ptr> >& responses) {
93}
94
95} // namespace cyclus
96
97#endif // CYCLUS_SRC_TRADER_MANAGEMENT_H_
boost::shared_ptr< Material > Ptr
Definition material.h:75
boost::shared_ptr< Product > Ptr
Definition product.h:24
For failed object state expectations.
Definition error.h:53
A simple API for agents that wish to exchange resources in the simulation.
Definition trader.h:24
virtual void GetProductTrades(const std::vector< Trade< Product > > &trades, std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
default implementation for responding to product trades
Definition trader.h:72
virtual void AcceptProductTrades(const std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
default implementation for product trade acceptance
Definition trader.h:83
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
static std::set< typename BidPortfolio< T >::Ptr > QueryBids(Trader *t, typename CommodMap< T >::type &map)
std::set< RequestPortfolio< Material >::Ptr > QueryRequests< Material >(Trader *t)
std::set< RequestPortfolio< Product >::Ptr > QueryRequests< Product >(Trader *t)
static void PopulateTradeResponses(Trader *trader, const std::vector< Trade< T > > &trades, std::vector< std::pair< Trade< T >, typename T::Ptr > > &responses)
static void AcceptTrades(Trader *trader, const std::vector< std::pair< Trade< T >, typename T::Ptr > > &responses)
std::set< BidPortfolio< Material >::Ptr > QueryBids< Material >(Trader *t, CommodMap< Material >::type &map)
void PopulateTradeResponses< Material >(Trader *trader, const std::vector< Trade< Material > > &trades, std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
void PopulateTradeResponses< Product >(Trader *trader, const std::vector< Trade< Product > > &trades, std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
static std::set< typename RequestPortfolio< T >::Ptr > QueryRequests(Trader *t)
std::set< BidPortfolio< Product >::Ptr > QueryBids< Product >(Trader *t, CommodMap< Product >::type &map)
std::map< std::string, std::vector< Request< T > * > > type
A Trade is a simple container that associates a request for a resource with a bid for that resource.
Definition trade.h:16