Hello everybody..

I'm here again looking for some advices, so thank you before everything.

I have some collections in my main application class, but I need to retrieve them from other different classes and I would like to know a good way to achieve that. It looks like this:

Qt Code:
  1. class App : QApplication {
  2. // This class handles the collections and is responsible of setting up them
  3. private:
  4. DualCollection<Unit> units; //Internally implemented as two QHashes with QString as key type. Don't think it really matters.
  5. DualCollection<GameItem> items;
  6. // So on.
  7. };
  8.  
  9. class RosterUnit {
  10. public:
  11. void RosterUnit(); // This method need to get a read-only Unit and parse some information. It also needs access to some items
  12. };
  13.  
  14. class ObjectAction {
  15. public:
  16. void doAction() = 0; // Some subclasses will eventually need access to some information like Units or Items
  17. };
To copy to clipboard, switch view to plain text mode 

In fact there are probably other two classes that need to retrieve some information.. I was thinking to use the Singleton pattern with the application class and provide functions like getItem(const QString& key), getUnit(...) and so on, but I'm not sure if it's a good choice. I have read some disadvantages that apply to global variables and singletons like they are hard to debug because they can be modified in the whole application, but it does not apply here because I will provide only a public interface for reading.

What do you think?

Thank you very much!