Utopia  2
Framework for studying models of complex & adaptive systems.
CopyMeBare.hh
Go to the documentation of this file.
1 #ifndef UTOPIA_MODELS_COPYMEBARE_HH
2 #define UTOPIA_MODELS_COPYMEBARE_HH
3 // TODO Adjust above include guard (and at bottom of file)
4 
5 // standard library includes
6 #include <random>
7 
8 // third-party library includes
9 
10 // Utopia-related includes
11 #include <utopia/core/model.hh>
12 #include <utopia/core/types.hh>
13 
14 
15 namespace Utopia {
16 namespace Models {
17 namespace CopyMeBare {
18 
19 // ++ Type definitions ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 
23 
24 
25 // ++ Model definition ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27 
30 class CopyMeBare:
31  public Model<CopyMeBare, ModelTypes>
32 {
33 public:
36 
38  using DataGroup = typename Base::DataGroup;
39 
41  using DataSet = typename Base::DataSet;
42 
43 
44 private:
45  // Base members: _time, _name, _cfg, _hdfgrp, _rng, _monitor, _space
46  // ... but you should definitely check out the documentation ;)
47 
48  // -- Members -------------------------------------------------------------
49 
50 
51  // .. Temporary objects ...................................................
52 
53 
54  // .. Datasets ............................................................
55  // NOTE They should be named '_dset_<name>', where <name> is the
56  // dataset's actual name as set in its constructor. Ideally, do not
57  // hide them inside a struct ...
58  // std::shared_ptr<DataSet> _dset_my_var;
59 
60 
61 public:
62  // -- Model Setup ---------------------------------------------------------
63 
65 
73  template<class ParentModel>
75  const std::string& name,
76  ParentModel& parent_model,
77  const DataIO::Config& custom_cfg = {}
78  )
79  :
80  Base(name, parent_model, custom_cfg)
81  {}
82 
83 
84 private:
85  // .. Setup functions .....................................................
86 
87  // .. Helper functions ....................................................
88 
89 public:
90  // -- Public Interface ----------------------------------------------------
91  // .. Simulation Control ..................................................
92 
94 
97  void perform_step () {
98 
99  }
100 
101 
103 
108  void monitor () {
109  // Can supply information to the monitor here in two ways:
110  // this->_monitor.set_entry("key", value);
111  // this->_monitor.set_entry("key", [this](){return 42.;});
112  }
113 
114 
116 
120  void write_data () {
121  // Example:
122  // _dset_foo->write(it.begin(), it.end(),
123  // [](const auto& element) {
124  // return element.get_value();
125  // });
126  }
127 
128 
129  // Getters and setters ....................................................
130  // Add getters and setters here to interface with other model
131 
132 };
133 
134 } // namespace CopyMeBare
135 } // namespace Models
136 } // namespace Utopia
137 
138 #endif // UTOPIA_MODELS_COPYMEBARE_HH
Base class interface for Models using the CRT Pattern.
Definition: model.hh:112
typename ModelTypes::DataSet DataSet
Data type that is used for storing data.
Definition: model.hh:125
typename ModelTypes::DataGroup DataGroup
Data type that is used for storing datasets.
Definition: model.hh:122
The CopyMeBare Model; the bare-basics a model needs.
Definition: CopyMeBare.hh:32
typename Base::DataGroup DataGroup
Data type of the group to write model data to, holding datasets.
Definition: CopyMeBare.hh:38
void perform_step()
Iterate a single step.
Definition: CopyMeBare.hh:97
Model< CopyMeBare, ModelTypes > Base
The type of the Model base class of this derived class.
Definition: CopyMeBare.hh:35
typename Base::DataSet DataSet
Data type for a dataset.
Definition: CopyMeBare.hh:41
void write_data()
Write data.
Definition: CopyMeBare.hh:120
void monitor()
Monitor model information.
Definition: CopyMeBare.hh:108
CopyMeBare(const std::string &name, ParentModel &parent_model, const DataIO::Config &custom_cfg={})
Construct the CopyMeBare model.
Definition: CopyMeBare.hh:74
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition: types.hh:71
Definition: agent.hh:11
Wrapper struct for defining model class data types.
Definition: model.hh:92