Add remaining files
[juce-lv2.git] / juce / source / src / utilities / juce_DeletedAtShutdown.h
blob1773c908a94e09634fae0c1f449a5637fb90fb3d
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__
27 #define __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__
29 #include "../containers/juce_Array.h"
32 //==============================================================================
33 /**
34 Classes derived from this will be automatically deleted when the application exits.
36 After JUCEApplication::shutdown() has been called, any objects derived from
37 DeletedAtShutdown which are still in existence will be deleted in the reverse
38 order to that in which they were created.
40 So if you've got a singleton and don't want to have to explicitly delete it, just
41 inherit from this and it'll be taken care of.
43 class JUCE_API DeletedAtShutdown
45 protected:
46 /** Creates a DeletedAtShutdown object. */
47 DeletedAtShutdown();
49 /** Destructor.
51 It's ok to delete these objects explicitly - it's only the ones left
52 dangling at the end that will be deleted automatically.
54 virtual ~DeletedAtShutdown();
57 public:
58 /** Deletes all extant objects.
60 This shouldn't be used by applications, as it's called automatically
61 in the shutdown code of the JUCEApplication class.
63 static void deleteAll();
65 private:
66 static Array <DeletedAtShutdown*>& getObjects();
68 JUCE_DECLARE_NON_COPYABLE (DeletedAtShutdown);
71 #endif // __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__