Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XalanMemMngArrayAllocate.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-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 #if !defined(XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680)
00017 #define XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/Include/XalanMemMgrAutoPtr.hpp>
00027 
00028 
00029 
00030 XALAN_CPP_NAMESPACE_BEGIN
00031 
00032 
00033 template <class Type>
00034 class XalanMemMngArrayAllocate
00035 {
00036     typedef typename XalanMemMgrAutoPtrArray<Type>::size_type size_type;
00037 
00038 public:
00039     static Type*
00040     allocate(   size_t              size, 
00041                 MemoryManagerType&  memoryManager)
00042     {       
00043         XalanMemMgrAutoPtrArray<Type> theGuard (    memoryManager,
00044                                                     (Type*)memoryManager.allocate( sizeof(Type)*size),
00045                                                     size_type(size) );
00046 
00047         size_t allocated = 0;
00048 
00049         for ( Type* runPtr = theGuard.get() ; allocated < size ; ++ allocated )
00050         {
00051             new ( runPtr + allocated ) Type();
00052 
00053             ++theGuard;
00054         }
00055 
00056         Type*  theResult = theGuard.get();
00057 
00058         theGuard.release();
00059 
00060         return theResult;
00061     }
00062     
00063     static Type*
00064     allocateMemMgr( size_t              size, 
00065                 MemoryManagerType&  memoryManager)
00066     {       
00067         XalanMemMgrAutoPtrArray<Type> theGuard (    memoryManager,
00068                                                     (Type*)memoryManager.allocate( sizeof(Type)*size),
00069                                                     size_type(size) );
00070 
00071         size_t allocated = 0;
00072 
00073         for ( Type* runPtr = theGuard.get() ; allocated < size ; ++ allocated )
00074         {
00075             new ( runPtr + allocated ) Type(memoryManager);
00076 
00077             ++theGuard;
00078         }
00079 
00080         Type*  theResult = theGuard.get();
00081 
00082         theGuard.release();
00083 
00084         return theResult;
00085     }
00086     
00087     static void
00088     deallocate (    Type*               ptr,
00089                     size_t              size,
00090                     MemoryManagerType&  memoryManager)
00091     {
00092         assert ( ptr != 0 );
00093 
00094         Type* runPtr = ptr;
00095 
00096         for ( size_t i = 0; i < size ; ++i )
00097         {
00098             runPtr->~Type();
00099         }
00100 
00101         memoryManager.deallocate ( ptr);
00102     }
00103  
00104 };
00105 
00106 
00107 XALAN_CPP_NAMESPACE_END
00108 
00109 
00110 
00111 #endif  // if !defined(XALANMEMMGRARRAYALLOCATE_HEADER_GUARD_1357924680)
00112 
00113 

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