summaryrefslogtreecommitdiff
path: root/core/property_instance.hpp
blob: 74a1a98bdab9ffd8f701c6fc710bc25e5f922de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef m6EAApyWyIDlhjYO7FswFNLRrB0
#define m6EAApyWyIDlhjYO7FswFNLRrB0

#include <boost/static_assert.hpp>

#include "checkpoint.hpp"
#include "ephermal_checkpoint.hpp"
#include "pointers.hpp"
#include "quant_types.hpp"
#include "string_helpers.hpp"

namespace PropertyInstanceImpl {

template <
  typename Prop,
  bool doWriteResults,
  typename Quant = typename Prop::quant,
  typename QuantClass = typename Prop::quant::class_t
  > struct PropertyInstance_Container;

template <typename Prop>
struct PropertyInstance_Container<
  Prop, true, typename Prop::quant, ContinuousPropertyClass> {
  PropertyInstance_Container() : 
    data(string(Prop::quant::name) + "_" + string(Prop::name), Prop::initialValue)
  {}
  typedef Checkpoint<typename Prop::type, 
		     Prop::quant::instance_ptr_t::numInstances()> type;
  type data;
};

template <typename Prop>
struct PropertyInstance_Container<
  Prop, false, typename Prop::quant, ContinuousPropertyClass> {
  PropertyInstance_Container() :
    data(string(Prop::quant::name) + "_" + string(Prop::name), Prop::initialValue)
  {}
  typedef EphermalCheckpoint<typename Prop::type, 
			     Prop::quant::instance_ptr_t::numInstances()> type;
  type data;
};

template <typename Prop, bool doWriteResults>
struct PropertyInstance_Container<
  Prop, doWriteResults, typename Prop::quant, DiscretePropertyClass> {
  PropertyInstance_Container() : 
    data(string(Prop::quant::name) + "_" + string(Prop::name), 
	 Prop::instance_ptr_t::maxInstances())
  {}
  typedef Vector<
    typename Prop::type,
    8 * Prop::size, // size in [bits]
    boost::mpl::bool_<doWriteResults>
    > type;
  type data;
};

} // namespace PropertyInstanceImpl

template <typename Prop, bool doWriteResults>
struct PropertyInstance : 
  PropertyInstanceImpl::PropertyInstance_Container<Prop, doWriteResults> {};


#endif // m6EAApyWyIDlhjYO7FswFNLRrB0
contact: Jan Huwald // Impressum