Xerces-C++: XMLRegisterCleanup.hpp Source File

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

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