1 | /*
|
---|
2 | * Copyright 1999-2000,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Id: XMLRegisterCleanup.hpp,v 1.5 2004/09/08 13:56:24 peiyongz Exp $
|
---|
19 | * $Log: XMLRegisterCleanup.hpp,v $
|
---|
20 | * Revision 1.5 2004/09/08 13:56:24 peiyongz
|
---|
21 | * Apache License Version 2.0
|
---|
22 | *
|
---|
23 | * Revision 1.4 2004/02/24 22:57:28 peiyongz
|
---|
24 | * XercesDeprecatedDOMLib
|
---|
25 | *
|
---|
26 | * Revision 1.3 2004/01/29 11:48:47 cargilld
|
---|
27 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
28 | *
|
---|
29 | * Revision 1.2 2002/11/04 15:22:05 tng
|
---|
30 | * C++ Namespace Support.
|
---|
31 | *
|
---|
32 | * Revision 1.1.1.1 2002/02/01 22:22:15 peiyongz
|
---|
33 | * sane_include
|
---|
34 | *
|
---|
35 | * Revision 1.4 2001/10/25 21:55:29 peiyongz
|
---|
36 | * copy ctor explicity declared private to prevent supprise.
|
---|
37 | *
|
---|
38 | * Revision 1.3 2001/10/24 18:13:06 peiyongz
|
---|
39 | * CVS tag added
|
---|
40 | *
|
---|
41 | *
|
---|
42 | */
|
---|
43 |
|
---|
44 | #if !defined(XMLREGISTERCLEANUP_HPP)
|
---|
45 | #define XMLREGISTERCLEANUP_HPP
|
---|
46 |
|
---|
47 | #include <xercesc/util/Mutexes.hpp>
|
---|
48 |
|
---|
49 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
50 |
|
---|
51 | //
|
---|
52 | // For internal use only.
|
---|
53 | //
|
---|
54 | // This class is used by the platform utilities class to support
|
---|
55 | // reinitialisation of global/static data which is lazily created.
|
---|
56 | // Since that data is widely spread out the platform utilities
|
---|
57 | // class cannot know about them directly. So, the code that creates such
|
---|
58 | // objects creates an registers a cleanup for the object. The platform
|
---|
59 | // termination call will iterate the list and delete the objects.
|
---|
60 | //
|
---|
61 | // N.B. These objects need to be statically allocated. I couldn't think
|
---|
62 | // of a neat way of ensuring this - can anyone else?
|
---|
63 |
|
---|
64 | class XMLUTIL_EXPORT XMLRegisterCleanup
|
---|
65 | {
|
---|
66 | public :
|
---|
67 | // The cleanup function to be called on XMLPlatformUtils::Terminate()
|
---|
68 | typedef void (*XMLCleanupFn)();
|
---|
69 |
|
---|
70 | void doCleanup();
|
---|
71 |
|
---|
72 | // This function is called during initialisation of static data to
|
---|
73 | // register a function to be called on XMLPlatformUtils::Terminate.
|
---|
74 | // It gives an object that uses static data an opportunity to reset
|
---|
75 | // such data.
|
---|
76 | void registerCleanup(XMLCleanupFn cleanupFn);
|
---|
77 |
|
---|
78 | // This function can be called either from XMLPlatformUtils::Terminate
|
---|
79 | // to state that the cleanup has been performed and should not be
|
---|
80 | // performed again, or from code that you have written that determines
|
---|
81 | // that cleanup is no longer necessary.
|
---|
82 | void unregisterCleanup();
|
---|
83 |
|
---|
84 | // The default constructor sets a state that ensures that this object
|
---|
85 | // will do nothing
|
---|
86 | XMLRegisterCleanup();
|
---|
87 |
|
---|
88 | private:
|
---|
89 | // -----------------------------------------------------------------------
|
---|
90 | // Unimplemented constructors and operators
|
---|
91 | // -----------------------------------------------------------------------
|
---|
92 | XMLRegisterCleanup(const XMLRegisterCleanup&);
|
---|
93 | XMLRegisterCleanup& operator=(const XMLRegisterCleanup&);
|
---|
94 |
|
---|
95 | // This is the cleanup function to be called
|
---|
96 | XMLCleanupFn m_cleanupFn;
|
---|
97 |
|
---|
98 | // These are list pointers to the next/prev cleanup function to be called
|
---|
99 | XMLRegisterCleanup *m_nextCleanup, *m_prevCleanup;
|
---|
100 |
|
---|
101 | // This function reinitialises the object to the default state
|
---|
102 | void resetCleanup();
|
---|
103 | };
|
---|
104 |
|
---|
105 | XERCES_CPP_NAMESPACE_END
|
---|
106 |
|
---|
107 | #endif
|
---|