openMSX
Main Page
Namespaces
Classes
Files
File List
File Members
serial
MidiOutLogger.cc
Go to the documentation of this file.
1
#include "
MidiOutLogger.hh
"
2
#include "
PlugException.hh
"
3
#include "
FilenameSetting.hh
"
4
#include "
FileOperations.hh
"
5
#include "
serialize.hh
"
6
#include "
memory.hh
"
7
8
namespace
openmsx {
9
10
MidiOutLogger::MidiOutLogger
(
CommandController
& commandController)
11
: logFilenameSetting(
make_unique
<
FilenameSetting
>(
12
commandController,
"midi-out-logfilename"
,
13
"filename of the file where the MIDI output is logged to"
,
14
"/dev/midi"
))
15
{
16
}
17
18
MidiOutLogger::~MidiOutLogger
()
19
{
20
}
21
22
void
MidiOutLogger::plugHelper
(
Connector
&
/*connector*/
,
23
EmuTime::param
/*time*/
)
24
{
25
FileOperations::openofstream
(file, logFilenameSetting->getValue());
26
if
(file.fail()) {
27
file.clear();
28
throw
PlugException
(
"Error opening log file"
);
29
}
30
}
31
32
void
MidiOutLogger::unplugHelper
(
EmuTime::param
/*time*/
)
33
{
34
file.close();
35
}
36
37
const
std::string&
MidiOutLogger::getName
()
const
38
{
39
static
const
std::string name(
"midi-out-logger"
);
40
return
name;
41
}
42
43
string_ref
MidiOutLogger::getDescription
()
const
44
{
45
return
"Midi output logger. Log all data that is sent to this "
46
"pluggable to a file. The filename is set with the "
47
"'midi-out-logfilename' setting."
;
48
}
49
50
void
MidiOutLogger::recvByte
(
byte
value,
EmuTime::param
/*time*/
)
51
{
52
if
(file.is_open()) {
53
file.put(value);
54
file.flush();
55
}
56
}
57
58
template
<
typename
Archive>
59
void
MidiOutLogger::serialize
(Archive&
/*ar*/
,
unsigned
/*version*/
)
60
{
61
// don't try to resume a previous logfile (see PrinterPortLogger)
62
}
63
INSTANTIATE_SERIALIZE_METHODS
(
MidiOutLogger
);
64
REGISTER_POLYMORPHIC_INITIALIZER
(
Pluggable
,
MidiOutLogger
,
"MidiOutLogger"
);
65
66
}
// namespace openmsx
Generated on Mon Jun 17 2013 22:18:16 for openMSX by
1.8.1.2