AGX Dynamics  2.37.2.0
SingletonManager.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 #pragma once
18 
19 #ifdef _MSC_VER
20 # pragma warning(push)
21 # pragma warning(disable: 4251) // warning C4251: class X needs to have dll-interface to be used by clients of class Y
22 #endif
23 
24 
25 #include <agx/agxCore_export.h>
26 #include <agx/agx.h>
27 #include <agx/Referenced.h>
29 #include <agx/HashSet.h>
30 #include <agx/DynamicLibrary.h>
31 
33 
34 namespace agx
35 {
36 
37  class Singleton;
38 
39 
41  class AGXCORE_EXPORT SingletonManager : public agx::Referenced
42  {
43  public:
44 
46  SingletonManager();
47 
49  static SingletonManager* instance();
50 
52  void registerSingleton( Singleton* );
53 
54  bool unregisterSingleton( Singleton* singleton );
55 
57  void shutdown();
58 
60  void print( ) const;
61 
62  void registerDynamicLibrary(agx::DynamicLibrary*);
63 
64  void unregisterDynamicLibrary(agx::DynamicLibrary*);
65 
66  protected:
67  virtual ~SingletonManager();
68 
69  private:
70  typedef agx::Vector<Singleton*> SingletonQueue;
71  SingletonQueue m_singletons;
72  SingletonQueue m_addedSingletons;
73  bool m_dirty;
74  bool m_shutdownCalled;
75 
77 
78  Mutex m_mutex;
79  };
80 
81  AGX_DECLARE_POINTER_TYPES(SingletonManager);
82 }
84 
85 #ifdef _MSC_VER
86 # pragma warning(pop)
87 #endif
void AGXPHYSICS_EXPORT shutdown()
Shutdown of the AGX Dynamics API will be done when the number of shutdown matches the number of calls...
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: HashSet.h:669
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::mutex Mutex
Definition: Referenced.h:99
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define AGXCORE_EXPORT
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97