summaryrefslogtreecommitdiff
path: root/core/index_randomspike.hpp
blob: a40a99b656436860870bd554a3ce4f6888d60d23 (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
#ifndef zpkaBa96qijSBV6tlRldSMrZ3N0
#define zpkaBa96qijSBV6tlRldSMrZ3N0

#include "index_spike_base.hpp"

template<>
struct Index<RandomSpike> : CommonSpikeIndex<Ptr<RandomSpike>::ptr_t> {
  typedef boost::tuple<> con_arg_t;
  Index() :
    CommonSpikeIndex("randomspike"),
    eventTime("index_randomspike_eventtime", maxSpikes),
    maxEventTime("index_randomspike_maxeventtime", Time::beforeAll())
  {}
  Index(const con_arg_t &) : 
    CommonSpikeIndex("randomspike"),
    eventTime("index_randomspike_eventtime", maxSpikes),
    maxEventTime("index_randomspike_maxeventtime", Time::beforeAll())
  {}

  //  using Index<SpikeBaseCase>::first;

  // write
  template<typename SrcQuant>
  inline ptr_t add(Time time, Time eventTime, SrcQuant src);

  virtual void sync() {
    CommonSpikeIndex::sync();
    eventTime.barrierRead() = eventTime.barrierWrite() = time.barrierWrite();
    eventTime.sync();
    maxEventTime.sync();
  }

  // data
  Vector<Time> eventTime;
  Checkpoint<Time, maxNeurons> maxEventTime;
};

template<typename IllegalImpl>
Index<RandomSpike>::ptr_t Index<RandomSpike>::
add(Time, Time, IllegalImpl) DO_NOT_CALL

template<>
Index<RandomSpike>::ptr_t Index<RandomSpike>::
add(Time t_in, Time t_out, neuron_ptr_t aSrc) {
  ptr_t ptr(CommonSpikeIndex::add(t_in, t_out, aSrc));
  eventTime.set(ptr, t_out);
  maxEventTime.set(t_in, aSrc(), 
		   std::max(t_out, maxEventTime.getValue(t_in, aSrc())));
  return ptr;
}

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