Revision: 597
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=597&view=rev
Author: andy_miller
Date: 2008-06-19 23:54:10 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
nxogre update
Modified Paths:
--------------
trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.cpp
trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.h
trunk/python-ogre/ThirdParty/nxogre/NxOgre.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreAllocator.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreAllocator.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterController.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterModel.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterModel.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterMovementModel.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCloth.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCloth.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreConfig.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreContactCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreContainer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreContainer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreDebugRenderer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreDualIdentifier.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreDualIdentifier.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreError.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreExtendedTypes.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreFluid.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreFluid.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreForceField.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreGroup.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreHelpers.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreHelpers.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreIntersection.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreIntersection.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreJoint.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreJoint.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointSet1.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointSet2.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreLog.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreLog.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMachine.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMachine.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMaterial.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMaterial.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMeshRenderable.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMeshRenderable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreNodeRenderable.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreNodeRenderable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreNxActorController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreNxActorController.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreOgreMeshRenderable.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreOgreMeshRenderable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreOgreNodeRenderable.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreOgreNodeRenderable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreOgreSceneRenderer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreOgreSceneRenderer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreParams.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreParams.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePerformer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgrePerformer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePhysXDriver.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgrePhysXDriver.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePlatform.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePose.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePrerequisites.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreRaycaster.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreRaycaster.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreRemoteDebuggerConnection.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreRemoteDebuggerConnection.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreRenderable.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreRenderable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreRenderableSource.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreRenderableSource.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreResourceManager.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreResourceManager.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreResourceSystem.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreResourceSystem.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreScene.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreScene.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneContactController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneController.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneRenderer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneRenderer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneTriggerController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneTriggerController.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShape.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShape.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapePrimitives.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapePrimitives.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeTerrain.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeTerrain.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeWheel.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeWheel.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSheet.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSheet.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSimpleActor.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSimpleActor.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSimpleShape.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSimpleShape.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSkeleton.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSkeleton.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSleepCallback.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSleepCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSoftBody.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSoftBody.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreStable.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreStable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreTesting.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreTesting.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreThrow.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreTrigger.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreTrigger.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreTriggerCallback.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreTriggerCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserAllocator.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserAllocator.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreWheelSet.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreWheelSet.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreWorld.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreWorld.h
Added Paths:
-----------
trunk/python-ogre/ThirdParty/nxogre/FireState.cpp
trunk/python-ogre/ThirdParty/nxogre/Flour.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreDeletionCallback.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreDeletionCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreFileResource.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreFileResource.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreFileResourceManager.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreFileResourceManager.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreHeightfield.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreHeightfield.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointCallback.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreKinematicCharacter.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreKinematicCharacter.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreKinematicCharacterSweep.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreManualHeightfield.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreManualHeightfield.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreManualMesh.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreManualMesh.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreManualMeshUtil.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreManualMeshUtil.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMaterialAlias.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMaterialAlias.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMemoryResource.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMemoryResource.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMemoryResourceManager.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMemoryResourceManager.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMesh.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMesh.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreMeshParams.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMeshParams.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePrerequisitesOgre.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreResource.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreResource.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreResourceCallback.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreResourceCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeMeshes.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeMeshes.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreTimeStep.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreTimer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreTimer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreTriggerFunction.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreVoidPointer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreWheelContactCallback.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreWhen.h
Modified: trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.cpp 2008-06-17 04:38:24 UTC (rev 596)
+++ trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.cpp 2008-06-20 06:54:10 UTC (rev 597)
@@ -25,4 +25,629 @@
*/
#include "NxOgreStable.h"
-#include "BetajaenCC.h"
\ No newline at end of file
+#include "BetajaenCC.h"
+
+#if 0
+
+BETAJAEN_CC_NAMESPACE_START
+
+/*
+ Flat
+
+ \note Iterator is known as Type* in this file only.
+*/
+
+template< class Type, class AllocatorType >
+Flat<Type, AllocatorType>::Flat(AllocatorPtr allocator, bool deleteAllocator)
+ : First(NULL), Last(NULL), End(NULL), Allocator(allocator), AutoDeleteAllocator(deleteAllocator)
+{
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+Flat<Type, AllocatorType>::~Flat()
+{
+ _deallocate(First);
+ if (AutoDeleteAllocator)
+ delete Allocator;
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+unsigned int Flat<Type, AllocatorType>::_size() const
+{
+ return (unsigned int) (Last - First);
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+unsigned int Flat<Type, AllocatorType>::_capacity() const
+{
+ return (unsigned int) (First == 0 ? 0 : End - First);
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+Type* Flat<Type, AllocatorType>::_allocate(unsigned int size)
+{
+ return (Type*) Allocator->Allocate(size * sizeof(Type));
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+void Flat<Type, AllocatorType>::_deallocate(Type* p)
+{
+ if (p)
+ Allocator->Deallocate(p);
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+Type* Flat<Type, AllocatorType>::_reallocate(Type* p, unsigned int size)
+{
+ return (Iterator) Allocator->Reallocate(p, size * sizeof(Type));
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+void Flat<Type, AllocatorType>::_clip(unsigned int size)
+{
+
+ if (size < _size())
+ return;
+
+ Iterator new_first = _allocate(size);
+ _copy(First, Last, new_first);
+ _destroy(First, Last);
+ _deallocate(First);
+ End = new_first + size;
+ Last = new_first + _size();
+ First = new_first;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+void Flat<Type, AllocatorType>::_reserve(unsigned int new_size)
+{
+ if (_capacity() >= new_size)
+ return;
+
+ Iterator new_first = _allocate(new_size);
+ _copy(First, Last, new_first);
+ _destroy(First, Last);
+ _deallocate(First);
+ End = new_first + new_size;
+ Last = new_first + _size();
+ First = new_first;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+Type* Flat<Type, AllocatorType>::_copy(Type* begin, Type* end, Type* dest)
+{
+ for (;begin != end; ++dest, ++begin)
+ *dest = *begin;
+ return dest;
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+void Flat<Type, AllocatorType>::_delete_range(Type* begin, Type* end)
+{
+ for (; begin != end; ++begin) {
+ BETAJAEN_CC_DELETE(*begin);
+ }
+}
+
+/////////////////////////////////////////////////////////////
+
+template< class Type, class AllocatorType >
+void Flat<Type, AllocatorType>::_destroy(Type* begin, Type* end)
+{
+ for (; begin != end; ++begin) {
+ BETAJAEN_CC_DESTRUCTOR(begin)
+ begin->~Type();
+ }
+}
+
+BETAJAEN_CC_NAMESPACE_END
+
+
+/**
+ SharedList
+*/
+
+BETAJAEN_CC_NAMESPACE_START
+
+/////////////////////////////////////////////////////////////
+
+#define SharedListType SharedList<Type, AllocatorType>
+#define TypePtr Type*
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+SharedList<Type, AllocatorType>::SharedList(AllocatorType* _allocator, bool _auto_delete_allocator)
+{
+ if (_allocator == NULL)
+ _allocator = new AllocatorType();
+
+ _Flat = new FlatType(_allocator, _auto_delete_allocator);
+ _Usage = new unsigned int(1);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+SharedList<Type, AllocatorType>::SharedList(const SharedListType& other)
+{
+
+ _Flat = other._Flat;
+ _Usage = other._Usage;
+ ++(*_Usage);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+SharedListType& SharedList<Type, AllocatorType>::operator=(const SharedListType& other)
+{
+
+ if (_Flat)
+ {
+ _Flat->_delete_range(_Flat->First, _Flat->Last);
+ delete _Flat;
+ }
+
+ if (_Usage)
+ delete _Usage;
+
+ _Flat = other._Flat;
+ _Usage = other._Usage;
+ ++(*_Usage);
+
+ return *this;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::Get(size_t pos)
+{
+ if (pos > Size())
+ return NULL;
+
+ return *(_Flat->First + pos);
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::operator[](size_t pos)
+{
+ if (pos > Size())
+ return NULL;
+
+ return *(_Flat->First + pos);
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+unsigned int SharedList<Type, AllocatorType>::WhereIs(TypePtr ptr)
+{
+
+ if (_Flat->_size() == 0)
+ return 0;
+
+ unsigned int i=0;
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin, ++i)
+ {
+ if (ptr == (*begin))
+ return i;
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+bool SharedList<Type, AllocatorType>::Has(TypePtr ptr)
+{
+
+ if (_Flat->_size() == 0)
+ return false;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ {
+ if (ptr == (*begin))
+ return true;
+ }
+
+ return false;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+unsigned SharedList<Type, AllocatorType>::Size() const
+{
+ return _Flat->_size();
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::Insert(Type* const & val)
+{
+
+ if (_Flat->End <= _Flat->Last)
+ _Flat->_reserve( (1 + Size()) * 2);
+
+ *_Flat->Last = val;
+ _Flat->Last++;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::Clean(unsigned int n)
+{
+ _Flat->_clip(_Flat->_size() + n);
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::Destroy(unsigned int n)
+{
+ if (n == 0)
+ return Destroy(First);
+
+ if (n == Size())
+ return Destroy(Last);
+
+ delete *(_Flat->First + n);
+
+ _Flat->_destroy(_Flat->First + n, _Flat->First + n + 1);
+ _Flat->_copy(_Flat->First + n + 1, _Flat->Last, _Flat->First + n);
+ _Flat->Last--;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::DestroyAll()
+{
+ if (Size() == 0)
+ return;
+
+ _Flat->_delete_range(_Flat->First, _Flat->Last);
+ // Could be iffy.
+ _Flat->Last = _Flat->First;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::Destroy(TypePtr val) {
+ unsigned int i = WhereIs(val);
+ Destroy(i);
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::Destroy(AbsolutePosition position)
+{
+
+ switch(position) {
+
+ case First:
+ {
+ delete *_Flat->First;
+ _Flat->_copy(_Flat->First + 1, _Flat->Last + 1, _Flat->First);
+ _Flat->Last--;
+ }
+ break;
+
+ case Last:
+ {
+ _Flat->Last--;
+ delete *_Flat->Last;
+ }
+ break;
+
+ }
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::Remove(unsigned int n)
+{
+
+ if (n == 0)
+ return Remove(First);
+
+ if (n == Size())
+ return Remove(Last);
+
+ TypePtr ptr = Get(n);
+ _Flat->_destroy(_Flat->First + n, _Flat->First + n + 1);
+ _Flat->_copy(_Flat->First + n + 1, _Flat->Last, _Flat->First + n);
+ _Flat->Last--;
+
+ return ptr;
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::Remove(AbsolutePosition position)
+{
+
+ if (_Flat->_size() == 0)
+ return NULL;
+
+ switch(position) {
+
+ case First:
+ {
+ TypePtr t = *(_Flat->First);
+ _Flat->_copy(_Flat->First + 1, _Flat->Last + 1, _Flat->First);
+ _Flat->Last--;
+ return t;
+ }
+
+ break;
+
+ case Last:
+ {
+ _Flat->Last--;
+ return *(_Flat->Last);
+ }
+ break;
+ }
+
+ return NULL;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::Begin()
+{
+
+ if (_Flat->_size() == 0)
+ return NULL;
+
+ _Iterator = _Flat->First;
+ return *_Iterator;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::Next()
+{
+
+ if (_Flat->_size() == 0)
+ return NULL;
+ else if (_Iterator == _Flat->Last)
+ return NULL;
+ else
+ return (*_Iterator++);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::End()
+{
+
+ if (_Flat->_size() == 0)
+ return NULL;
+
+ _Iterator = _Flat->Last - 1;
+ return *_Iterator;
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+TypePtr SharedList<Type, AllocatorType>::Previous()
+{
+
+ if (_Flat->_size() == 0)
+ return NULL;
+ else if (_Iterator == _Flat->First - 1)
+ return NULL;
+ else
+ return (*_Iterator--);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)()) {
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin) {
+ (*begin->*MethodPtr)();
+ }
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template < typename _A >
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A), _A _1) {
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin) {
+ (*begin->*MethodPtr)(_1);
+ }
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template < typename _A, typename _B>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B), _A _1, _B _2) {
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template <typename _A, typename _B, typename _C>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B, _C), _A _1, _B _2, _C _3)
+{
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2, _3);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template <typename _A, typename _B, typename _C, typename _D>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A _1, _B _2, _C _3, _D _4)
+{
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2, _3, _4);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template <typename _A, typename _B, typename _C, typename _D, typename _E>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A _1, _B _2, _C _3, _D _4, _E _5) {
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2, _3, _4, _5);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template <typename _A, typename _B, typename _C, typename _D, typename _E, typename _F>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A _1, _B _2, _C _3, _D _4, _E _5, _F _6)
+{
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2, _3, _4, _5, _6);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template <typename _A, typename _B, typename _C, typename _D, typename _E, typename _F, typename _G>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A _1, _B _2, _C _3, _D _4, _E _5, _F _6, _G _7)
+{
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2, _3, _4, _5, _6, _7);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < typename Type, typename AllocatorType>
+template <typename _A, typename _B, typename _C, typename _D, typename _E, typename _F, typename _G, typename _H>
+void SharedList<Type, AllocatorType>::Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A _1, _B _2, _C _3, _D _4, _E _5, _F _6, _G _7, _H _8)
+{
+
+ if (_Flat->_size() == 0)
+ return;
+
+ for(Iterator begin = _Flat->First; begin != _Flat->Last; ++begin)
+ (*begin->*MethodPtr)(_1, _2, _3, _4, _5, _6, _7, _8);
+
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+unsigned int SharedList<Type, AllocatorType>::getUsageCount() const
+{
+ return *_Usage;
+}
+
+/////////////////////////////////////////////////////////////
+
+template < class Type, class AllocatorType >
+Flat<Type*, AllocatorType>* SharedList<Type, AllocatorType>::getFlat() const {
+ return _Flat;
+}
+
+/////////////////////////////////////////////////////////////
+
+#undef SharedListType
+#undef TypePtr
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_END
+
+
+#endif
\ No newline at end of file
Modified: trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.h
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.h 2008-06-17 04:38:24 UTC (rev 596)
+++ trunk/python-ogre/ThirdParty/nxogre/BetajaenCC.h 2008-06-20 06:54:10 UTC (rev 597)
@@ -48,6 +48,18 @@
#define BETAJAEN_CC_TEMPLATE_CLASS_EXPORT __forceinline
// #define BETAJAEN_CC_FUNCTION_EXPORT NxPublicFunction
+
+/** \brief Delete macro. Used if you have your own leak checker, etc.
+*/
+// #define BETAJAEN_CC_DELETE(ptr) \
+// {::NxOgre::Allocator::getPtr()->watch_delete(static_cast<void*>(ptr));}; \
+// delete ptr;
+
+// /** \brief Called just before when a class is destroyed using it's destructor.
+// */
+// #define BETAJAEN_CC_DESTRUCTOR(ptr) \
+// ::NxOgre::Allocator::getPtr()->watch_delete(begin);
+
//////////////////////////////////////////////////////////////////////////
#if (BETAJAEN_CC_DEBUG_COMMENTS == 1)
@@ -73,11 +85,9 @@
#endif
#if (_MSC_VER>=1000)
-# define BETAJAEN_CC_INLINE
-// __forceinline
+# define BETAJAEN_CC_INLINE __forceinline
#else
-# define BETAJAEN_CC_INLINE
-//inline
+# define BETAJAEN_CC_INLINE inline
#endif
#ifndef BETAJAEN_CC_CLASS_EXPORT
@@ -92,15 +102,24 @@
# define BETAJAEN_CC_FUNCTION_EXPORT
#endif
+#ifndef BETAJAEN_CC_DELETE
+# define BETAJAEN_CC_DELETE(ptr) delete ptr;
+#endif
+
+#ifndef BETAJAEN_CC_DESTRUCTOR
+# define BETAJAEN_CC_DESTRUCTOR(ptr)
+#endif
+
BETAJAEN_CC_NAMESPACE_END
//////////////////////////////////////////////////////////////////////////
BETAJAEN_CC_NAMESPACE_START
+
class SharedAllocator;
-
template <class TypePtr, class AllocatorType = SharedAllocator> class Flat;
+template <class BaseType, class AllocatorType = SharedAllocator> class Array;
template <class BaseType, class AllocatorType = SharedAllocator> class SharedList;
template <typename IdentifierType, class BaseType, class AllocatorType = SharedAllocator> class SharedMap;
template <typename IdentifierType, class TypePtr> class Tree;
@@ -264,9 +283,7 @@
BETAJAEN_CC_INLINE void _delete_range(Iterator begin, Iterator end)
{
for (; begin != end; ++begin) {
- {::NxOgre::Allocator::getPtr()->watch_delete(static_cast<void*>(*begin));};
- delete *begin;
- /** NxOgre Remove*/ // delete *begin;
+ BETAJAEN_CC_DELETE(*begin);
}
}
@@ -275,15 +292,15 @@
BETAJAEN_CC_INLINE void _destroy(Iterator begin, Iterator end)
{
for (; begin != end; ++begin) {
- /** NxOgre */ ::NxOgre::Allocator::getPtr()->watch_delete(begin);
+ BETAJAEN_CC_DESTRUCTOR(begin)
begin->~Type();
}
}
/////////////////////////////////////////////////////////////
-private: AllocatorPtr Allocator;
-private: bool AutoDeleteAllocator;
+protected: AllocatorPtr Allocator;
+protected: bool AutoDeleteAllocator;
public: Iterator First, Last, End;
}; // End of Flat<Type,AllocatorType> class.
@@ -294,6 +311,68 @@
BETAJAEN_CC_NAMESPACE_START
+template
+ <
+ class Type, /* Class to Store; A, myClassName, etc. */
+ class AllocatorType /* Allocator to use, or leave blank for SharedAllocator */
+ >
+class BETAJAEN_CC_CLASS_EXPORT Array {
+
+public:
+
+typedef Type* TypePtr;
+typedef Array<Type, AllocatorType> ArrayType;
+typedef Flat<Type, AllocatorType> FlatType;
+typedef FlatType* FlatPtr;
+
+BETAJAEN_CC_INLINE Array(AllocatorType* _allocator = NULL, bool _auto_delete_allocator = true)
+{
+ if (_allocator == NULL)
+ _allocator = new AllocatorType();
+
+ _Flat = new FlatType(_allocator, _auto_delete_allocator);
+
+}
+
+BETAJAEN_CC_INLINE ~Array()
+{
+ delete _Flat;
+}
+
+BETAJAEN_CC_INLINE TypePtr getPtr()
+{
+ return _Flat->First;
+}
+
+BETAJAEN_CC_INLINE unsigned int Size()
+{
+ return _Flat->_size();
+}
+
+BETAJAEN_CC_INLINE void Append(Type v) {
+
+ if (_Flat->End <= _Flat->Last)
+ _Flat->_reserve( (1 + _Flat->_size()) * 2);
+
+ *_Flat->Last = v;
+ _Flat->Last++;
+
+}
+
+BETAJAEN_CC_INLINE void Clip() {
+ _Flat->_clip(0);
+}
+
+private: FlatPtr _Flat;
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
/** \brief A list of pointers with garbage collections and the ability to
share the same list with similar lists. Like STL's Vector.
@@ -616,7 +695,21 @@
}
+// \brief Destroys everything
+//
+BETAJAEN_CC_INLINE void RemoveAll()
+{
+ if (Size() == 0)
+ return;
+ _Flat->_deallocate(_Flat->First);
+
+ // Could be iffy.
+ _Flat->Last = _Flat->First;
+
+}
+
+
/** \brief Places the Iterator at the beginning of the List
*/
BETAJAEN_CC_INLINE TypePtr Begin()
@@ -869,6 +962,13 @@
};
+class BETAJAEN_CC_CLASS_EXPORT NodeIterator
+{
+public:
+ NodePtr _Up[50];
+ NodePtr _It;
+ int _Top;
+};
/** \brief Tree constructor
*/
@@ -884,11 +984,16 @@
{
}
+public: BETAJAEN_CC_INLINE bool isEmpty() const {
+ return (_Root == 0);
+}
/** \brief Destroys all the nodes in the tree and deletes all of the values referenced in it.
*/
public: BETAJAEN_CC_INLINE void DestroyAll()
{
+ if (_Root == NULL)
+ return;
NodePtr iterator = _Root;
NodePtr save = 0;
@@ -911,6 +1016,7 @@
iterator = save;
}
+ _Root = NULL;
}
@@ -918,6 +1024,10 @@
*/
public: BETAJAEN_CC_INLINE void RemoveAll()
{
+
+ if (_Root == NULL)
+ return;
+
NodePtr iterator = _Root;
NodePtr save = 0;
@@ -933,11 +1043,14 @@
{
save = iterator->_Children[1];
delete iterator;
+ iterator = NULL;
}
iterator = save;
}
+ _Root = NULL;
+
}
@@ -1011,9 +1124,68 @@
return 0;
}
+/**
+*/
+public: BETAJAEN_CC_INLINE TypePtr First(NodeIterator* it)
+{
+ it->_It = _Root;
+ it->_Top = 0;
+
+ if (it->_It != 0) {
+ while (it->_It->_Children[0] != 0) {
+ it->_Up[it->_Top++] = it->_It;
+ it->_It = it->_It->_Children[0];
+ }
+ }
+
+ if (it->_It != 0)
+ return it->_It->_Val;
+ else
+ return 0;
+
+}
+
/**
*/
+public: BETAJAEN_CC_INLINE TypePtr Next(NodeIterator* it)
+{
+ if (it->_It->_Children[1] != 0) {
+ it->_Up[it->_Top++] = it->_It;
+ it->_It = it->_It->_Children[1];
+
+ while (it->_It->_Children[0] != 0) {
+ it->_Up[it->_Top++] = it->_It;
+ it->_It = it->_It->_Children[0];
+ }
+
+ }
+ else {
+ NodePtr last;
+
+ do {
+
+ if (it->_Top == 0) {
+ it->_It = 0;
+ break;
+ }
+
+ last = it->_It;
+ it->_It = it->_Up[--it->_Top];
+
+ } while (last == it->_It->_Children[1]);
+
+ }
+
+ if (it->_It != 0)
+ return it->_It->_Val;
+ else
+ return 0;
+
+}
+
+/**
+*/
public: BETAJAEN_CC_INLINE bool Insert(NodeIdentifier target, TypePtr val)
{
Node* node = new Node(target, val);
@@ -1051,6 +1223,7 @@
return true;
}
+
private: NodePtr _Root;
};
@@ -1116,11 +1289,1272 @@
BETAJAEN_CC_INLINE void DestroyAll()
{
+ _Tree->DestroyAll();
+}
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE void RemoveAll() {
+ _Tree->RemoveAll();
}
/////////////////////////////////////////////////////////////
+BETAJAEN_CC_INLINE void Destroy(IdentifierType);
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE void Remove(IdentifierType);
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE TypePtr Begin();
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE TypePtr Next();
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE TypePtr End();
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE TypePtr Previous();
+
+/////////////////////////////////////////////////////////////
+
+/** \brief For each item in the list call it's own method.
+*/
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)()) {
+
+ if (_Tree->isEmpty())
+ return;
+
+ typename TreeType::NodeIterator iterator;
+ TypePtr ptr = _Tree->First(&iterator);
+
+ while (ptr != 0) {
+ (ptr->*MethodPtr)();
+ ptr = _Tree->Next(&iterator);
+ }
+}
+
+
+/** \brief For each item in the list call it's own method, with one argument.
+*/
+template <typename _A>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A), _A _1) {
+
+ if (_Tree->isEmpty())
+ return;
+
+ typename TreeType::NodeIterator iterator;
+ TypePtr ptr = _Tree->First(&iterator);
+
+ while (ptr != 0) {
+ (ptr->*MethodPtr)(_1);
+ ptr = _Tree->Next(&iterator);
+ }
+}
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE TreePtr getTree() const
+{
+ return _Tree;
+}
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE unsigned int getUsage() const
+{
+ return *_Usage;
+}
+
+/////////////////////////////////////////////////////////////
+
+private: TreePtr _Tree;
+private: unsigned int* _Usage;
+
+/////////////////////////////////////////////////////////////
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+/** \brief Vector with two rows.
+*/
+template <
+ typename Type
+ >
+class BETAJAEN_CC_CLASS_EXPORT Vector2
+{
+
+public:
+
+typedef Vector2<Type> ThisType;
+
+/* \brief First */
+Type i;
+
+/* \brief Second */
+Type j;
+
+BETAJAEN_CC_INLINE Vector2()
+{
+}
+
+BETAJAEN_CC_INLINE Vector2(Type _i, Type _j)
+: i(_i), j(_j)
+{
+}
+
+BETAJAEN_CC_INLINE void swap(ThisType& other)
+{
+ Type First = i, Second = j;
+ i = other.i; other.i = First;
+ j = other.j; other.j = Second;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator = (const ThisType& other)
+{
+ i = other.i; j = other.j;
+ return *this;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator = (const Type& other)
+{
+ i = other; j = other;
+ return *this;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator *= (const Type& other)
+{
+ i *= other; j *= other;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator *= (const ThisType& other)
+{
+ i *= other.i; j *= other.j;
+}
+
+BETAJAEN_CC_INLINE bool operator == (const ThisType& other) const
+{
+ return (i == other.i && j == other.j);
+}
+
+BETAJAEN_CC_INLINE bool operator != (const ThisType& other) const
+{
+ return (i != other.i || j != other.j);
+}
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+/** \brief Vector with three rows.
+*/
+template <
+ typename Type
+ >
+class BETAJAEN_CC_CLASS_EXPORT Vector3
+{
+
+public:
+
+typedef Vector3<Type> ThisType;
+
+/* \brief First */
+Type i;
+
+/* \brief Second */
+Type j;
+
+/* \brief Third */
+Type k;
+
+
+BETAJAEN_CC_INLINE Vector3()
+{
+}
+
+BETAJAEN_CC_INLINE Vector3(Type _i, Type _j, Type _k)
+: i(_i), j(_j), k(_k)
+{
+}
+
+BETAJAEN_CC_INLINE void swap(ThisType& other)
+{
+ Type First = i, Second = j, Third = k;
+ i = other.i; other.i = First;
+ j = other.j; other.j = Second;
+ k = other.k; other.k = Third;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator = (const ThisType& other)
+{
+ i = other.i; j = other.j; k = other.k;
+ return *this;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator = (const Type& other)
+{
+ i = other; j = other; k = other;
+ return *this;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator *= (const Type& other)
+{
+ i *= other; j *= other; k *= other;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator *= (const ThisType& other)
+{
+ i *= other.i; j *= other.j; k *= other.k;
+}
+
+BETAJAEN_CC_INLINE bool operator == (const ThisType& other) const
+{
+ return (i == other.i && j == other.j && k == other.k);
+}
+
+BETAJAEN_CC_INLINE bool operator != (const ThisType& other) const
+{
+ return (i != other.i || j != other.j || k != other.k);
+}
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+/** \brief Vector with four rows.
+*/
+template <
+ typename Type
+ >
+class BETAJAEN_CC_CLASS_EXPORT Vector4 {
+
+public:
+
+typedef Vector4<Type> ThisType;
+
+/* \brief First */
+Type i;
+
+/* \brief Second */
+Type j;
+
+/* \brief Third */
+Type k;
+
+/* \brief Fourth */
+Type l;
+
+BETAJAEN_CC_INLINE Vector4()
+{
+}
+
+BETAJAEN_CC_INLINE Vector4(Type _i, Type _j, Type _k, Type _l)
+: i(_i), j(_j), k(_k), l(_l)
+{
+}
+
+BETAJAEN_CC_INLINE void swap(ThisType& other)
+{
+ Type First = i, Second = j, Third = k, Fourth = l;
+ i = other.i; other.i = First;
+ j = other.j; other.j = Second;
+ k = other.k; other.k = Third;
+ l = other.l; other.l = Fourth;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator = (const ThisType& other) {
+ i = other.i; j = other.j; k = other.k; l = other.l;
+ return *this;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator *= (const Type& other)
+{
+ i *= other; j *= other; k *= other; l *= other;
+}
+
+BETAJAEN_CC_INLINE ThisType& operator *= (const ThisType& other)
+{
+ i *= other.i; j *= other.j; k *= other.k; l *= other.l;
+}
+
+BETAJAEN_CC_INLINE bool operator == (const ThisType& other) const {
+ return (i == other.i && j == other.j && k == other.k && l == other.l);
+}
+
+BETAJAEN_CC_INLINE bool operator != (const ThisType& other) const {
+ return (i != other.i || j != other.j || k != other.k || l != other.l);
+}
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+template <typename Type>
+class BETAJAEN_CC_CLASS_EXPORT Vector {
+
+ public:
+ typedef Type* TypePtr;
+
+ TypePtr j;
+ unsigned int jSize;
+
+ Vector(unsigned int j_size)
+ {
+
+ }
+
+ ~Vector()
+ {
+
+ }
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+#if 0
+BETAJAEN_CC_NAMESPACE_START
+
+template <typename Type>
+class BETAJAEN_CC_TEMPLATE_CLASS_EXPORT Matrix {
+
+public:
+ typedef Type* TypePtr;
+
+ TypePtr ij;
+ unsigned int iSize,
+ jSize;
+
+ class MatrixIterator {
+ public:
+
+ enum IteratorRole {
+ IR_COLUMN,
+ IR_ROW
+ };
+
+ MatrixIterator(Matrix* _matrix, IteratorRole _role, unsigned int _iterator = 0)
+ mMatrix(_matrix), mRole(_role), mIterator(_iterator)
+ {
+ }
+
+ Matrix* mMatrix;
+ IteratorRole mRole;
+ unsigned int mIterator;
+
+ };
+
+ class RowIterator {
+ public:
+ RowIterator(TypePtr ijPtr, unsigned int row, unsigned int i_size, unsigned j_size)
+ : ij(ijPtr), r(row), iSize(i_size), jSize(j_size)
+ {
+ }
+
+ Type& operator[] (unsigned int column)
+ {
+ return ij[(column * iSize) + r];
+ }
+
+
+ RowIterator& operator=(Type _f) {
+
+ // Doesn't work.
+ for (unsigned int i=r * iSize;i < (r * iSize) + iSize;i++) {
+ printf("i=%i\n", i);
+ ij[i] = _f;
+ }
+ printf("Done.\n");
+ return *this;
+ }
+
+ TypePtr ij;
+ unsigned int r, iSize, jSize;
+
+ };
+
+ class ColumnIterator {
+
+ public:
+
+ ColumnIterator(TypePtr ijPtr, unsigned int col, unsigned int i_size, unsigned j_size)
+ : ij(ijPtr), c(col), iSize(i_size), jSize(j_size)
+ {
+ }
+
+ Type& operator[] (unsigned int row)
+ {
+ if (row > i_size)
+ row = i_size;
+
+ return ij[(c * iSize) + row];
+ }
+
+
+ ColumnIterator& operator=(Type _f) {
+ for (unsigned int i=c;i < c + jSize;i++) {
+ printf("i=%i\n", i);
+ ij[i] = _f;
+ }
+ printf("Done.\n");
+ return *this;
+ }
+
+ TypePtr ij;
+ unsigned int c, iSize, jSize;
+ };
+
+ class All {
+ public:
+
+ All()
+ {
+ }
+
+ All(TypePtr ijPtr, unsigned int i_size, unsigned int j_size)
+ : ij(ijPtr), iSize(i_size), jSize(j_size)
+ {
+ }
+
+ All& operator=(Type _f) {
+ for (unsigned int i=0;i < iSize;i++)
+ for (unsigned int j=0;j < jSize;j++)
+ ij[(j * jSize) + i] = _f;
+ return *this;
+ }
+
+ All& operator*=(Type _f) {
+ for (unsigned int i=0;i < iSize;i++)
+ for (unsigned int j=0;j < jSize;j++)
+ ij[(j * jSize) + i] *= _f;
+ return *this;
+ }
+
+ All& operator/=(Type _f) {
+ for (unsigned int i=0;i < iSize;i++)
+ for (unsigned int j=0;j < jSize;j++)
+ ij[(j * jSize) + i] /= _f;
+ return *this;
+ }
+
+ All& operator+=(Type _f) {
+ for (unsigned int i=0;i < iSize;i++)
+ for (unsigned int j=0;j < jSize;j++)
+ ij[(j * jSize) + i] += _f;
+ return *this;
+ }
+
+ All& operator-=(Type _f) {
+ for (unsigned int i=0;i < iSize;i++)
+ for (unsigned int j=0;j < jSize;j++)
+ ij[(j * jSize) + i] -= _f;
+ return *this;
+ }
+
+ All& operator++(int) {
+ for (unsigned int i=0;i < iSize;i++)
+ for (unsigned int j=0;j < jSize;j++)
+ ij[(j * jSize) + i]++;
+ return *this;
+ }
+
+
+ TypePtr ij;
+ unsigned iSize, jSize;
+ };
+
+ All all;
+
+Matrix(unsigned int nbRows, unsigned int nbColumns)
+: iSize(nbRows), jSize(nbColumns)
+{
+ ij = new Type[iSize * jSize];
+ for (unsigned int i = 0;i < (iSize * jSize);i++)
+ ij[i] = 0;
+
+ all = All(ij, iSize, jSize);
+
+ BETAJAEN_CC_PRINTF("Matrix created with %i", nbColumns);
+}
+
+~Matrix()
+{
+ if (iSize || jSize)
+ delete [] ij;
+}
+
+RowIterator operator[] (unsigned int row)
+{
+ return RowIterator(ij, row, iSize, jSize);
+}
+
+ColumnIterator operator() (unsigned col)
+{
+ return ColumnIterator(ij, col, iSize, jSize);
+}
+
+void dump()
+{
+ for (unsigned int i=0;i < iSize;i++) {
+ for (unsigned int j=0;j < jSize;j++) {
+ printf("%f\t", ij[(j * jSize) + i]);
+ }
+ printf("\n");
+ }
+
+}
+
+};
+BETAJAEN_CC_NAMESPACE_END
+#endif
+
+//////////////////////////////////////////////////////////////////////////
+
+#endif
+
+
+#if 0
+/*
+
+Betajaen's Container Classes
+
+Copyright (c) 2007 Robin Southern, http://www.nxogre.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+
+#ifndef BETAJAENS_CC_H
+#define BETAJAENS_CC_H
+
+#include "NxOgrePlatform.h"
+#include "NxOgreAllocator.h"
+
+// Configuration
+
+/** \brief Namespace to place the Containers in. Comment out if you want it in the global namespace.
+*/
+#define BETAJAEN_CC_NAMESPACE Betajaen
+
+
+/** \brief Enable debug comments. Set to zero to disable, 1 to enable
+*/
+#define BETAJAEN_CC_DEBUG_COMMENTS 1
+
+
+/** \brief Export Class Macro, replace value with your export macro
+*/
+#define BETAJAEN_CC_CLASS_EXPORT __declspec(dllexport)
+#define BETAJAEN_CC_TEMPLATE_CLASS_EXPORT __forceinline
+// #define BETAJAEN_CC_FUNCTION_EXPORT NxPublicFunction
+
+
+/** \brief Delete macro. Used if you have your own leak checker, etc.
+*/
+#define BETAJAEN_CC_DELETE(ptr) \
+ {::NxOgre::Allocator::getPtr()->watch_delete(static_cast<void*>(ptr));}; \
+ delete ptr;
+
+/** \brief Called just before when a class is destroyed using it's destructor.
+*/
+#define BETAJAEN_CC_DESTRUCTOR(ptr) \
+ ::NxOgre::Allocator::getPtr()->watch_delete(begin);
+
+//////////////////////////////////////////////////////////////////////////
+
+#if (BETAJAEN_CC_DEBUG_COMMENTS == 1)
+# include <stdio.h>
+#endif
+
+#ifdef BETAJAEN_CC_NAMESPACE
+# define BETAJAEN_CC_NAMESPACE_START namespace BETAJAEN_CC_NAMESPACE {
+# define BETAJAEN_CC_NAMESPACE_END }
+#else
+# define BETAJAEN_CC_NAMESPACE_START /**/
+# define BETAJAEN_CC_NAMESPACE_END /**/
+#endif
+
+BETAJAEN_CC_NAMESPACE_START
+
+#if (BETAJAEN_CC_DEBUG_COMMENTS == 1)
+# define BETAJAEN_CC_PRINT(x) printf(x "\n");
+# define BETAJAEN_CC_PRINTF(x, y) printf(x "\n",y);
+#else
+# define BETAJAEN_CC_PRINT(x) /* x */
+# define BETAJAEN_CC_PRINTF(x,y) /* x, y*/
+#endif
+
+#if (_MSC_VER>=1000)
+# define BETAJAEN_CC_INLINE __forceinline
+#else
+# define BETAJAEN_CC_INLINE inline
+#endif
+
+#ifndef BETAJAEN_CC_CLASS_EXPORT
+# define BETAJAEN_CC_CLASS_EXPORT
+#endif
+
+#ifndef BETAJAEN_CC_TEMPLATE_CLASS_EXPORT
+# define BETAJAEN_CC_TEMPLATE_CLASS_EXPORT
+#endif
+
+#ifndef BETAJAEN_CC_FUNCTION_EXPORT
+# define BETAJAEN_CC_FUNCTION_EXPORT
+#endif
+
+#ifndef BETAJAEN_CC_DELETE
+# define BETAJAEN_CC_DELETE(ptr) delete ptr;
+#endif
+
+#ifndef BETAJAEN_CC_DESTRUCTOR
+# define BETAJAEN_CC_DESTRUCTOR(ptr)
+#endif
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+template <class TypePtr, class AllocatorType = SharedAllocator> class Flat;
+class SharedAllocator;
+template <class BaseType, class AllocatorType = SharedAllocator> class SharedList;
+template <typename IdentifierType, class BaseType, class AllocatorType = SharedAllocator> class SharedMap;
+template <typename IdentifierType, class TypePtr> class Tree;
+template <typename> class Vector2;
+template <typename> class Vector3;
+template <typename> class Vector4;
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+class BETAJAEN_CC_CLASS_EXPORT SharedAllocator {
+
+public:
+
+/////////////////////////////////////////////////////////////
+
+void* Allocate(size_t size)
+{
+ return malloc(size);
+}
+
+/////////////////////////////////////////////////////////////
+
+void Deallocate(void* mem)
+{
+ if (mem)
+ free(mem);
+}
+
+/////////////////////////////////////////////////////////////
+
+void* Reallocate(void* mem, size_t size)
+{
+ return realloc(mem, size);
+}
+
+/////////////////////////////////////////////////////////////
+
+}; // End of the SharedAllocator class.
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+template
+ <
+ class Type,
+ class AllocatorType
+ >
+class BETAJAEN_CC_CLASS_EXPORT Flat
+{
+
+public:
+
+typedef Type * Iterator;
+typedef AllocatorType* AllocatorPtr;
+
+BETAJAEN_CC_INLINE Flat(AllocatorPtr allocator, bool deleteAllocator);
+BETAJAEN_CC_INLINE ~Flat();
+BETAJAEN_CC_INLINE unsigned int _size() const;
+BETAJAEN_CC_INLINE unsigned int _capacity() const;
+BETAJAEN_CC_INLINE Type* _allocate(unsigned int size);
+BETAJAEN_CC_INLINE void _deallocate(Type* p);
+BETAJAEN_CC_INLINE Iterator _reallocate(Iterator p, unsigned int size);
+BETAJAEN_CC_INLINE void _clip(unsigned int size);
+BETAJAEN_CC_INLINE void _reserve(unsigned int new_size);
+BETAJAEN_CC_INLINE Iterator _copy(Iterator begin, Iterator end, Iterator dest);
+BETAJAEN_CC_INLINE void _delete_range(Iterator begin, Iterator end);
+BETAJAEN_CC_INLINE void _destroy(Iterator begin, Iterator end);
+
+private: AllocatorPtr Allocator;
+private: bool AutoDeleteAllocator;
+public: Iterator First, Last, End;
+
+}; // End of Flat<Type,AllocatorType> class.
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+/** \brief A list of pointers with garbage collections and the ability to
+ share the same list with similar lists. Like STL's Vector.
+
+ \example
+ <code>
+ class A;
+
+ SharedList<A> aList;
+ a.Insert(new A());
+ a.Remove(a.Last);
+ </code>
+
+*/
+template
+ <
+ class Type, /* Class to Store; A, myClassName, etc. */
+ class AllocatorType /* Allocator to use, or leave blank for SharedAllocator */
+ >
+class BETAJAEN_CC_CLASS_EXPORT SharedList {
+
+public:
+
+typedef Type* TypePtr;
+typedef TypePtr* Iterator;
+typedef SharedList<Type, AllocatorType> SharedListType;
+typedef Flat<TypePtr, AllocatorType> FlatType;
+typedef FlatType* FlatPtr;
+
+/////////////////////////////////////////////////////////////
+
+enum AbsolutePosition
+{
+ First,
+ Last
+};
+
+/**
+ Constructor with optional custom allocator
+*/
+BETAJAEN_CC_INLINE SharedList(AllocatorType* _allocator = NULL, bool _auto_delete_allocator = true);
+
+/** \brief Copy Constructor between SharedList's. The Flat will not be copied but referenced.
+ Any action on this list will effect all lists using the same Flat. Clean up will only
+ happen on the destruction of the last surviving list.
+
+ \example
+ <code>
+ typedef SharedList<A> AList;
+ AList a;
+ AList b(a);
+ </code>
+*/
+BETAJAEN_CC_INLINE SharedList(const SharedListType& other);
+
+/** \brief Copy Operator. Functions the same as Copy Constructor but deletes the set that this
+ may already have.
+
+ \example
+ <code>
+ typedef SharedList<A> AList;
+ AList a;
+ AList b;
+ b = a;
+ </code>
+*/
+BETAJAEN_CC_INLINE SharedListType& operator=(const SharedListType& other);
+
+
+/** \brief Destructor. If this is the last of all SharedLists sharing the same set,
+ the set will be destroyed otherwise the Flat will be ignored and this SharedList
+ dies gracefully.
+*/
+BETAJAEN_CC_INLINE ~SharedList() {
+
+ if (--(*_Usage) == 0)
+ {
+ _Flat->_delete_range(_Flat->First, _Flat->Last);
+ delete _Flat;
+ delete _Usage;
+ }
+
+}
+
+/** \brief Gets the pointer to the nth Type in the list. Alternate interface to operator[].
+*/
+BETAJAEN_CC_INLINE TypePtr Get(size_t pos);
+
+/** \brief Gets the pointer to the nth TypePtr in the list.
+*/
+BETAJAEN_CC_INLINE TypePtr operator[](size_t pos);
+
+/** \brief Where is something in the list.
+*/
+BETAJAEN_CC_INLINE unsigned int WhereIs(TypePtr ptr);
+
+/** \brief Is this pointer in the list?
+*/
+BETAJAEN_CC_INLINE bool Has(TypePtr ptr);
+
+/** \brief The size of the SharedList.
+*/
+BETAJAEN_CC_INLINE unsigned Size() const;
+
+/** \brief Insert something into the list
+*/
+BETAJAEN_CC_INLINE void Insert(const TypePtr& val);
+
+/** \brief Resize the capacity of the list to size + n.
+*/
+BETAJAEN_CC_INLINE void Clean(unsigned int n = 4);
+
+/** \brief Destroy something nth position into the list.
+*/
+BETAJAEN_CC_INLINE void Destroy(unsigned int n);
+
+// \brief Destroys everything
+//
+BETAJAEN_CC_INLINE void DestroyAll();
+
+/** \brief Destroys something in the list based on the pointer in the list.
+*/
+BETAJAEN_CC_INLINE void Destroy(TypePtr val);
+
+/** \brief Deletes something from the list based on AbsolutePosition
+*/
+BETAJAEN_CC_INLINE void Destroy(AbsolutePosition position);
+
+/** \brief Removes something from the list based on numerical position.
+*/
+BETAJAEN_CC_INLINE TypePtr Remove(unsigned int n);
+
+/** \brief Removes something from the list based on AbsolutePosition
+*/
+BETAJAEN_CC_INLINE TypePtr Remove(AbsolutePosition position);
+
+/** \brief Places the Iterator at the beginning of the List
+*/
+BETAJAEN_CC_INLINE TypePtr Begin();
+
+/** \brief Advances the Iterator forward by one, and returns the value of the list or NULL
+ \returns The next item in the list, or NULL if it has reached the end of it.
+*/
+BETAJAEN_CC_INLINE TypePtr Next();
+
+/** \brief Places the iterator at the end of the List
+*/
+BETAJAEN_CC_INLINE TypePtr End();
+
+/** \brief Advances the Iterator backwards by one, and returns the value of the list or NULL
+ \returns The previous item in the list, or NULL if it has reached the beginning of it.
+*/
+BETAJAEN_CC_INLINE TypePtr Previous();
+
+/** \brief For each item in the list call it's own method.
+*/
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)());
+
+/** \brief For each item in the list call it's own method, with one argument.
+*/
+template <typename _A>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A), _A);
+
+/** \brief For each item in the list call it's own method, with two arguments.
+*/
+template <typename _A, typename _B>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B), _A, _B);
+
+/** \brief For each item in the list call it's own method, with three arguments.
+*/
+template <typename _A, typename _B, typename _C>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B, _C), _A, _B, _C);
+
+/** \brief For each item in the list call it's own method, with four arguments.
+*/
+template <typename _A, typename _B, typename _C, typename _D>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A, _B, _C, _D);
+
+/** \brief For each item in the list call it's own method, with five arguments.
+*/
+template <typename _A, typename _B, typename _C, typename _D, typename _E>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A, _B, _C, _D, _E);
+
+/** \brief For each item in the list call it's own method, with six arguments.
+*/
+template <typename _A, typename _B, typename _C, typename _D, typename _E, typename _F>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A, _B, _C, _D, _E, _F);
+
+/** \brief For each item in the list call it's own method, with seven arguments.
+*/
+template <typename _A, typename _B, typename _C, typename _D, typename _E, typename _F, typename _G>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A, _B, _C, _D, _E, _F, _G);
+
+/** \brief For each item in the list call it's own method, with eight arguments.
+*/
+template <typename _A, typename _B, typename _C, typename _D, typename _E, typename _F, typename _G, typename _H>
+BETAJAEN_CC_INLINE void Each(void (Type::*MethodPtr)(_A, _B, _C, _D), _A, _B, _C, _D, _E, _F, _G, _H);
+
+/** \brief Returns the pointer to the working set.
+*/
+BETAJAEN_CC_INLINE FlatPtr getFlat() const;
+
+/** \brief Returns the number of SharedLists using this set.
+*/
+BETAJAEN_CC_INLINE unsigned int getUsageCount() const;
+
+private: unsigned int* _Usage;
+private: FlatPtr _Flat;
+private: Iterator _Iterator;
+
+}; // End of SharedList<Type, AllocatorType> Class.
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+
+/** \brief Binary Tree with variable identifer and storage type.
+
+*/
+template <typename NodeIdentifier, class Type>
+class BETAJAEN_CC_CLASS_EXPORT Tree
+{
+ // Much of this Tree was from the excellent tutorial by Julienne Walker
+ // http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx
+
+public:
+
+class Node;
+typedef Node* NodePtr;
+typedef Type* TypePtr;
+
+/** \brief A tree is made up of nodes.
+*/
+class BETAJAEN_CC_CLASS_EXPORT Node
+{
+
+public:
+
+Node(NodeIdentifier id, TypePtr val) : _ID(id), _Val(val)
+{
+ _Children[0] = NULL;
+ _Children[1] = NULL;
+}
+
+void Replace(Node* n)
+{
+ _ID = n->_ID;
+ _Val = n->_Val;
+}
+
+NodeIdentifier _ID;
+TypePtr _Val;
+NodePtr _Children[2];
+
+};
+
+
+/** \brief Tree constructor
+*/
+public: BETAJAEN_CC_INLINE Tree() : _Root(NULL)
+{
+}
+
+
+/** \brief Tree destructor.
+ \note Does not remove or destroy the contents of the tree.
+*/
+public: BETAJAEN_CC_INLINE ~Tree()
+{
+}
+
+
+/** \brief Destroys all the nodes in the tree and deletes all of the values referenced in it.
+*/
+public: BETAJAEN_CC_INLINE void DestroyAll()
+{
+
+ NodePtr iterator = _Root;
+ NodePtr save = 0;
+
+ while (iterator != NULL)
+ {
+ if (iterator->_Children[0] != NULL)
+ {
+ save = iterator->_Children[0];
+ iterator->_Children[0] = save->_Children[1];
+ save->_Children[1] = iterator;
+ }
+ else
+ {
+ save = iterator->_Children[1];
+ delete iterator->_Val;
+ delete iterator;
+ }
+
+ iterator = save;
+ }
+
+}
+
+
+/** \brief Destroys all the nodes in the tree, but not all of the values referenced in it.
+*/
+public: BETAJAEN_CC_INLINE void RemoveAll()
+{
+ NodePtr iterator = _Root;
+ NodePtr save = 0;
+
+ while (iterator != NULL)
+ {
+ if (iterator->_Children[0] != NULL)
+ {
+ save = iterator->_Children[0];
+ iterator->_Children[0] = save->_Children[1];
+ save->_Children[1] = iterator;
+ }
+ else
+ {
+ save = iterator->_Children[1];
+ delete iterator;
+ }
+
+ iterator = save;
+ }
+
+}
+
+
+/** \brief Remove a Node based of an identifier
+*/
+public: BETAJAEN_CC_INLINE void Remove(NodeIdentifier id)
+{
+
+ if (_Root == NULL)
+ return;
+
+ Node head = {0};
+ NodePtr iterator = &head;
+ NodePtr *f = 0, *p = 0;
+ int direction = 1;
+
+ iterator->_Children[1] = _Root;
+
+ //while (iterator =
+
+}
+
+
+
+/** \brief Removes a ranges of nodes based on max. and min. identifiers.
+ \note This operates based on the "operator <" of the TypeIdentifier the class,
+ which defines if the type is in the range or not. Types such as ints, or reals
+ aren't a problem but things like strings or complicated classes may produce
+ strange results.
+*/
+public: BETAJAEN_CC_INLINE void RemoveRange(NodeIdentifier id_min, NodeIdentifier id_max)
+{
+
+
+}
+
+
+/**
+*/
+public: BETAJAEN_CC_INLINE void Destroy(NodeIdentifier id)
+{
+
+}
+
+
+/**
+*/
+public: BETAJAEN_CC_INLINE void DestroyRange(NodeIdentifier id_min, NodeIdentifier id_max)
+{
+
+}
+
+
+/**
+*/
+public: BETAJAEN_CC_INLINE TypePtr Find(NodeIdentifier target)
+{
+ NodePtr iterator = _Root;
+ while (iterator != NULL)
+ {
+ if (iterator->_ID == target)
+ {
+ return iterator->_Val;
+ }
+ else
+ {
+ iterator = iterator->_Children[int(iterator->_ID < target)];
+ }
+ }
+
+ return 0;
+}
+
+
+/**
+*/
+public: BETAJAEN_CC_INLINE bool Insert(NodeIdentifier target, TypePtr val)
+{
+ Node* node = new Node(target, val);
+
+
+ if (_Root == NULL)
+ {
+ _Root = node;
+ return true;
+ }
+ else
+ {
+ Node* iterator = _Root;
+ unsigned int direction;
+
+ for ( ; ; )
+ {
+ direction = iterator->_ID < target;
+
+ if (iterator->_ID == target)
+ {
+ delete node;
+ return false;
+ }
+ else if (iterator->_Children[direction] == NULL)
+ break;
+
+
+ iterator = iterator->_Children[direction];
+ }
+
+ iterator->_Children[direction] = node;
+ }
+
+ return true;
+}
+
+private: NodePtr _Root;
+
+};
+
+BETAJAEN_CC_NAMESPACE_END
+
+//////////////////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_NAMESPACE_START
+
+template <
+ typename IdentifierType,
+ class Type,
+ class AllocatorType
+ >
+class BETAJAEN_CC_CLASS_EXPORT SharedMap
+{
+
+public:
+
+typedef Type* TypePtr;
+typedef Tree<IdentifierType, Type> TreeType;
+typedef TreeType* TreePtr;
+
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE SharedMap()
+{
+ _Tree = new TreeType();
+}
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE ~SharedMap()
+{
+ _Tree->DestroyAll();
+ delete _Tree;
+}
+
+/////////////////////////////////////////////////////////////
+
+BETAJAEN_CC_INLINE TypePt...
[truncated message content] |