CYCLUS
Loading...
Searching...
No Matches
res_tracker.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_RES_TRACKER_H_
2#define CYCLUS_SRC_RES_TRACKER_H_
3
4#include <string>
5#include <vector>
6
7#include "context.h"
8#include "resource.h"
9
10namespace cyclus {
11
12/// Tracks and records the state and parent-child relationships of resources as
13/// they are changed. Resource implementations embed this as a member variable
14/// and invoke its methods appropriately to have their state changes tracked in
15/// the canonical core resource table.
16///
17/// Invocations to Create, Extract, Absorb, and Modify result in one or more
18/// entries in the output db Resource table and also call the Record method of
19/// the tracker's tracked resource. A zero parent id indicates a resource id
20/// has no parent; if both are zeros the resource was newly created.
22 public:
23 /// Create a new tracker following r.
25
26 /// Prevent a resource's heritage from being tracked and recorded.
27 void DontTrack();
28
29 /// Should be called when a resource instance is newly created.
30 void Create(Agent* creator);
31
32 /// Should be called when a resource has some quantity removed from it (e.g.
33 /// resource is split).
34 /// @param removed the tracker of the extracted/removed resource.
36
37 /// Should be called when a resource is combined with another.
38 /// @param absorbed the tracker of the resource being absorbed.
40
41 /// Should be called when the state of a resource changes (e.g. radioactive
42 /// decay).
43 void Modify();
44
45 /// Should be called when a resource's package gets modified. If the resource
46 /// was just created from a parent resource, the parent should be passed in.
47 /// If the resource is just being repackaged (e.g. to unpackaged), the parent
48 /// should be NULL.
49 void Package(ResTracker* parent = NULL);
50
51 private:
52 void Record(bool bumpId = true);
53
54 int parent1_;
55 int parent2_;
56 bool tracked_;
57 std::string package_name_;
58 Resource* res_;
59 Context* ctx_;
60};
61
62} // namespace cyclus
63
64#endif // CYCLUS_SRC_RES_TRACKER_H_
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
Tracks and records the state and parent-child relationships of resources as they are changed.
Definition res_tracker.h:21
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.
Definition res_tracker.cc:8
void DontTrack()
Prevent a resource's heritage from being tracked and recorded.
Resource defines an abstract interface implemented by types that are offered, requested,...
Definition resource.h:22
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters