source: trunk/VUT/GtpVisibilityPreprocessor/support/xerces/include/xercesc/util/Janitor.hpp @ 358

Revision 358, 5.4 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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 * $Log: Janitor.hpp,v $
19 * Revision 1.6  2004/09/08 13:56:22  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.5  2004/01/29 11:48:46  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.4  2003/11/06 19:28:11  knoaman
26 * PSVI support for annotations.
27 *
28 * Revision 1.3  2003/05/15 19:04:35  knoaman
29 * Partial implementation of the configurable memory manager.
30 *
31 * Revision 1.2  2002/11/04 15:22:04  tng
32 * C++ Namespace Support.
33 *
34 * Revision 1.1.1.1  2002/02/01 22:22:10  peiyongz
35 * sane_include
36 *
37 * Revision 1.7  2000/10/13 22:45:12  andyh
38 * Complete removal of ArrayJanitory::operator->().  Was just commented out earlier.
39 *
40 * Revision 1.6  2000/10/10 23:52:11  andyh
41 * From Janitor, remove the addition that is having compile problems in MSVC.
42 *
43 * Revision 1.5  2000/10/09 18:32:31  jberry
44 * Add some auto_ptr functionality to allow modification of monitored
45 * pointer value. This eases use of Janitor in some situations.
46 *
47 * Revision 1.4  2000/03/02 19:54:40  roddey
48 * This checkin includes many changes done while waiting for the
49 * 1.1.0 code to be finished. I can't list them all here, but a list is
50 * available elsewhere.
51 *
52 * Revision 1.3  2000/02/24 20:05:24  abagchi
53 * Swat for removing Log from API docs
54 *
55 * Revision 1.2  2000/02/06 07:48:02  rahulj
56 * Year 2K copyright swat.
57 *
58 * Revision 1.1.1.1  1999/11/09 01:04:27  twl
59 * Initial checkin
60 *
61 * Revision 1.2  1999/11/08 20:45:08  rahul
62 * Swat for adding in Product name and CVS comment log variable.
63 *
64 */
65
66
67#if !defined(JANITOR_HPP)
68#define JANITOR_HPP
69
70#include <xercesc/util/XMemory.hpp>
71#include <xercesc/framework/MemoryManager.hpp>
72
73XERCES_CPP_NAMESPACE_BEGIN
74
75template <class T> class Janitor : public XMemory
76{
77public  :
78    // -----------------------------------------------------------------------
79    //  Constructors and Destructor
80    // -----------------------------------------------------------------------
81    Janitor(T* const toDelete);
82    ~Janitor();
83
84    // -----------------------------------------------------------------------
85    //  Public, non-virtual methods
86    // -----------------------------------------------------------------------
87    void orphan();
88
89    //  small amount of auto_ptr compatibility
90    T& operator*() const;
91    T* operator->() const;
92    T* get() const;
93    T* release();
94    void reset(T* p = 0);
95    bool isDataNull();
96
97private :
98    // -----------------------------------------------------------------------
99    //  Unimplemented constructors and operators
100    // -----------------------------------------------------------------------
101    Janitor();
102    Janitor(const Janitor<T>&);
103    Janitor<T>& operator=(const Janitor<T>&);
104
105    // -----------------------------------------------------------------------
106    //  Private data members
107    //
108    //  fData
109    //      This is the pointer to the object or structure that must be
110    //      destroyed when this object is destroyed.
111    // -----------------------------------------------------------------------
112    T*  fData;
113};
114
115
116
117template <class T> class ArrayJanitor : public XMemory
118{
119public  :
120    // -----------------------------------------------------------------------
121    //  Constructors and Destructor
122    // -----------------------------------------------------------------------
123    ArrayJanitor(T* const toDelete);
124    ArrayJanitor(T* const toDelete, MemoryManager* const manager);
125    ~ArrayJanitor();
126
127
128    // -----------------------------------------------------------------------
129    //  Public, non-virtual methods
130    // -----------------------------------------------------------------------
131    void orphan();
132
133        //      small amount of auto_ptr compatibility
134        T&      operator[](int index) const;
135        T*      get() const;
136        T*      release();
137        void reset(T* p = 0);
138        void reset(T* p, MemoryManager* const manager);
139
140private :
141    // -----------------------------------------------------------------------
142    //  Unimplemented constructors and operators
143    // -----------------------------------------------------------------------
144        ArrayJanitor();
145    ArrayJanitor(const ArrayJanitor<T>& copy);
146    ArrayJanitor& operator=(const ArrayJanitor<T>& copy);   
147
148    // -----------------------------------------------------------------------
149    //  Private data members
150    //
151    //  fData
152    //      This is the pointer to the object or structure that must be
153    //      destroyed when this object is destroyed.
154    // -----------------------------------------------------------------------
155    T*  fData;
156    MemoryManager* fMemoryManager;
157};
158
159XERCES_CPP_NAMESPACE_END
160
161#if !defined(XERCES_TMPLSINC)
162#include <xercesc/util/Janitor.c>
163#endif
164
165#endif
Note: See TracBrowser for help on using the repository browser.