NEST  2.6.0,not_revisioned_source_dir@0
music_event_handler.h
Go to the documentation of this file.
1 /*
2  * music_event_handler.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 MUSIC_EVENT_HANDLER
24 #define MUSIC_EVENT_HANDLER
25 
26 #include "config.h"
27 
28 #ifdef HAVE_MUSIC
29 
30 #include <music.hh>
31 #include "nest.h"
32 #include "node.h"
33 
34 #include <queue>
35 
36 namespace nest {
37 
38  class Network;
39 
43 class MusicEventHandler : public MUSIC::EventHandlerGlobalIndex
44 {
45 public:
47  MusicEventHandler(std::string portname, double acceptable_latency, int max_buffered, Network* net);
48 
49  virtual ~MusicEventHandler();
50 
54  void register_channel(int channel, nest::Node* mp);
55 
61  void publish_port();
62 
68  void operator () (double t, MUSIC::GlobalIndex channel);
69 
74  void update(Time const &, const long_t, const long_t);
75 
76 private:
77  MUSIC::EventInputPort *music_port_;
78  MUSIC::PermutationIndex *music_perm_ind_;
79  bool published_;
80  std::string portname_;
81  std::vector<nest::Node*> channelmap_;
82  std::vector<MUSIC::GlobalIndex> indexmap_;
86 
92  std::vector< std::priority_queue< double, std::vector<double>, std::greater<double> > > eventqueue_;
93 };
94 
95 } // namespace nest
96 
97 #endif // HAVE_MUSIC
98 
99 #endif // MUSIC_EVENT_HANDLER
Declarations for base class Node.
int max_buffered_
Definition: music_event_handler.h:84
void update(Time const &, const long_t, const long_t)
This function is called by the scheduler and delivers the queued events to the target music_in_proxie...
Definition: music_event_handler.cpp:125
void operator()(double t, MUSIC::GlobalIndex channel)
Called by MUSIC from within tick() to deliver events to NEST.
Definition: music_event_handler.cpp:119
std::vector< MUSIC::GlobalIndex > indexmap_
Maps local index to global MUSIC index (channel)
Definition: music_event_handler.h:82
void publish_port()
Publish the MUSIC port.
Definition: music_event_handler.cpp:80
Definition: nest_time.h:130
MUSIC::PermutationIndex * music_perm_ind_
Definition: music_event_handler.h:78
virtual ~MusicEventHandler()
Definition: music_event_handler.cpp:53
std::vector< std::priority_queue< double, std::vector< double >, std::greater< double > > > eventqueue_
Buffers incoming spike events until they are due.
Definition: music_event_handler.h:92
double acceptable_latency_
The acceptable latency of the port in ms.
Definition: music_event_handler.h:83
Main administrative interface to the network.
Definition: network.h:135
MusicEventHandler()
Definition: music_event_handler.cpp:34
Event handler for all events of a MUSIC port received on this process.
Definition: music_event_handler.h:43
Default types used by the NEST kernel.
Base class for all NEST network objects.
Definition: node.h:96
bool published_
Definition: music_event_handler.h:79
std::vector< nest::Node * > channelmap_
Maps channel number to music_event_in_proxy.
Definition: music_event_handler.h:81
Network * net_
Pointer to global network driver.
Definition: music_event_handler.h:85
MUSIC::EventInputPort * music_port_
Definition: music_event_handler.h:77
long long_t
Integer number with at least 32 bit.
Definition: nest.h:96
void register_channel(int channel, nest::Node *mp)
Register a new node to a specific channel on this port.
Definition: music_event_handler.cpp:65
std::string portname_
Definition: music_event_handler.h:80