title: Input needed for my program structure/design
body: <p>I've tried to describe the application I'm building in a much detail as needed, so I apologise in advance for the essay!</p>
  
  <p>I'm in the process of designing and building a fairly large music application, using the C++ Juce framework, that in a nutshell takes in OSC messages and turns them into audio and MIDI data. The application has three 'modes', each defining what kind of sound will be produced by the OSC messages. The user can apply a mode and a further bunch of mode settings to define the sound that each OSC message 'triggers'. </p>
  
  <p>Below is a basic block diagram overview of the programs' class relationship and hierarchy, or at least how I theoretically imagine it to be. To clarify the Juce terminology, a 'Component' class is basically a GUI object/class that displays things on screen and allows user interaction.</p>
  
  <p><a href="http://liamlacey.web44.net/images/Software_block_diagram.jpg" rel="nofollow noreferrer">Basic block diagram http://liamlacey.web44.net/images/Software_block_diagram.jpg</a></p>
  
  <p>I'm an experienced C programmer, however I'm fairly new to C++ and OOP design. I'm understanding most if it fine but the major problem I'm having is in terms of  structuring all the classes to have the correct relationships and hierarchy so that they can all communicate properly in order for the application to do what it needs to do.</p>
  
  <p>Here is a brief description of what each class does:</p>
  
  <ul>
  <li><p><code>OscInput</code> - this base class uses the oscpack library to listen for OSC messages. Only 1 class can inherit from this base class as the application will crash if there are multiple listeners on the same UDP port.</p></li>
  <li><p><code>Main</code> - application start-up. Inherits from OscInput so that every time an OSC message is received a callback function is called within this class</p></li>
  <li><p><code>MainWindow</code> - the apps main document window - default to Juce apps.</p></li>
  <li><p><code>MainComponent</code> - the main/background component/GUI of the app - default to Juce apps.</p></li>
  <li><p><code>Mode1Component</code> / <code>Mode2Component</code> / <code>Mode3Component</code> - a single instance of each of these component classes is called and displayed from MainComponent which are used by the user to change the settings of what each OSC message does.</p></li>
  <li><p><code>SubComponent1</code> - a single instance of this component class is called and displayed from MainComponent.</p></li>
  <li><p><code>SubComponent2</code> - 48 instances of this component class are called and displayed from SubComponent1. Each instance is used to display the value of a different OSC message being received.</p></li>
  <li><p><code>Mode1/Mode2/Mode3</code>  - a single instance of each of these classes is called from Main. Each class is used to actually convert the OSC messages into audio or MIDI data, based on values/variables within the Settings class.</p></li>
  <li><p><code>Settings</code> - a single instance of this class that is used to store settings that control what sound is produced from each different OSC message.</p></li>
  </ul>
  
  <p>I'm fairly happy I have all the component/GUI classes laid out and connected in the right way. I have also got incoming OSC messages working fine. But it is the relationship of the Settings class instance that I'm not quite sure how to implement. Here are the relationships I need help with:</p>
  
  <ul>
  <li>The single instances of Mode1, Mode2, and Mode3 all need to retrieve values from the Setting class instance</li>
  <li>The single instances of MainComponent, Mode1Component, Mode2Component, Mode3Component all need to send values to the Settings class instance, as well as retrieve values from the instance.</li>
  <li>All 48 instances of SubComponent2 need to retrieve OSC messages</li>
  </ul>
  
  <p>Therefore I have the following questions:</p>
  
  <ul>
  <li><p>Where should the <code>Settings</code> class instance be called from so that all the relevant class instances mentioned above can communicate with it? I only want a single instance of this class that needs to be accessed by many other classes, so should it be a global, Singleton, or static class? I've been studying the Singleton design pattern which seems to be what I'm looking for, but I get the impression I should avoid it if I can and consider alternative methods.</p></li>
  <li><p>Should it be the <code>Main</code> class that listens for OSC messages? How can I get SubComponent2 to receive OSC messages as well as the Mode1, Mode2, and Mode3 class instances?</p></li>
  <li><p>Should the functionality classes (Mode1, Mode2, and Mode3) be called from Main? I'm trying to keep all functionality and GUI code separate as I have someone else dealing with GUI programming while I'm dealing with the functionality programming of the application.</p></li>
  <li><p>Can anyone spot any major flaws in the design pattern of my program?</p></li>
  </ul>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Thanks</p>