1 /*
2  *  ring_buffer_impl.h
3  *
4  *  This file is part of NEST.
5  *
6  *  Copyright (C) 2004 The NEST Initiative
7  *
8  *  NEST is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  NEST is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with NEST.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef RING_BUFFER_IMPL_H
24 #define RING_BUFFER_IMPL_H
25 
26 #include "ring_buffer.h"
27 
28 template < unsigned int num_channels >
MultiChannelInputBuffer()29 nest::MultiChannelInputBuffer< num_channels >::MultiChannelInputBuffer()
30   : buffer_( kernel().connection_manager.get_min_delay() + kernel().connection_manager.get_max_delay(),
31       std::array< double, num_channels >() )
32 {
33 }
34 
35 template < unsigned int num_channels >
36 void
resize()37 nest::MultiChannelInputBuffer< num_channels >::resize()
38 {
39   const size_t size = kernel().connection_manager.get_min_delay() + kernel().connection_manager.get_max_delay();
40   if ( buffer_.size() != size )
41   {
42     buffer_.resize( size, std::array< double, num_channels >() );
43   }
44 }
45 
46 template < unsigned int num_channels >
47 void
clear()48 nest::MultiChannelInputBuffer< num_channels >::clear()
49 {
50   resize(); // does nothing if size is fine
51   // set all elements to 0.0
52   for ( index slot = 0; slot < buffer_.size(); ++slot )
53   {
54     reset_values_all_channels( slot );
55   }
56 }
57 
58 #endif
59