Xerces-C++: XMLRegisterCleanup.hpp Source File

| API Docs for SAX and DOM |
| Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages # XMLRegisterCleanup.hpp Go to the documentation of this file.
    00001 /*
    00002  * Copyright 1999-2000,2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *      http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 /*
    00018  * $Id: XMLRegisterCleanup.hpp 191054 2005-06-17 02:56:35Z jberry $
    00019  */
    00020
    00021 #if !defined(XMLREGISTERCLEANUP_HPP)
    00022 #define XMLREGISTERCLEANUP_HPP
    00023
    00024 #include <xercesc/util/Mutexes.hpp>
    00025
    00026 XERCES_CPP_NAMESPACE_BEGIN
    00027
    00028 //
    00029 //  For internal use only.
    00030 //
    00031 //  This class is used by the platform utilities class to support
    00032 //  reinitialisation of global/static data which is lazily created.
    00033 //  Since that data is widely spread out the platform utilities
    00034 //  class cannot know about them directly. So, the code that creates such
    00035 //  objects creates an registers a cleanup for the object. The platform
    00036 //  termination call will iterate the list and delete the objects.
    00037 //
    00038 //  N.B. These objects need to be statically allocated.  I couldn't think
    00039 //  of a neat way of ensuring this - can anyone else?
    00040
    00041 class  XMLRegisterCleanup
    00042 {
    00043 public :
    00044     // The cleanup function to be called on XMLPlatformUtils::Terminate()
    00045     typedef void (*XMLCleanupFn)();
    00046
    00047     void doCleanup();
    00048
    00049     // This function is called during initialisation of static data to
    00050     // register a function to be called on XMLPlatformUtils::Terminate.
    00051     // It gives an object that uses static data an opportunity to reset
    00052     // such data.
    00053     void registerCleanup(XMLCleanupFn cleanupFn);
    00054
    00055     // This function can be called either from XMLPlatformUtils::Terminate
    00056     // to state that the cleanup has been performed and should not be
    00057     // performed again, or from code that you have written that determines
    00058     // that cleanup is no longer necessary.
    00059     void unregisterCleanup();
    00060
    00061     // The default constructor sets a state that ensures that this object
    00062     // will do nothing
    00063     XMLRegisterCleanup();
    00064
    00065 private:
    00066     // -----------------------------------------------------------------------
    00067     //  Unimplemented constructors and operators
    00068     // -----------------------------------------------------------------------
    00069     XMLRegisterCleanup(const XMLRegisterCleanup&);
    00070     XMLRegisterCleanup& operator=(const XMLRegisterCleanup&);
    00071
    00072     // This is the cleanup function to be called
    00073     XMLCleanupFn m_cleanupFn;
    00074
    00075     // These are list pointers to the next/prev cleanup function to be called
    00076     XMLRegisterCleanup *m_nextCleanup, *m_prevCleanup;
    00077
    00078     // This function reinitialises the object to the default state
    00079     void resetCleanup();
    00080 };
    00081
    00082 XERCES_CPP_NAMESPACE_END
    00083
    00084 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.