forked from ChristophKirst/SimKernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_io.cpp
68 lines (56 loc) · 1.23 KB
/
sim_io.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
sim_io.cpp - Sim object's message and error objects
Christoph Kirst
Max Planck Institue for Dynamics and Self-Organisation
HU Berlin, BCCN Göttingen & Berlin (2008)
****************************************************************************/
#include "sim_io.h"
#include "sim_signals.h"
#include "sim.h"
SimIO::SimIO(Sim* sim_) : sim(sim_), msg("") {};
SimIO::~SimIO()
{
//release(Warning);
};
void SimIO::release(const SimSignal& sig)
{
if (msg!= "")
{
std::ostringstream str;
str << "There was an unsent message: " << msg;
sim->signal(sig, str.str());
msg = "";
};
};
SimIO& SimIO::operator << (const SimSignal& sig)
{
std::string m = msg;
msg = "";
sim->signal(sig, m);
return (*this);
};
// endl.
SimIO& SimIO::operator << (SimIO& (*io) (SimIO&))
{
return (*io)(*this);
};
void SimIO::endline()
{
msg += "\n";
flush();
};
void SimIO::flush(const SimSignal& sig)
{
if (msg != "") sim->signal(sig, msg);
msg = "";
};
SimIO& Endl (SimIO& io)
{
io.endline();
return (io);
};
void SimIO::output_level(const SimSignal& sig)
{
sim->output_level(sig);
};