9 : tracked_(true), res_(r), ctx_(ctx), parent1_(0), parent2_(0) {}
24 ctx_->NewDatum(
"ResCreators")
25 ->AddVal(
"ResourceId", res_->state_id())
26 ->AddVal(
"AgentId", creator->
id())
35 parent1_ = res_->state_id();
46 parent1_ = res_->state_id();
53 removed->parent1_ = res_->state_id();
54 removed->parent2_ = 0;
55 removed->tracked_ = tracked_;
68 parent1_ = res_->state_id();
69 parent2_ = absorbed->res_->
state_id();
79 package_name_ = res_->package_name();
82 parent1_ = parent->res_->state_id();
91 parent1_ = res_->state_id();
96void ResTracker::Record(
bool bumpId) {
110 ->
AddVal(
"Parent1", parent1_)
111 ->
AddVal(
"Parent2", parent2_)
The abstract base class used by all types of agents that live and interact in a simulation.
virtual const int id() const
The agent instance's unique ID within a simulation.
A simulation context provides access to necessary simulation-global functions and state.
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
virtual int time()
Returns the current simulation timestep.
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
void Record()
Record this datum to its Recorder.
void Create(Agent *creator)
Should be called when a resource instance is newly created.
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.
ResTracker(Context *ctx, Resource *r)
Create a new tracker following r.
void DontTrack()
Prevent a resource's heritage from being tracked and recorded.
Resource defines an abstract interface implemented by types that are offered, requested,...
double UnitValue() const
Returns the unit value of this resource.
const int state_id() const
Returns the unique id corresponding to this resource and its current state.
virtual const ResourceType type() const =0
A unique type/name for the concrete resource implementation.
virtual std::string units() const =0
Returns the units this resource is based in (e.g. "kg").
virtual void Record(Context *ctx) const =0
Records the resource's state to the output database.
virtual double quantity() const =0
Returns the quantity of this resource with dimensions as specified by the return value of units().
const int obj_id() const
Returns the unique id corresponding to this resource object.
virtual std::string package_name()
Returns the package id.
void BumpStateId()
Assigns a new, unique internal id to this resource and its state.
virtual int qual_id() const =0
Returns an id representing the specific resource implementation's internal state that is not accessib...
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