28 ->AddVal(
"AgentId", creator->
id())
49 removed->parent1_ = res_->
state_id();
50 removed->parent2_ = 0;
51 removed->tracked_ = tracked_;
63 parent2_ = absorbed->res_->
state_id();
67 void ResTracker::Record() {
71 ->AddVal(
"ObjId", res_->
obj_id())
72 ->AddVal(
"Type", res_->
type())
73 ->AddVal(
"TimeCreated", ctx_->
time())
74 ->AddVal(
"Quantity", res_->
quantity())
75 ->AddVal(
"Units", res_->
units())
76 ->AddVal(
"QualId", res_->
qual_id())
77 ->AddVal(
"Parent1", parent1_)
78 ->
AddVal(
"Parent2", parent2_)
void Absorb(ResTracker *absorbed)
Should be called when a resource is combined with another.
const int obj_id() const
Returns the unique id corresponding to this resource object.
virtual const ResourceType type() const =0
A unique type/name for the concrete resource implementation.
const int state_id() const
Returns the unique id corresponding to this resource and its current state.
virtual const int id() const
The agent instance's unique ID within a simulation.
void Create(Agent *creator)
Should be called when a resource instance is newly created.
virtual int qual_id() const =0
Returns an id representing the specific resource implementation's internal state that is not accessib...
virtual double quantity() const =0
Returns the quantity of this resource with dimensions as specified by the return value of units()...
Tracks and records the state and parent-child relationships of resources as they are changed...
virtual std::string units() const =0
Returns the units this resource is based in (e.g. "kg").
Resource defines an abstract interface implemented by types that are offered, requested, and transferred between simulation agents.
virtual int time()
Returns the current simulation timestep.
void DontTrack()
Prevent a resource's heritage from being tracked and recorded.
void BumpStateId()
Assigns a new, unique internal id to this resource and its state.
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 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.
A simulation context provides access to necessary simulation-global functions and state...
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.
void Record()
Record this datum to its Recorder.
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
virtual void Record(Context *ctx) const =0
Records the resource's state to the output database.
ResTracker(Context *ctx, Resource *r)
Create a new tracker following r.