Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
auryn::Monitor Class Reference

Abstract base class for all Monitor objects. More...

#include <Monitor.h>

Inheritance diagram for auryn::Monitor:
Inheritance graph
[legend]
Collaboration diagram for auryn::Monitor:
Collaboration graph
[legend]

Public Member Functions

virtual void flush ()
 Flush to file. More...
 
 Monitor (std::string filename, std::string default_extension="dat")
 Standard constructor with file name. More...
 
 Monitor ()
 Constructor which does not open a text file for output. More...
 
std::string generate_filename (std::string name_hint="")
 Generates a default filename from the device ID. More...
 
virtual ~Monitor ()
 Standard destructor. More...
 
- Public Member Functions inherited from auryn::Device
 Device ()
 Standard constructor. More...
 
void set_name (std::string s)
 Set device name. More...
 
std::string get_name ()
 Get device name. More...
 
int get_id ()
 Get numeric device id. More...
 
virtual ~Device ()
 Standard destructor. More...
 
virtual void evolve ()
 
virtual void execute ()
 

Public Attributes

bool active
 Standard active switch. More...
 
- Public Attributes inherited from auryn::Device
bool active
 Standard active switch. More...
 

Protected Member Functions

virtual void open_output_file (std::string filename)
 
virtual void virtual_serialize (boost::archive::binary_oarchive &ar, const unsigned int version)
 
virtual void virtual_serialize (boost::archive::binary_iarchive &ar, const unsigned int version)
 
- Protected Member Functions inherited from auryn::Device
void init ()
 Standard initializer to be called by the constructor. More...
 

Protected Attributes

std::ofstream outfile
 
std::string fname
 
std::string default_file_extension
 
- Protected Attributes inherited from auryn::Device
std::string device_name
 Identifying name for device. More...
 

Detailed Description

Abstract base class for all Monitor objects.

This Class constitutes the base class for all Monitors in Auryn. Per default it openes a single text file for writing (outfile) named by the name supplied in the constructor. Classes inheriting from Monitor have to implement the method execute. Unlike Checker objects execute returns void. Use Checker if you need the Monitor to be able to interrupt a run.

Constructor & Destructor Documentation

◆ Monitor() [1/2]

Monitor::Monitor ( std::string  filename,
std::string  default_extension = "dat" 
)

Standard constructor with file name.

41  : Device()
42 {
43  default_file_extension = default_extension;
44  init(filename);
45 }
void init()
Standard initializer to be called by the constructor.
Definition: Device.cpp:32
Device()
Standard constructor.
Definition: Device.cpp:41
std::string default_file_extension
Definition: Monitor.h:64
Here is the call graph for this function:

◆ Monitor() [2/2]

Monitor::Monitor ( )

Constructor which does not open a text file for output.

47  : Device()
48 {
49  default_file_extension = "dat";
50 }
Device()
Standard constructor.
Definition: Device.cpp:41
std::string default_file_extension
Definition: Monitor.h:64

◆ ~Monitor()

Monitor::~Monitor ( )
virtual

Standard destructor.

76 {
77  free();
78 }

Member Function Documentation

◆ flush()

void Monitor::flush ( )
virtual

Flush to file.

Reimplemented from auryn::Device.

Reimplemented in auryn::BinarySpikeMonitor.

86 {
87  outfile.flush();
88 }
std::ofstream outfile
Definition: Monitor.h:58

◆ generate_filename()

std::string Monitor::generate_filename ( std::string  name_hint = "")

Generates a default filename from the device ID.

64 {
65  std::stringstream oss;
66  oss << get_name() << name_hint;
67  std::string tmpstr = oss.str();
68  tmpstr.erase(std::remove(tmpstr.begin(),tmpstr.end(),' '),tmpstr.end());
69  std::transform(tmpstr.begin(), tmpstr.end(), tmpstr.begin(), ::tolower);
70  tmpstr = sys->fn(tmpstr, default_file_extension);
71  // std::cout << tmpstr << std::endl;
72  return tmpstr;
73 }
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 default_file_extension
Definition: Monitor.h:64
std::string get_name()
Get device name.
Definition: Device.cpp:67
string fn(std::string extension)
Format output file name.
Definition: System.cpp:689
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156
Here is the call graph for this function:

◆ open_output_file()

void Monitor::open_output_file ( std::string  filename)
protectedvirtual

Opens a text outputfile – for binary files redefine this function in derived class.

53 {
54  outfile.open( filename.c_str(), std::ios::out );
55  if (!outfile) {
56  std::stringstream oss;
57  oss << "Can't open output file " << filename;
58  auryn::logger->msg(oss.str(),ERROR);
59  exit(1);
60  }
61 }
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::ofstream outfile
Definition: Monitor.h:58
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
Here is the call graph for this function:

◆ virtual_serialize() [1/2]

void Monitor::virtual_serialize ( boost::archive::binary_oarchive &  ar,
const unsigned int  version 
)
protectedvirtual

Functions necesssary for serialization and loading saving to netstate files.

Reimplemented from auryn::Device.

Reimplemented in auryn::BurstRateMonitor, auryn::PatternMonitor, and auryn::PopulationRateMonitor.

92 {
93  Device::virtual_serialize(ar, version);
94 }
virtual void virtual_serialize(boost::archive::binary_oarchive &ar, const unsigned int version)
Definition: Device.cpp:50
Here is the call graph for this function:

◆ virtual_serialize() [2/2]

void Monitor::virtual_serialize ( boost::archive::binary_iarchive &  ar,
const unsigned int  version 
)
protectedvirtual

Reimplemented from auryn::Device.

Reimplemented in auryn::BurstRateMonitor, auryn::PatternMonitor, and auryn::PopulationRateMonitor.

97 {
98  Device::virtual_serialize(ar, version);
99 }
virtual void virtual_serialize(boost::archive::binary_oarchive &ar, const unsigned int version)
Definition: Device.cpp:50
Here is the call graph for this function:

Member Data Documentation

◆ active

bool auryn::Monitor::active

Standard active switch.

◆ default_file_extension

std::string auryn::Monitor::default_file_extension
protected

Default extension

◆ fname

std::string auryn::Monitor::fname
protected

Stores output filename

◆ outfile

std::ofstream auryn::Monitor::outfile
protected

Output filestream to be used in the derived classes


The documentation for this class was generated from the following files: