openMSX
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 
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 
19 {
20 }
21 
23  EmuTime::param /*time*/)
24 {
25  FileOperations::openofstream(file, logFilenameSetting->getString());
26  if (file.fail()) {
27  file.clear();
28  throw PlugException("Error opening log file");
29  }
30 }
31 
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 
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 
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 }
65 
66 } // 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)
void openofstream(std::ofstream &stream, const std::string &filename)
Open an ofstream in a platform-independent manner.
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:33
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:7
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.
std::unique_ptr< T > make_unique()
Definition: memory.hh:27