From: <m97...@us...> - 2012-01-29 19:23:49
|
Revision: 12387 http://openmsx.svn.sourceforge.net/openmsx/?rev=12387&view=rev Author: m9710797 Date: 2012-01-29 19:23:43 +0000 (Sun, 29 Jan 2012) Log Message: ----------- Make passing of ownership to PluggingController::registerPluggable() explicit Modified Paths: -------------- openmsx/trunk/src/PluggableFactory.cc openmsx/trunk/src/PluggingController.cc openmsx/trunk/src/PluggingController.hh openmsx/trunk/src/cassette/CassettePort.cc openmsx/trunk/src/input/JoyMega.cc openmsx/trunk/src/input/Joystick.cc openmsx/trunk/src/serial/MidiInWindows.cc openmsx/trunk/src/serial/MidiOutCoreMIDI.cc openmsx/trunk/src/serial/MidiOutWindows.cc Modified: openmsx/trunk/src/PluggableFactory.cc =================================================================== --- openmsx/trunk/src/PluggableFactory.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/PluggableFactory.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -29,9 +29,10 @@ #include "MidiOutCoreMIDI.hh" #endif - namespace openmsx { +using std::auto_ptr; + void PluggableFactory::createAll(PluggingController& controller, MSXMotherBoard& motherBoard) { @@ -47,56 +48,64 @@ // TODO: Support hot-plugging of input devices: // - additional key joysticks can be created by the user // - real joysticks and mice can be hotplugged (USB) - controller.registerPluggable(new ArkanoidPad(msxEventDistributor, - stateChangeDistributor)); - controller.registerPluggable(new Mouse(msxEventDistributor, - stateChangeDistributor)); - controller.registerPluggable(new Trackball(msxEventDistributor, - stateChangeDistributor)); - controller.registerPluggable(new JoyTap(controller, "joytap")); - controller.registerPluggable(new NinjaTap(controller, "ninjatap")); - controller.registerPluggable(new KeyJoystick( + controller.registerPluggable(auto_ptr<Pluggable>(new ArkanoidPad( + msxEventDistributor, stateChangeDistributor))); + controller.registerPluggable(auto_ptr<Pluggable>(new Mouse( + msxEventDistributor, stateChangeDistributor))); + controller.registerPluggable(auto_ptr<Pluggable>(new Trackball( + msxEventDistributor, stateChangeDistributor))); + controller.registerPluggable(auto_ptr<Pluggable>(new JoyTap( + controller, "joytap"))); + controller.registerPluggable(auto_ptr<Pluggable>(new NinjaTap( + controller, "ninjatap"))); + controller.registerPluggable(auto_ptr<Pluggable>(new KeyJoystick( commandController, msxEventDistributor, - stateChangeDistributor, "keyjoystick1")); - controller.registerPluggable(new KeyJoystick( + stateChangeDistributor, "keyjoystick1"))); + controller.registerPluggable(auto_ptr<Pluggable>(new KeyJoystick( commandController, msxEventDistributor, - stateChangeDistributor, "keyjoystick2")); + stateChangeDistributor, "keyjoystick2"))); Joystick::registerAll(msxEventDistributor, stateChangeDistributor, controller); JoyMega::registerAll(msxEventDistributor, stateChangeDistributor, controller); // Dongles - controller.registerPluggable(new SETetrisDongle()); - controller.registerPluggable(new MagicKey()); + controller.registerPluggable(auto_ptr<Pluggable>(new SETetrisDongle())); + controller.registerPluggable(auto_ptr<Pluggable>(new MagicKey())); // Logging: - controller.registerPluggable(new PrinterPortLogger(commandController)); - controller.registerPluggable(new MidiOutLogger(commandController)); + controller.registerPluggable(auto_ptr<Pluggable>(new PrinterPortLogger( + commandController))); + controller.registerPluggable(auto_ptr<Pluggable>(new MidiOutLogger( + commandController))); // Serial communication: - controller.registerPluggable(new RS232Tester( - eventDistributor, scheduler, commandController)); + controller.registerPluggable(auto_ptr<Pluggable>(new RS232Tester( + eventDistributor, scheduler, commandController))); // Sampled audio: - controller.registerPluggable(new PrinterPortSimpl(motherBoard.getMSXMixer())); - controller.registerPluggable(new WavAudioInput(commandController)); + controller.registerPluggable(auto_ptr<Pluggable>(new PrinterPortSimpl( + motherBoard.getMSXMixer()))); + controller.registerPluggable(auto_ptr<Pluggable>(new WavAudioInput( + commandController))); // MIDI: - controller.registerPluggable(new MidiInReader( - eventDistributor, scheduler, commandController)); + controller.registerPluggable(auto_ptr<Pluggable>(new MidiInReader( + eventDistributor, scheduler, commandController))); #if defined(_WIN32) MidiInWindows::registerAll(eventDistributor, scheduler, controller); MidiOutWindows::registerAll(controller); #endif #if defined(__APPLE__) - controller.registerPluggable(new MidiOutCoreMIDIVirtual()); + controller.registerPluggable(auto_ptr<Pluggable>(new MidiOutCoreMIDIVirtual())); MidiOutCoreMIDI::registerAll(controller); #endif // Printers - controller.registerPluggable(new ImagePrinterMSX(motherBoard)); - controller.registerPluggable(new ImagePrinterEpson(motherBoard)); + controller.registerPluggable(auto_ptr<Pluggable>(new ImagePrinterMSX( + motherBoard))); + controller.registerPluggable(auto_ptr<Pluggable>(new ImagePrinterEpson( + motherBoard))); } } // namespace openmsx Modified: openmsx/trunk/src/PluggingController.cc =================================================================== --- openmsx/trunk/src/PluggingController.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/PluggingController.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -143,9 +143,9 @@ } -void PluggingController::registerPluggable(Pluggable* pluggable) +void PluggingController::registerPluggable(std::auto_ptr<Pluggable> pluggable) { - pluggables.push_back(pluggable); + pluggables.push_back(pluggable.release()); } Modified: openmsx/trunk/src/PluggingController.hh =================================================================== --- openmsx/trunk/src/PluggingController.hh 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/PluggingController.hh 2012-01-29 19:23:43 UTC (rev 12387) @@ -39,11 +39,9 @@ */ Connector* findConnector(const std::string& name) const; - /** - * Add a Pluggable to the registry. - * PluggingController has ownership of all registered Pluggables. + /** Add a Pluggable to the registry. */ - void registerPluggable(Pluggable* pluggable); + void registerPluggable(std::auto_ptr<Pluggable> pluggable); /** Return the Pluggable with given name or * NULL if there is none with this name. Modified: openmsx/trunk/src/cassette/CassettePort.cc =================================================================== --- openmsx/trunk/src/cassette/CassettePort.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/cassette/CassettePort.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -66,7 +66,7 @@ , lastOutput(false) , motorControl(false) { - getPluggingController().registerPluggable(new CassettePlayer( + getPluggingController().registerPluggable(auto_ptr<Pluggable>(new CassettePlayer( motherBoard.getCommandController(), motherBoard, motherBoard.getScheduler(), @@ -74,7 +74,7 @@ motherBoard.getReactor().getEventDistributor(), motherBoard.getMSXCliComm(), motherBoard.getReactor().getFilePool(), - motherBoard.getReactor().getGlobalSettings().getThrottleManager())); + motherBoard.getReactor().getGlobalSettings().getThrottleManager()))); } CassettePort::~CassettePort() Modified: openmsx/trunk/src/input/JoyMega.cc =================================================================== --- openmsx/trunk/src/input/JoyMega.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/input/JoyMega.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -42,8 +42,10 @@ // accelerometers do end up being symlinked as a joystick in // practice. if (SDL_JoystickNumButtons(joystick) != 0) { - controller.registerPluggable(new JoyMega( - eventDistributor, stateChangeDistributor, joystick)); + controller.registerPluggable(std::auto_ptr<Pluggable>( + new JoyMega(eventDistributor, + stateChangeDistributor, + joystick))); } } } Modified: openmsx/trunk/src/input/Joystick.cc =================================================================== --- openmsx/trunk/src/input/Joystick.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/input/Joystick.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -43,8 +43,10 @@ // accelerometers do end up being symlinked as a joystick in // practice. if (SDL_JoystickNumButtons(joystick) != 0) { - controller.registerPluggable(new Joystick( - eventDistributor, stateChangeDistributor, joystick)); + controller.registerPluggable(std::auto_ptr<Pluggable>( + new Joystick(eventDistributor, + stateChangeDistributor, + joystick))); } } } Modified: openmsx/trunk/src/serial/MidiInWindows.cc =================================================================== --- openmsx/trunk/src/serial/MidiInWindows.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/serial/MidiInWindows.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -30,8 +30,8 @@ w32_midiInInit(); unsigned devnum = w32_midiInGetVFNsNum(); for (unsigned i = 0 ; i <devnum; ++i) { - controller.registerPluggable( - new MidiInWindows(eventDistributor, scheduler, i)); + controller.registerPluggable(std::auto_ptr<Pluggable>( + new MidiInWindows(eventDistributor, scheduler, i))); } } Modified: openmsx/trunk/src/serial/MidiOutCoreMIDI.cc =================================================================== --- openmsx/trunk/src/serial/MidiOutCoreMIDI.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/serial/MidiOutCoreMIDI.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -19,7 +19,8 @@ for (ItemCount i = 0; i < numberOfEndpoints; i++) { MIDIEndpointRef endpoint = MIDIGetDestination(i); if (endpoint) { - controller.registerPluggable(new MidiOutCoreMIDI(endpoint)); + controller.registerPluggable(std::auto_ptr<Pluggable>( + new MidiOutCoreMIDI(endpoint))); } } } Modified: openmsx/trunk/src/serial/MidiOutWindows.cc =================================================================== --- openmsx/trunk/src/serial/MidiOutWindows.cc 2012-01-29 19:23:13 UTC (rev 12386) +++ openmsx/trunk/src/serial/MidiOutWindows.cc 2012-01-29 19:23:43 UTC (rev 12387) @@ -17,7 +17,8 @@ w32_midiOutInit(); unsigned devnum = w32_midiOutGetVFNsNum(); for (unsigned i = 0; i < devnum; ++i) { - controller.registerPluggable(new MidiOutWindows(i)); + controller.registerPluggable(std::auto_ptr<Pluggable>( + new MidiOutWindows(i))); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |