11std::map<std::string, int> Product::qualids_;
12int Product::next_qualid_ = 1;
16 std::string quality, std::string package_name) {
17 if (qualids_.count(
quality) == 0) {
18 qualids_[
quality] = next_qualid_++;
19 creator->context()->NewDatum(
"Products")
20 ->AddVal(
"QualId", qualids_[
quality])
33 std::string quality) {
35 r->tracker_.DontTrack();
43 g->tracker_.DontTrack();
50 throw ValueError(
"incompatible resource types.");
52 quantity_ +=
other->quantity();
61 throw ValueError(
"Attempted to extract more quantity than exists.");
73 return boost::static_pointer_cast<Resource>(
Extract(qty));
81 if (qty > quantity_) {
82 throw ValueError(
"Attempted to extract more quantity than exists.");
90 other->tracker_.Package(&tracker_);
94 return boost::static_pointer_cast<Resource>(
other);
109 double min =
p->fill_min();
110 double max =
p->fill_max();
111 if (quantity_ >=
min && quantity_ <= max) {
115 throw ValueError(
"Product quantity is outside of package fill limits.");
120Product::Product(
Context* ctx,
double quantity, std::string quality, std::string package_name)
125 package_name_(package_name) {}
The abstract base class used by all types of agents that live and interact in a simulation.
A simulation context provides access to necessary simulation-global functions and state.
Package::Ptr GetPackage(std::string name)
Retrieve a registered package.
boost::shared_ptr< Package > Ptr
static std::string unpackaged_name()
A Product is a general type of resource in the Cyclus simulation, and is a catch-all for non-standard...
virtual Resource::Ptr Clone() const
Returns an untracked (not part of the simulation) copy of the resource.
virtual double quantity() const
Returns the quantity of this resource with dimensions as specified by the return value of units().
static Ptr Create(Agent *creator, double quantity, std::string quality, std::string package_name=Package::unpackaged_name())
Creates a new product that is "live" and tracked.
virtual std::string package_name()
Returns the package id.
boost::shared_ptr< Product > Ptr
virtual const std::string & quality() const
Returns the quality of this resource (e.g. bananas, human labor, water, etc.).
static Ptr CreateUntracked(double quantity, std::string quality)
Creates a new product that does not actually exist as part of the simulation and is untracked.
virtual Resource::Ptr PackageExtract(double qty, std::string new_package_name=Package::unpackaged_name())
void Absorb(Product::Ptr other)
Absorbs the contents of the given 'other' resource into this resource.
static const ResourceType kType
virtual void ChangePackage(std::string new_package_name=Package::unpackaged_name())
Changes the product's package id.
virtual Resource::Ptr ExtractRes(double quantity)
Splits the resource and returns the extracted portion as a new resource object.
Product::Ptr Extract(double quantity)
Extracts the specified mass from this resource and returns it as a new product object with the same q...
void Modify()
Should be called when the state of a resource changes (e.g.
void Extract(ResTracker *removed)
Should be called when a resource has some quantity removed from it (e.g.
void Package(ResTracker *parent=NULL)
Should be called when a resource's package gets modified.
void Absorb(ResTracker *absorbed)
Should be called when a resource is combined with another.
boost::shared_ptr< Resource > Ptr
For values that are too big, too small, etc.
Code providing rudimentary logging capability for the Cyclus core.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
double eps_rsrc()
an epsilon value to be used by resources
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters