openMSX
MidiOutLogger.cc
Go to the documentation of this file.
1 #include "MidiOutLogger.hh"
2 #include "PlugException.hh"
3 #include "FileOperations.hh"
4 #include "serialize.hh"
5 
6 namespace openmsx {
7 
9  : logFilenameSetting(
10  commandController, "midi-out-logfilename",
11  "filename of the file where the MIDI output is logged to",
12  "/dev/midi")
13 {
14 }
15 
17  EmuTime::param /*time*/)
18 {
19  FileOperations::openofstream(file, logFilenameSetting.getString().str());
20  if (file.fail()) {
21  file.clear();
22  throw PlugException("Error opening log file");
23  }
24 }
25 
27 {
28  file.close();
29 }
30 
31 const std::string& MidiOutLogger::getName() const
32 {
33  static const std::string name("midi-out-logger");
34  return name;
35 }
36 
38 {
39  return "Midi output logger. Log all data that is sent to this "
40  "pluggable to a file. The filename is set with the "
41  "'midi-out-logfilename' setting.";
42 }
43 
45 {
46  if (file.is_open()) {
47  file.put(value);
48  file.flush();
49  }
50 }
51 
52 template<typename Archive>
53 void MidiOutLogger::serialize(Archive& /*ar*/, unsigned /*version*/)
54 {
55  // don't try to resume a previous logfile (see PrinterPortLogger)
56 }
59 
60 } // namespace openmsx
void recvByte(byte value, EmuTime::param time) override
Represents something you can plug devices into.
Definition: Connector.hh:21
REGISTER_POLYMORPHIC_INITIALIZER(Pluggable, CassettePlayer,"CassettePlayer")
void serialize(Archive &ar, unsigned version)
MidiOutLogger(CommandController &commandController)
Definition: MidiOutLogger.cc:8
std::string str() const
Definition: string_ref.cc:12
void openofstream(std::ofstream &stream, const std::string &filename)
Open an ofstream in a platform-independent manner.
string_ref getDescription() const override
Description for this pluggable.
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
void plugHelper(Connector &connector, EmuTime::param time) override
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:25
const std::string & getName() const override
Name used to identify this pluggable.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:802
void unplugHelper(EmuTime::param time) override
Thrown when a plug action fails.
string_ref getString() const