Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Device.h
Go to the documentation of this file.
1 /*
2 * Copyright 2014-2018 Friedemann Zenke
3 *
4 * This file is part of Auryn, a simulation package for plastic
5 * spiking neural networks.
6 *
7 * Auryn is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Auryn is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Auryn. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * If you are using Auryn or parts of it for your work please cite:
21 * Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations
22 * of spiking neural networks using general-purpose computers.
23 * Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076
24 */
25 
26 #ifndef DEVICE_H_
27 #define DEVICE_H_
28 
29 #include "auryn_definitions.h"
30 #include "AurynVector.h"
31 #include <fstream>
32 #include <string>
33 
34 #include <boost/archive/binary_oarchive.hpp>
35 #include <boost/archive/binary_iarchive.hpp>
36 
37 namespace auryn {
38 
39  class System;
40 
47  class Device
48  {
49  private:
51  int device_id;
52 
54  static int device_id_count;
55 
58  template<class Archive>
59  void serialize(Archive & ar, const unsigned int version)
60  {
61  virtual_serialize(ar, version);
62  }
63 
64 
65  protected:
68 
70  void init();
71 
72  /* Functions necesssary for serialization and loading saving to netstate files. */
73  virtual void virtual_serialize(boost::archive::binary_oarchive & ar, const unsigned int version ) ;
74  virtual void virtual_serialize(boost::archive::binary_iarchive & ar, const unsigned int version ) ;
75 
76  public:
78  bool active;
79 
81  Device();
82 
84  void set_name(std::string s);
85 
88 
90  int get_id();
91 
93  virtual void flush();
94 
96  virtual ~Device();
97 
99  virtual void evolve() { };
100 
102  virtual void execute() { };
103  };
104 
105  BOOST_SERIALIZATION_ASSUME_ABSTRACT(Device)
106 
107  extern System * sys;
108  extern Logger * logger;
109 }
110 
111 #endif /*DEVICE_H_*/
virtual void execute()
Definition: Device.h:102
virtual void evolve()
Definition: Device.h:99
Class that implements system wide variables and methods to manage and run simulations.
Definition: System.h:70
virtual ~Device()
Standard destructor.
Definition: Device.cpp:46
virtual void flush()
Flush to file.
Definition: Device.cpp:58
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
friend class boost::serialization::access
Definition: Device.h:57
void set_name(std::string s)
Set device name.
Definition: Device.cpp:62
void init()
Standard initializer to be called by the constructor.
Definition: Device.cpp:32
Definition: ABSConnection.h:38
A generic logger class that logs to screen and a log-file.
Definition: Logger.h:48
int get_id()
Get numeric device id.
Definition: Device.cpp:72
Device()
Standard constructor.
Definition: Device.cpp:41
bool active
Standard active switch.
Definition: Device.h:78
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
std::string device_name
Identifying name for device.
Definition: Device.h:67
std::string get_name()
Get device name.
Definition: Device.cpp:67
virtual void virtual_serialize(boost::archive::binary_oarchive &ar, const unsigned int version)
Definition: Device.cpp:50
Abstract base class for all Device, Stimulator, etc objects.
Definition: Device.h:47
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156