source: icXML/icXML-devel/src/xercesc/dom/DOMMemoryManager.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 5.4 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#if !defined(XERCESC_INCLUDE_GUARD_DOMMEMORYMANAGER_HPP)
19#define XERCESC_INCLUDE_GUARD_DOMMEMORYMANAGER_HPP
20
21//------------------------------------------------------------------------------------
22//  Includes
23//------------------------------------------------------------------------------------
24
25XERCES_CPP_NAMESPACE_BEGIN
26
27/**
28  * The <code>DOMMemoryManager</code> interface exposes the memory allocation-related
29  * functionalities of a <code>DOMDocument</code>
30  */
31
32class CDOM_EXPORT DOMMemoryManager
33{
34protected:
35    // -----------------------------------------------------------------------
36    //  Hidden constructors
37    // -----------------------------------------------------------------------
38    /** @name Hidden constructors */
39    //@{
40    DOMMemoryManager() {};
41    //@}
42
43private:
44    // -----------------------------------------------------------------------
45    // Unimplemented constructors and operators
46    // -----------------------------------------------------------------------
47    /** @name Unimplemented constructors and operators */
48    //@{
49    DOMMemoryManager(const DOMMemoryManager &);
50    DOMMemoryManager & operator = (const DOMMemoryManager &);
51    //@}
52
53public:
54
55    // -----------------------------------------------------------------------
56    //  All constructors are hidden, just the destructor is available
57    // -----------------------------------------------------------------------
58    /** @name Destructor */
59    //@{
60    /**
61     * Destructor
62     *
63     */
64    virtual ~DOMMemoryManager() {};
65    //@}
66
67    // -----------------------------------------------------------------------
68    //  data types
69    // -----------------------------------------------------------------------
70    enum NodeObjectType {
71        ATTR_OBJECT                   = 0,
72        ATTR_NS_OBJECT                = 1,
73        CDATA_SECTION_OBJECT          = 2,
74        COMMENT_OBJECT                = 3,
75        DOCUMENT_FRAGMENT_OBJECT      = 4,
76        DOCUMENT_TYPE_OBJECT          = 5,
77        ELEMENT_OBJECT                = 6,
78        ELEMENT_NS_OBJECT             = 7,
79        ENTITY_OBJECT                 = 8,
80        ENTITY_REFERENCE_OBJECT       = 9,
81        NOTATION_OBJECT               = 10,
82        PROCESSING_INSTRUCTION_OBJECT = 11,
83        TEXT_OBJECT                   = 12
84    };
85
86    //@{
87    // -----------------------------------------------------------------------
88    //  Getter methods
89    // -----------------------------------------------------------------------
90    /**
91     * Returns the size of the chunks of memory allocated by the memory manager
92     *
93     * @return the dimension of the chunks of memory allocated by the memory manager
94     */
95    virtual XMLSize_t getMemoryAllocationBlockSize() const = 0;
96
97    //@}
98
99    //@{
100    // -----------------------------------------------------------------------
101    //  Setter methods
102    // -----------------------------------------------------------------------
103    /**
104     * Set the size of the chunks of memory allocated by the memory manager
105     *
106     * @param size the new size of the chunks; it must be greater than 4KB
107     */
108    virtual void setMemoryAllocationBlockSize(XMLSize_t size) = 0;
109    //@}
110
111    //@{
112    // -----------------------------------------------------------------------
113    //  Operations
114    // -----------------------------------------------------------------------
115    /**
116     * Allocate a memory block of the requested size from the managed pool
117     *
118     * @param amount the size of the new memory block
119     *
120     * @return the pointer to the newly allocated block
121     */
122    virtual void* allocate(XMLSize_t amount) = 0;
123
124    /**
125     * Allocate a memory block of the requested size from the managed pool of DOM objects
126     *
127     * @param amount the size of the new memory block
128     * @param type   the type of the DOM object that will be stored in the block
129     *
130     * @return the pointer to the newly allocated block
131     */
132    virtual void* allocate(XMLSize_t amount, DOMMemoryManager::NodeObjectType type) = 0;
133
134    /**
135     * Release a DOM object and place its memory back in the pool
136     *
137     * @param object the pointer to the DOM node
138     * @param type   the type of the DOM object
139     */
140    virtual void release(DOMNode* object, DOMMemoryManager::NodeObjectType type) = 0;
141
142    /**
143     * Allocate a memory block from the mnaged pool and copy the provided string
144     *
145     * @param src the string to be copied
146     *
147     * @return the pointer to the newly allocated block
148     */   
149    virtual XMLCh* cloneString(const XMLCh *src) = 0;
150    //@}
151
152};
153
154XERCES_CPP_NAMESPACE_END
155
156#endif
157
158/**
159 * End of file DOMMemoryManager.hpp
160 */
Note: See TracBrowser for help on using the repository browser.