Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

ArenaBlock.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-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 #if !defined(ARENABLOCK_INCLUDE_GUARD_1357924680)
18 #define ARENABLOCK_INCLUDE_GUARD_1357924680
19 
20 
21 
23 
24 
25 
26 
27 XALAN_CPP_NAMESPACE_BEGIN
28 
29 
30 template<class ObjectType,
31 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
32  class SizeType>
33 #else
34  class SizeType = size_t>
35 #endif
36 class ArenaBlock : public ArenaBlockBase<ObjectType, SizeType>
37 {
38 public:
39 
41 
43 
45 
46  /*
47  * Construct an ArenaBlock of the specified size
48  * of objects.
49  *
50  * @param theManager The memory manager instance for the block.
51  * @param theBlockSize The size of the block (the number of objects it can contain).
52  */
54  MemoryManagerType& theManager,
55  size_type theBlockSize) :
56  BaseClassType(theManager, theBlockSize)
57  {
58  }
59 
61  {
62  assert( this->m_objectCount <= this->m_blockSize );
63 
64  for ( size_type i = 0; i < this->m_objectCount ; ++i )
65  {
66  XalanDestroy(this->m_objectBlock[i]);
67  }
68  }
69 
70  static ThisType*
72  MemoryManagerType& theManager,
73  size_type theBlockSize)
74  {
75  ThisType* theInstance;
76 
77  return XalanConstruct(
78  theManager,
79  theInstance,
80  theManager,
81  theBlockSize);
82  }
83 
84  /*
85  * Allocate a block. Once the object is constructed, you must call
86  * commitAllocation().
87  *
88  * @return a pointer to the new block.
89  */
90  ObjectType*
92  {
93  // Any space left?
94  if (this->m_objectCount == this->m_blockSize)
95  {
96  return 0;
97  }
98  else
99  {
100  assert(this->m_objectBlock != 0);
101 
102  return this->m_objectBlock + this->m_objectCount;
103  }
104  }
105 
106  /*
107  * Commit the previous allocation.
108  *
109  * @param theBlock the address that was returned by allocateBlock()
110  */
111  void
112 #if defined (NDEBUG)
113  commitAllocation(ObjectType* /* theBlock */)
114 #else
115  commitAllocation(ObjectType* theBlock)
116 #endif
117  {
118  assert(theBlock == this->m_objectBlock + this->m_objectCount);
119  assert(this->m_objectCount < this->m_blockSize);
120 
121  ++this->m_objectCount;
122  }
123 
124  /*
125  * Determine if this block owns the specified object. Note
126  * that even if the object address is within our block, this
127  * call will return false if no object currently occupies the
128  * block. See also ownsBlock().
129  *
130  * @param theObject the address of the object.
131  * @return true if we own the object, false if not.
132  */
133  bool
134  ownsObject(const ObjectType* theObject) const
135  {
136  return this->isInBorders(theObject, this->m_objectCount);
137  }
138 
139 private:
140 
141  // Not implemented...
143 
145  operator=(const ArenaBlock<ObjectType, SizeType>&);
146 
147  bool
148  operator==(const ArenaBlock<ObjectType, SizeType>&) const;
149 };
150 
151 
152 
153 XALAN_CPP_NAMESPACE_END
154 
155 
156 
157 #endif // !defined(ARENABLOCK_INCLUDE_GUARD_1357924680)

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo