OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::KfTransformArrayMemoryManager Class Reference

Implementation to create the KfTransform variables needed by SkeletonTrack SkeletonAnimationDef and. More...

#include <OgreKfTransformArrayMemoryManager.h>

+ Inheritance diagram for Ogre::KfTransformArrayMemoryManager:
+ Collaboration diagram for Ogre::KfTransformArrayMemoryManager:

Public Types

enum  ManagerType {
  NodeType, ObjectDataType, BoneType, UserDefinedType0,
  UserDefinedType1, UserDefinedType2, UserDefinedType3, UserDefinedType4,
  UserDefinedType5, UserDefinedType6, NumStructTypes
}
 
enum  MemoryTypes { KfTransformType = 0, NumMemoryTypes }
 
typedef std::vector< ptrdiff_t > PtrdiffVec
 

Public Member Functions

 KfTransformArrayMemoryManager (uint16 depthLevel, size_t hintMaxNodes, size_t cleanupThreshold=100, size_t maxHardLimit=MAX_MEMORY_SLOTS, RebaseListener *rebaseListener=0)
 Constructor. More...
 
virtual ~KfTransformArrayMemoryManager ()
 
void createNewNode (KfTransform **outTransform)
 Requests memory for a new KfTransofrm (for the Array vectors & matrices) More...
 
void destroy ()
 Destroys the memory ptrs. More...
 
size_t getAllMemory () const
 Gets all memory reserved for this manager. More...
 
size_t getFreeMemory () const
 Gets available memory in bytes. More...
 
size_t getUsedMemory () const
 Gets used memory in bytes (not including waste) More...
 
size_t getWastedMemory () const
 Gets wasted memory (perform a cleanup to fix) More...
 
void initialize ()
 Initializes mMemoryPools. More...
 

Static Public Attributes

static const size_t ElementsMemSize [NumMemoryTypes]
 
static const size_t MAX_MEMORY_SLOTS
 

Protected Types

typedef std::vector< size_t > SlotsVec
 

Protected Member Functions

size_t createNewSlot ()
 Requests memory for a new slot (could be used for SceneNode, Entities, etc.) More...
 
void destroySlot (const char *ptrToFirstElement, uint8 index)
 Releases memory acquired through. More...
 
virtual void slotsRecreated (size_t prevNumSlots)
 Called when mMemoryPools changes, to give a chance derived class to initialize memory to default values. More...
 

Protected Attributes

SlotsVec mAvailableSlots
 
CleanupRoutines const * mCleanupRoutines
 
size_t mCleanupThreshold
 
size_t const * mElementsMemSizes
 
uint16 mLevel
 The hierarchy depth level. More...
 
ManagerType mManagerType
 
size_t mMaxHardLimit
 
size_t mMaxMemory
 
MemoryPoolVec mMemoryPools
 One per memory type. More...
 
RebaseListenermRebaseListener
 
size_t mTotalMemoryMultiplier
 
size_t mUsedMemory
 

Detailed Description

Implementation to create the KfTransform variables needed by SkeletonTrack SkeletonAnimationDef and.

See also
SkeletonTrack
Author
Matias N. Goldberg
Version
1.0

Definition at line 44 of file OgreKfTransformArrayMemoryManager.h.

Member Typedef Documentation

typedef std::vector<ptrdiff_t> Ogre::ArrayMemoryManager::PtrdiffVec
inherited

Definition at line 87 of file OgreArrayMemoryManager.h.

typedef std::vector<size_t> Ogre::ArrayMemoryManager::SlotsVec
protectedinherited

Definition at line 182 of file OgreArrayMemoryManager.h.

Member Enumeration Documentation

Enumerator
NodeType 
ObjectDataType 
BoneType 
UserDefinedType0 
UserDefinedType1 
UserDefinedType2 
UserDefinedType3 
UserDefinedType4 
UserDefinedType5 
UserDefinedType6 
NumStructTypes 

Definition at line 67 of file OgreArrayMemoryManager.h.

Enumerator
KfTransformType 
NumMemoryTypes 

Definition at line 47 of file OgreKfTransformArrayMemoryManager.h.

Constructor & Destructor Documentation

Ogre::KfTransformArrayMemoryManager::KfTransformArrayMemoryManager ( uint16  depthLevel,
size_t  hintMaxNodes,
size_t  cleanupThreshold = 100,
size_t  maxHardLimit = MAX_MEMORY_SLOTS,
RebaseListener rebaseListener = 0 
)

Constructor.

intialize. destroy.

Parameters
elementsMemSizeArray containing the size in bytes of each element type (i.e. NodeElementsMemSize)
cleanupRoutinesArray containing the cleanup function that will be called when performing cleanups. Many pointers can use the flatCleaner and is the fastest. However Array variables (i.e. ArrayVector3) have a layout where flatCleaner won't work correctly because the data is interleaved (rather than flat).
numElementsSizeNumber of entries in elementsMemSize
depthLevelValue only used to pass to the listener. Identifies to which hierarchy depth level this memory manager belongs to.
hintMaxNodesHint on how many SceneNodes we'll be creating.
cleanupThresholdThe threshold at which a cleanup is triggered after too many nodes have been destroyed in a non-LIFO order or without being created again. -1 to disable cleanups.
maxHardLimitMaximum amount of SceneNodes. The manager is not allowed to grow and consume more memory past that limit. MAX_MEMORY_SLOTS for no limit. This is useful when target architecture has much less memory than the dev machine.
Note that if hintMaxNodes < maxHardLimit, the manager may be forced to do temporary allocations (to do the reallocs) thus during a brief perdiod of time it may consume more memory than the established hard limit (up to 2x).
Parameters
rebaseListenerThe listener to be called when cleaning up or growing the memory pool. If null, cleanupThreshold is set to -1 & maxHardLimit will be set to hintMaxNodes
virtual Ogre::KfTransformArrayMemoryManager::~KfTransformArrayMemoryManager ( )
inlinevirtual

