AGX Dynamics  2.37.3.2
Singleton.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 #ifndef AGX_SINGLETON_H
18 #define AGX_SINGLETON_H
19 
20 #include <agx/agxCore_export.h>
21 #include <agx/agx.h>
22 #include <agx/Referenced.h>
24 
25 
26 namespace agx
27 {
28 
31  {
32  public:
33 
35  enum Priority {
36  HIGHEST_PRIORITY = 2147483647,
37  LOWEST_PRIORITY = 10000,
38  DEFAULT_PRIORITY = 1073741824
39  };
40 
46  Singleton( int priority = DEFAULT_PRIORITY );
47 
49  virtual void shutdown() {}
50 
52  int getPriority() const;
53 
54  friend class SingletonManager;
55 
56  virtual std::string getClassName() const = 0;
57 
58 #ifdef SWIG
59 # define SINGLETON_CLASSNAME_METHOD()
60 #else
61 # define SINGLETON_CLASSNAME_METHOD() \
62  std::string getClassName() const override { agxStream::ClassInformation ci(AGX_FUNCTION); return ci.getClassType(); }
63 #endif
64 
65  protected:
66 
68  virtual ~Singleton();
69 
70  void _shutdown();
71 
72  private:
73  int m_priority;
74  bool m_shutdownCalled;
75  };
76 
78 
79 }
80 
81 #endif
ref_ptr< Singleton > SingletonRef
Definition: Singleton.h:77
Priority
Specifies the ranges of the priority which can be assigned to a singleton at the time of creation...
Definition: Singleton.h:35
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
virtual void shutdown()
Implement this method to cleanup your Singleton class.
Definition: Singleton.h:49
#define AGXCORE_EXPORT
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:30