NEST main@f146f75
Loading...
Searching...
No Matches
io_manager.h
Go to the documentation of this file.
1/*
2 * io_manager.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 IO_MANAGER_H
24#define IO_MANAGER_H
25
26// C++ includes:
27#include <set>
28#include <string>
29
30// Includes from libnestutil:
31#include "manager_interface.h"
32
33#include "recording_backend.h"
34#include "stimulation_backend.h"
35
36namespace nest
37{
38
50{
51public:
52 IOManager();
53 ~IOManager() override;
54
55 void initialize( const bool ) override;
56 void finalize( const bool ) override;
57 void set_status( const Dictionary& ) override;
58 void get_status( Dictionary& ) override;
59
60 void set_recording_backend_status( std::string, const Dictionary& );
62
69 const std::string& get_data_prefix() const;
70
77 const std::string& get_data_path() const;
78
85 bool overwrite_files() const;
86
91 void post_run_hook();
92 void pre_run_hook();
93
98 void post_step_hook();
99
105 void cleanup() override;
106 void prepare() override;
107
108 template < class RecordingBackendT >
109 void register_recording_backend( const std::string& );
110 template < class StimulationBackendT >
111 void register_stimulation_backend( const std::string& );
112
113 bool is_valid_recording_backend( const std::string& ) const;
114 bool is_valid_stimulation_backend( const std::string& ) const;
115
133 void write( const std::string&,
134 const RecordingDevice&,
135 const Event&,
136 const std::vector< double >&,
137 const std::vector< long >& );
138
139 void enroll_recorder( const std::string&, const RecordingDevice&, const Dictionary& );
140 void enroll_stimulator( const std::string&, StimulationDevice&, const Dictionary& );
141
142 void set_recording_value_names( const std::string& backend_name,
143 const RecordingDevice& device,
144 const std::vector< std::string >& double_value_names,
145 const std::vector< std::string >& long_value_names );
146
147 void check_recording_backend_device_status( const std::string&, const Dictionary& );
148 void get_recording_backend_device_defaults( const std::string&, Dictionary& );
149 void get_recording_backend_device_status( const std::string&, const RecordingDevice&, Dictionary& );
150
151private:
152 void set_data_path_prefix_( const Dictionary& );
153
155 template < typename BackendT >
156 void remove_backends_( std::map< std::string, BackendT* >& backends, const std::set< std::string >& keep );
157
158 std::string data_path_;
159 std::string data_prefix_;
161
165 std::map< std::string, RecordingBackend* > recording_backends_;
166
170 std::map< std::string, StimulationBackend* > stimulation_backends_;
171
178 std::set< std::string > builtin_recording_backends_;
179 std::set< std::string > builtin_stimulation_backends_;
180};
181
182inline const std::string&
184{
185 return data_path_;
186}
187
188inline const std::string&
190{
191 return data_prefix_;
192}
193
194inline bool
196{
197 return overwrite_files_;
198}
199
200} // namespace nest
201
202#endif /* #ifndef IO_MANAGER_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Encapsulate information sent between nodes.
Definition event.h:103
void set_status(const Dictionary &) override
Set the status of the manager.
Definition io_manager.cpp:214
void pre_run_hook()
Definition io_manager.cpp:253
~IOManager() override
Definition io_manager.cpp:65
void register_stimulation_backend(const std::string &)
Definition io_manager_impl.h:48
void register_recording_backend(const std::string &)
Definition io_manager_impl.h:33
void get_status(Dictionary &) override
Retrieve the status of the manager.
Definition io_manager.cpp:231
void get_recording_backend_device_status(const std::string &, const RecordingDevice &, Dictionary &)
Definition io_manager.cpp:404
void cleanup() override
Finalize all registered recording backends after a call to SimulationManager::simulate() or Simulatio...
Definition io_manager.cpp:301
void set_recording_value_names(const std::string &backend_name, const RecordingDevice &device, const std::vector< std::string > &double_value_names, const std::vector< std::string > &long_value_names)
Definition io_manager.cpp:383
void set_recording_backend_status(std::string, const Dictionary &)
Definition io_manager.cpp:208
const std::string & get_data_path() const
The path for files written by devices.
Definition io_manager.h:183
void initialize(const bool) override
Prepare manager for operation.
Definition io_manager.cpp:70
const std::string & get_data_prefix() const
The prefix for files written by devices.
Definition io_manager.h:189
std::set< std::string > builtin_stimulation_backends_
Definition io_manager.h:179
IOManager()
Definition io_manager.cpp:60
std::map< std::string, StimulationBackend * > stimulation_backends_
A mapping from names to registered stimulation backends.
Definition io_manager.h:170
bool is_valid_recording_backend(const std::string &) const
Definition io_manager.cpp:314
void check_recording_backend_device_status(const std::string &, const Dictionary &)
Definition io_manager.cpp:392
Dictionary get_recording_backend_status(std::string)
Definition io_manager.cpp:222
void write(const std::string &, const RecordingDevice &, const Event &, const std::vector< double > &, const std::vector< long > &)
Send device data to a given recording backend.
Definition io_manager.cpp:326
void post_step_hook()
Clean up in all registered recording backends after a single simulation step by calling the backends'...
Definition io_manager.cpp:279
bool overwrite_files() const
Indicate if existing data files should be overwritten.
Definition io_manager.h:195
void remove_backends_(std::map< std::string, BackendT * > &backends, const std::set< std::string > &keep)
Delete and remove all backends except those named in keep.
Definition io_manager.cpp:145
void get_recording_backend_device_defaults(const std::string &, Dictionary &)
Definition io_manager.cpp:398
std::set< std::string > builtin_recording_backends_
Names of the built-in recording and stimulation backends.
Definition io_manager.h:178
void enroll_recorder(const std::string &, const RecordingDevice &, const Dictionary &)
Definition io_manager.cpp:336
std::string data_prefix_
Prefix for all files written by devices.
Definition io_manager.h:159
void prepare() override
Definition io_manager.cpp:288
bool overwrite_files_
If true, overwrite existing data files.
Definition io_manager.h:160
void enroll_stimulator(const std::string &, StimulationDevice &, const Dictionary &)
Definition io_manager.cpp:352
bool is_valid_stimulation_backend(const std::string &) const
Definition io_manager.cpp:320
std::map< std::string, RecordingBackend * > recording_backends_
A mapping from names to registered recording backends.
Definition io_manager.h:165
void set_data_path_prefix_(const Dictionary &)
Definition io_manager.cpp:162
void post_run_hook()
Clean up in all registered recording backends after a single call to run by calling the backends' pos...
Definition io_manager.cpp:266
void finalize(const bool) override
Take down manager after operation.
Definition io_manager.cpp:123
std::string data_path_
Path for all files written by devices.
Definition io_manager.h:158
ManagerInterface(ManagerInterface const &)=delete
Base class for all recording devices.
Definition recording_device.h:157
Base class for common properties of StimulationDevices.
Definition stimulation_device.h:154
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33