User Tools

Site Tools


gsoc2016_keyboard_classes_overview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
gsoc2016_keyboard_classes_overview [2016/05/16 14:35]
ferranpujolcamins [ControllerPresetVisitor]
gsoc2016_keyboard_classes_overview [2016/05/16 14:48]
ferranpujolcamins [ControllerPresetVisitor]
Line 12: Line 12:
  
 ==== ControllerPresetVisitor ==== ==== ControllerPresetVisitor ====
-//​Controller::​setPreset(const Controller&​ preset)// needs to know the [[http://​stackoverflow.com/​questions/​7649649/​what-is-dynamic-type-of-object | dynamic type]] of preset, because a //​MidiController//​ should only handle instances of //​MidiControllerPreset//​. ​This class is inherited by //​Controller//​. This is part of the [[https://​en.wikipedia.org/​wiki/​Visitor_pattern | Visitor pattern]]. +//​Controller::​setPreset(const Controller&​ preset)// needs to know the [[http://​stackoverflow.com/​questions/​7649649/​what-is-dynamic-type-of-object | dynamic type]] of //preset//, because ​a controller should only handle its corresponding preset types (e.g. a //​MidiController//​ should only handle instances of //​MidiControllerPreset//​)
-//​Controller//​ inherits from it. This class defines a series of pure virtual methods called //visit//. //​Controller//​ subclasses must implement these //visit// methods according to their ability to handle each preset type. Like this:+
  
-https://github.com/​mixxxdj/​mixxx/​blob/​master/​src/​controllers/midi/midicontroller.cpp#L34+To achieve this, the [[https://en.wikipedia.org/wiki/Visitor_pattern | Visitor pattern]] is used.
  
-https://github.com/mixxxdj/mixxx/blob/master/src/controllers/midi/midicontroller.cpp#L44+Suppose //preset// is a //​MidiControllerPreset//​. First 
 +//​Controller::​setPreset(const Controller&​ preset)// calls the //preset.accept(ControllerVisitor* visitor)//, which calls //​visitor.visit(this)//​. But since //preset// is of type //​MidiControllerPreset//,​ the method that is called is //​Controller::​visit(MidiControllerPreset* preset)//, thus controller now knows the type of //preset//.
  
-Here's the explanation of why this is needed: 
  
-https://​github.com/​mixxxdj/​mixxx/​blob/​master/​src/​controllers/​controller.h#​L34 
- 
-More info: [[https://​en.wikipedia.org/​wiki/​Visitor_pattern | Visitor pattern]] 
 ==== ControllerEngine ==== ==== ControllerEngine ====
 It manages the loading and execution of a script. //​Controller//​ class holds a //​ControllerEngine//​ instance. It manages the loading and execution of a script. //​Controller//​ class holds a //​ControllerEngine//​ instance.
gsoc2016_keyboard_classes_overview.txt · Last modified: 2016/05/16 16:22 by ferranpujolcamins