Note that there are some explanatory texts on larger screens.

plurals
  1. POOOP: Proper way to check other instances of objects' variables
    text
    copied!<p>I have a collection of related classes, call them</p> <pre><code>class Manager { private: std::vector&lt;Setting&gt; m_settings; } class Setting { private: std::vector&lt;Action&gt; m_actions; } class Action { private: Keybind m_keybind; } class Keybind { public: UpdateKeybind; private: TYPE keybind; } </code></pre> <p>As you can see from the pseudo-C++ code, Settings have actions, and actions have exactly one key binding. Now, as a user of my application you want to update the Keybind potentially, yes?</p> <p>I currently have buttons in a keybind-type dialog associated with each action, so the action can handle updating it's own keybind.</p> <p><strong>My Problem</strong>: </p> <p>How do I ensure that the Keybinding isn't bound to another object?</p> <p><strong>Possible solutions</strong>: </p> <ol> <li>Move UpdateKeybind itself to the Manager class, then have Manager query all the settings.</li> <li>Have a parent pointer in Action/Setting/Keybind so the Action can query the manager for updated keybind. </li> <li>Have the Action query other Actions (not great conceptually as far as I can tell).</li> </ol> <p><strong>What I need from you</strong>:</p> <ol> <li><p>What is the most rigorous approach, in terms of maintainability, speed, ease of understanding, and OOP appropriateness, to implementing checking if a Keybind is already found, whether out of my suggested solutions or something else entirely. I have already tried number 1 -- it works, but I feel like it could be better, ya dig? I was unable to find similar questions on StackOverflow, but if you do I'd love to see them!</p></li> <li><p>Any other pro tips, things to improve are helpful.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload