10 std::map<std::string, int> Product::qualids_;
11 int Product::next_qualid_ = 1;
16 if (qualids_.count(quality) == 0) {
17 qualids_[
quality] = next_qualid_++;
19 ->
AddVal(
"QualId", qualids_[quality])
20 ->
AddVal(
"Quality", quality)
26 r->tracker_.Create(creator);
34 r->tracker_.DontTrack();
48 if (other->quality() !=
quality()) {
49 throw ValueError(
"incompatible resource types.");
51 quantity_ += other->quantity();
54 tracker_.
Absorb(&other->tracker_);
59 if (quantity > quantity_) {
60 throw ValueError(
"Attempted to extract more quantity than exists.");
66 tracker_.
Extract(&other->tracker_);
void Absorb(ResTracker *absorbed)
Should be called when a resource is combined with another.
For values that are too big, too small, etc.
boost::shared_ptr< Product > Ptr
A Product is a general type of resource in the Cyclus simulation, and is a catch-all for non-standard...
virtual Resource::Ptr ExtractRes(double quantity)
Splits the resource and returns the extracted portion as a new resource object.
Resource defines an abstract interface implemented by types that are offered, requested, and transferred between simulation agents.
void Absorb(Product::Ptr other)
Absorbs the contents of the given 'other' resource into this resource.
static Ptr Create(Agent *creator, double quantity, std::string quality)
Creates a new product that is "live" and tracked.
Context * context() const
Returns this agent's simulation context.
void DontTrack()
Prevent a resource's heritage from being tracked and recorded.
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
virtual const std::string & quality() const
Returns the quality of this resource (e.g. bananas, human labor, water, etc.).
void Extract(ResTracker *removed)
Should be called when a resource has some quantity removed from it (e.g.
Code providing rudimentary logging capability for the Cyclus core.
A simulation context provides access to necessary simulation-global functions and state...
boost::shared_ptr< Resource > Ptr
The abstract base class used by all types of agents that live and interact in a simulation.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
static const ResourceType kType
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()...
void Record()
Record this datum to its Recorder.
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...
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
Product::Ptr Extract(double quantity)
Extracts the specified mass from this resource and returns it as a new product object with the same q...