{"action":"created","issue":{"url":"https://api.github.com/repos/LMMS/lmms/issues/2550","repository_url":"https://api.github.com/repos/LMMS/lmms","labels_url":"https://api.github.com/repos/LMMS/lmms/issues/2550/labels{/name}","comments_url":"https://api.github.com/repos/LMMS/lmms/issues/2550/comments","events_url":"https://api.github.com/repos/LMMS/lmms/issues/2550/events","html_url":"https://github.com/LMMS/lmms/pull/2550","id":132007456,"number":2550,"title":"Removes lots of static calls to Engine","user":{"login":"michaelgregorius","id":9293269,"avatar_url":"https://avatars.githubusercontent.com/u/9293269?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelgregorius","html_url":"https://github.com/michaelgregorius","followers_url":"https://api.github.com/users/michaelgregorius/followers","following_url":"https://api.github.com/users/michaelgregorius/following{/other_user}","gists_url":"https://api.github.com/users/michaelgregorius/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelgregorius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelgregorius/subscriptions","organizations_url":"https://api.github.com/users/michaelgregorius/orgs","repos_url":"https://api.github.com/users/michaelgregorius/repos","events_url":"https://api.github.com/users/michaelgregorius/events{/privacy}","received_events_url":"https://api.github.com/users/michaelgregorius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-02-07T20:27:34Z","updated_at":"2016-07-01T04:06:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/LMMS/lmms/pulls/2550","html_url":"https://github.com/LMMS/lmms/pull/2550","diff_url":"https://github.com/LMMS/lmms/pull/2550.diff","patch_url":"https://github.com/LMMS/lmms/pull/2550.patch"},"body":"There are many places in the code where static methods of the class Engine are called. The existance of a static instance of Engine makes it hard to control which components (e.g. Core, GUI, etc.) have access to which\r\ninformation. This changeset is a first step towards getting rid of these static calls.\r\n\r\nThe most important step is the introduction of an interface / a class called EngineClient. Classes that inherit from EngineClient can use simple member getters and setters to retrieve the Engine instance and as well as\r\nassociated other instances like Mixer, FxMixer, Song, etc. The constructor of EngineClient takes a pointer to the Engine as the sole parameter. Therefore the constructors of all classes that inherit from EngineClient had\r\nto be adjusted. The following classes inherit from EngineClient:\r\n* Plugin\r\n* The oscillators of TripleOscillator and Organic\r\n* VstPlugin\r\n* AutomationEditor\r\n* PianoRoll\r\n\r\nMaking the class Plugin an EngineClient enables all plugins in the plugin folder to use the member methods instead of the static calls. To be able to provide the Engine to the plugins constructors it was necessary to\r\nadjust the typedef for InstantiationHook to also include a pointer to an Engine in the parameters. The plugin factory function \"lmms_plugin_main\" was changed for all plugins and their constructors have been adjusted\r\naccordingly. The plugins folder is now free of static calls to Engine except for LadspaSubPluginFeatures.\r\n\r\nAdditionally the convenience methods getProcessingSampleRate and getFramesPerPeriod were added to the class Plugin.\r\n\r\nIn other cases code was adjusted to take the needed parameters instead of fetching them from the static Engine instance."},"comment":{"url":"https://api.github.com/repos/LMMS/lmms/issues/comments/229849330","html_url":"https://github.com/LMMS/lmms/pull/2550#issuecomment-229849330","issue_url":"https://api.github.com/repos/LMMS/lmms/issues/2550","id":229849330,"user":{"login":"jasp00","id":6378554,"avatar_url":"https://avatars.githubusercontent.com/u/6378554?v=3","gravatar_id":"","url":"https://api.github.com/users/jasp00","html_url":"https://github.com/jasp00","followers_url":"https://api.github.com/users/jasp00/followers","following_url":"https://api.github.com/users/jasp00/following{/other_user}","gists_url":"https://api.github.com/users/jasp00/gists{/gist_id}","starred_url":"https://api.github.com/users/jasp00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasp00/subscriptions","organizations_url":"https://api.github.com/users/jasp00/orgs","repos_url":"https://api.github.com/users/jasp00/repos","events_url":"https://api.github.com/users/jasp00/events{/privacy}","received_events_url":"https://api.github.com/users/jasp00/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T04:06:28Z","updated_at":"2016-07-01T04:06:28Z","body":"Back in 2007 (16a61bf8fef83849518a1f9b0fac918092596143), some classes inherited from `engineObject` that needed an `engine` parameter. Since there was only one engine, we noticed that static methods were more efficient. `eng()->` was translated to `engine::`. APIs became simpler, calls went faster, less memory was used.\r\n\r\nI do not see the benefit in this proposal. Static calls with `Engine::` and calls to a public `getEngine()` are the same. Perhaps the convenience methods such as `getSong()` are easier to write than `Engine::getSong()` or `LmmsCore::getSong()`. In any case, if there is still only one engine, these methods should be implemented with static instances to keep the advantages in simplicity, speed and memory usage."}}
{"actor":{"display_login":"jasp00"}}