AGX Dynamics  2.35.0.1
SingletonManager.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_SINGLETONMANAGER_H
18 #define AGX_SINGLETONMANAGER_H
19 
20 #include <agx/agxCore_export.h>
21 #include <agx/agx.h>
22 #include <agx/Referenced.h>
24 #include <agx/HashSet.h>
25 #include <agx/DynamicLibrary.h>
26 
28 
29 namespace agx
30 {
31 
32  class Singleton;
33 
34 
36  class AGXCORE_EXPORT SingletonManager : public agx::Referenced
37  {
38  public:
39 
41  SingletonManager();
42 
44  static SingletonManager* instance();
45 
47  void registerSingleton( Singleton* );
48 
49  bool unregisterSingleton( Singleton* singleton );
50 
52  void shutdown();
53 
55  void print( ) const;
56 
57  void registerDynamicLibrary(agx::DynamicLibrary*);
58 
59  void unregisterDynamicLibrary(agx::DynamicLibrary*);
60 
61  protected:
62  virtual ~SingletonManager();
63 
64  private:
65  typedef agx::Vector<Singleton*> SingletonQueue;
66  SingletonQueue m_singletons;
67  SingletonQueue m_addedSingletons;
68  bool m_dirty;
69  bool m_shutdownCalled;
70 
72 
73  Mutex m_mutex;
74  };
75 
76  AGX_DECLARE_POINTER_TYPES(SingletonManager);
77 }
79 
80 
81 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXCORE_EXPORT
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:666
Base class providing referencing counted objects.
Definition: Referenced.h:114
Templated vector class.
Definition: agx/Vector.h:53
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::mutex Mutex
Definition: Referenced.h:93
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.