AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
Singleton.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
26namespace 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() = 0;
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
#define AGXCORE_EXPORT
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:31
Priority
Specifies the ranges of the priority which can be assigned to a singleton at the time of creation.
Definition: Singleton.h:35
virtual ~Singleton()
Destructor.
Singleton(int priority=DEFAULT_PRIORITY)
Default constructor.
virtual void shutdown()=0
Implement this method to cleanup your Singleton class.
virtual std::string getClassName() const =0
int getPriority() const
Return the shutdown priority of the singleton instance.
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
ref_ptr< Singleton > SingletonRef
Definition: Singleton.h:77