Definition at line 60 of file OgreKfTransformArrayMemoryManager.h.

Member Function Documentation

void Ogre::KfTransformArrayMemoryManager::createNewNode ( KfTransform **  outTransform)

Requests memory for a new KfTransofrm (for the Array vectors & matrices)

Remarks
Uses all slots. Deletion is assumed to take place when the memory manager is destroyed; as this manager is run in a controlled environment.
Parameters
outTransformOut: The transform with filled memory pointers
size_t Ogre::ArrayMemoryManager::createNewSlot ( )
protectedinherited

Requests memory for a new slot (could be used for SceneNode, Entities, etc.)

Remarks
Try to create everything static first, then dynamic content. Values are initialized (position to zero, orientation to identity, scale to unit, etc)
Returns
The requested slot, as an offset to the base memory pointers.
void Ogre::ArrayMemoryManager::destroy ( )
inherited

Destroys the memory ptrs.

initialize

Remarks
If there were slots in use, make sure they're no longer used, as their ptrs will become dangling ptrs. We don't assert because this may be valid behavior (i.e. on shutdown)
void Ogre::ArrayMemoryManager::destroySlot ( const char *  ptrToFirstElement,
uint8  index 
)
protectedinherited

Releases memory acquired through.

See also
createNewSlot
Remarks
For optimal results, try to respect LIFO order in the removals
Parameters
ptrToFirstElementPointer to the first element, what's allocated with mMemoryPools[0]
indexThe index, typically mIndex (range [0; ARRAY_PACKED_REALS) )
size_t Ogre::ArrayMemoryManager::getAllMemory ( ) const
inherited

Gets all memory reserved for this manager.

size_t Ogre::ArrayMemoryManager::getFreeMemory ( ) const
inherited

Gets available memory in bytes.

size_t Ogre::ArrayMemoryManager::getUsedMemory ( ) const
inherited

Gets used memory in bytes (not including waste)

size_t Ogre::ArrayMemoryManager::getWastedMemory ( ) const
inherited

Gets wasted memory (perform a cleanup to fix)

void Ogre::ArrayMemoryManager::initialize ( )
inherited

Initializes mMemoryPools.

Once it has been called, destroy() must be called. destroy

Remarks
The destructor won't free the data, if you don't call destroy, memory will leak. Calling initialize twice is possible and won't leak, but will free the previous memory ptrs without calling the registered RebaseListener. So if there were slots in use, their pointers will become dangling. An assert will trigger if this happens.
virtual void Ogre::ArrayMemoryManager::slotsRecreated ( size_t  prevNumSlots)
inlineprotectedvirtualinherited

Called when mMemoryPools changes, to give a chance derived class to initialize memory to default values.

Parameters
prevNumSlotsThe previous value of mMaxMemory before changing mMemoryPools

Reimplemented in Ogre::ObjectDataArrayMemoryManager, Ogre::NodeArrayMemoryManager, and Ogre::BoneArrayMemoryManager.

Definition at line 285 of file OgreArrayMemoryManager.h.

Member Data Documentation

const size_t Ogre::KfTransformArrayMemoryManager::ElementsMemSize[NumMemoryTypes]
static

Definition at line 53 of file OgreKfTransformArrayMemoryManager.h.

SlotsVec Ogre::ArrayMemoryManager::mAvailableSlots
protectedinherited

Definition at line 183 of file OgreArrayMemoryManager.h.

const size_t Ogre::ArrayMemoryManager::MAX_MEMORY_SLOTS
staticinherited

Definition at line 194 of file OgreArrayMemoryManager.h.

CleanupRoutines const* Ogre::ArrayMemoryManager::mCleanupRoutines
protectedinherited

Definition at line 174 of file OgreArrayMemoryManager.h.

size_t Ogre::ArrayMemoryManager::mCleanupThreshold
protectedinherited

Definition at line 181 of file OgreArrayMemoryManager.h.

size_t const* Ogre::ArrayMemoryManager::mElementsMemSizes
protectedinherited

Definition at line 173 of file OgreArrayMemoryManager.h.

uint16 Ogre::ArrayMemoryManager::mLevel
protectedinherited

The hierarchy depth level.

This value is not used by the manager, just passed to the listeners so they can know to which level it belongs

Definition at line 189 of file OgreArrayMemoryManager.h.

ManagerType Ogre::ArrayMemoryManager::mManagerType
protectedinherited

Definition at line 191 of file OgreArrayMemoryManager.h.

size_t Ogre::ArrayMemoryManager::mMaxHardLimit
protectedinherited

Definition at line 180 of file OgreArrayMemoryManager.h.

size_t Ogre::ArrayMemoryManager::mMaxMemory
protectedinherited

Definition at line 179 of file OgreArrayMemoryManager.h.

MemoryPoolVec Ogre::ArrayMemoryManager::mMemoryPools
protectedinherited

One per memory type.

Definition at line 172 of file OgreArrayMemoryManager.h.

RebaseListener* Ogre::ArrayMemoryManager::mRebaseListener
protectedinherited

Definition at line 184 of file OgreArrayMemoryManager.h.

size_t Ogre::ArrayMemoryManager::mTotalMemoryMultiplier
protectedinherited

Definition at line 175 of file OgreArrayMemoryManager.h.

size_t Ogre::ArrayMemoryManager::mUsedMemory
protectedinherited

Definition at line 178 of file OgreArrayMemoryManager.h.


The documentation for this class was generated from the following file: