# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CShapeBank Class Reference

A CShapeBank handle all the instance of the shapes and the cache management system. More...

#include <shape_bank.h>

Collaboration diagram for NL3D::CShapeBank:

Collaboration graph
[legend]
List of all members.

Shape/Instances.

typedef NLMISC::CSmartPtr<
IShape
PShape
typedef std::map<std::string,
PShape
TShapeMap
typedef std::multimap<std::string,
IShape*> 
TWaitingShapesMMap
TShapeMap ShapeMap
TWaitingShapesMMap WaitingShapes
CAsyncFileManager asyncFileManager
IDriver_pDriver

Shape/Caches.

typedef std::map<std::string,
std::string> 
TShapeCacheNameMap
typedef std::map<std::string,
CShapeCache
TShapeCacheMap
typedef std::map<IShape*,CShapeInfoTShapeInfoMap
std::string* getShapeNameFromShapePtr (IShape* pShp)
IShapegetShapePtrFromShapeName (const std::string &pShpName)
CShapeCachegetShapeCachePtrFromShapePtr (IShape* pShp)
CShapeCachegetShapeCachePtrFromShapeCacheName (const std::string &shapeCacheName)
CShapeCachegetShapeCachePtrFromShapeName (const std::string &shapeName)
void checkShapeCache (CShapeCache* pShpCache)
void updateShapeInfo (IShape* pShp, CShapeCache* pShpCache)
TShapeCacheNameMap ShapeNameToShapeCacheName
TShapeCacheMap ShapeCacheNameToShapeCache
TShapeInfoMap ShapePtrToShapeInfo

Public Methods

 CShapeBank ()
 ~CShapeBank ()
Instance Management
IShapeaddRef (const std::string &shapeName)
 Add a reference to a shape and return the instance created. More...

void release (IShape* pShp)
 Release a reference to a shape by its instance. More...

bool isPresent (const std::string &shapeName)
 Return TRUE if the shape is present in the bank. Process the waiting shapes. More...

void load (const std::string &shapeName)
 Load the corresponding file from disk and add it to the bank. More...

void loadAsync (const std::string &shapeName, IDriver *pDriver)
 Load the corresponding file from disk asynchronously and add it to the bank. More...

void add (const std::string &shapeName, IShape* shape)
 Add directly a shape to the bank. If the shape name is already used do nothing. More...

Shape cache management
void addShapeCache (const std::string &shapeCacheName)
 Add a new ShapeCache. If already exist do nothing. More...

void removeShapeCache (const std::string &shapeCacheName)
 Remove a ShapeCache. More...

void reset ()
 Remove all ShapeCache and suppress all links (even the link to the default cache are removed). More...

void setShapeCacheSize (const std::string &shapeCacheName, sint32 maxSize)
 Set the shapeCache shapeCacheName the new size.(delete shapes if maxsize<shapeCacheSize). More...

void linkShapeToShapeCache (const std::string &shapeName, const std::string &shapeCacheName)
 Link a shape to a ShapeCache. The ShapeCache must exist and must not contains the shape. More...


Detailed Description

A CShapeBank handle all the instance of the shapes and the cache management system.

There is a default cache. If the shape is not linked explicitly to any cache it is linked to the default cache. The comportement of this cache is to not do any cache. When the release is called on the last reference to a shape linked to this cache, the shape is removed instantly. This is the behavior of all newly created cache before we call the setShapeCacheSize method.

Author(s):
Matthieu Besson , Nevrax France
Date:
2000

Definition at line 55 of file shape_bank.h.


Member Typedef Documentation

typedef NLMISC::CSmartPtr<IShape> NL3D::CShapeBank::PShape [private]
 

Definition at line 114 of file shape_bank.h.

typedef std::map<std::string,CShapeCache> NL3D::CShapeBank::TShapeCacheMap [private]
 

Definition at line 152 of file shape_bank.h.

typedef std::map<std::string,std::string> NL3D::CShapeBank::TShapeCacheNameMap [private]
 

Definition at line 151 of file shape_bank.h.

typedef std::map<IShape*,CShapeInfo> NL3D::CShapeBank::TShapeInfoMap [private]
 

Definition at line 153 of file shape_bank.h.

typedef std::map<std::string, PShape> NL3D::CShapeBank::TShapeMap [private]
 

Definition at line 115 of file shape_bank.h.

typedef std::multimap<std::string,IShape*> NL3D::CShapeBank::TWaitingShapesMMap [private]
 

Definition at line 118 of file shape_bank.h.


Constructor & Destructor Documentation

NL3D::CShapeBank::CShapeBank ( )
 

Definition at line 39 of file shape_bank.cpp.

NL3D::CShapeBank::~CShapeBank ( )
 

Definition at line 47 of file shape_bank.cpp.


Member Function Documentation

void NL3D::CShapeBank::add ( const std::string & shapeName,
IShape * pShp )
 

Add directly a shape to the bank. If the shape name is already used do nothing.

Definition at line 200 of file shape_bank.cpp.

IShape * NL3D::CShapeBank::addRef ( const std::string & shapeName )
 

Add a reference to a shape and return the instance created.

Definition at line 53 of file shape_bank.cpp.

void NL3D::CShapeBank::addShapeCache ( const std::string & shapeCacheName )
 

Add a new ShapeCache. If already exist do nothing.

Definition at line 233 of file shape_bank.cpp.

void NL3D::CShapeBank::checkShapeCache ( CShapeCache * pShpCache ) [private]
 

Definition at line 406 of file shape_bank.cpp.

CShapeBank::CShapeCache * NL3D::CShapeBank::getShapeCachePtrFromShapeCacheName ( const std::string & shapeCacheName ) [private]
 

Definition at line 370 of file shape_bank.cpp.

CShapeBank::CShapeCache * NL3D::CShapeBank::getShapeCachePtrFromShapeName ( const std::string & shapeName ) [private]
 

Definition at line 394 of file shape_bank.cpp.

CShapeBank::CShapeCache * NL3D::CShapeBank::getShapeCachePtrFromShapePtr ( IShape * pShp ) [private]
 

Definition at line 346 of file shape_bank.cpp.

string * NL3D::CShapeBank::getShapeNameFromShapePtr ( IShape * pShp ) [private]
 

Definition at line 382 of file shape_bank.cpp.

IShape * NL3D::CShapeBank::getShapePtrFromShapeName ( const std::string & pShpName ) [private]
 

Definition at line 358 of file shape_bank.cpp.

bool NL3D::CShapeBank::isPresent ( const std::string & shapeName )
 

Return TRUE if the shape is present in the bank. Process the waiting shapes.

Definition at line 117 of file shape_bank.cpp.

void NL3D::CShapeBank::linkShapeToShapeCache ( const std::string & shapeName,
const std::string & shapeCacheName )
 

Link a shape to a ShapeCache. The ShapeCache must exist and must not contains the shape.

Definition at line 305 of file shape_bank.cpp.

void NL3D::CShapeBank::load ( const std::string & shapeName )
 

Load the corresponding file from disk and add it to the bank.

Definition at line 166 of file shape_bank.cpp.

void NL3D::CShapeBank::loadAsync ( const std::string & shapeName,
IDriver * pDriver )
 

Load the corresponding file from disk asynchronously and add it to the bank.

The driver passed to this function is used to know if we have to load the textures.

Definition at line 190 of file shape_bank.cpp.

void NL3D::CShapeBank::release ( IShape * pShp )
 

Release a reference to a shape by its instance.

If the shape has no more reference it is added to its own shape cache. When the shape cache is full the last entry is deleted.

Definition at line 87 of file shape_bank.cpp.

void NL3D::CShapeBank::removeShapeCache ( const std::string & shapeCacheName )
 

Remove a ShapeCache.

All shapes in the shape cache are deleted. All links are redirected to the default ShapeCache

Definition at line 245 of file shape_bank.cpp.

void NL3D::CShapeBank::reset ( void )
 

Remove all ShapeCache and suppress all links (even the link to the default cache are removed).

Definition at line 272 of file shape_bank.cpp.

void NL3D::CShapeBank::setShapeCacheSize ( const std::string & shapeCacheName,
sint32 maxSize )
 

Set the shapeCache shapeCacheName the new size.(delete shapes if maxsize<shapeCacheSize).

Definition at line 293 of file shape_bank.cpp.

void NL3D::CShapeBank::updateShapeInfo ( IShape * pShp,
CShapeCache * pShpCache ) [private]
 

Definition at line 424 of file shape_bank.cpp.


Member Data Documentation

TShapeCacheMap NL3D::CShapeBank::ShapeCacheNameToShapeCache [private]
 

Definition at line 155 of file shape_bank.h.

TShapeMap NL3D::CShapeBank::ShapeMap [private]
 

Definition at line 116 of file shape_bank.h.

TShapeCacheNameMap NL3D::CShapeBank::ShapeNameToShapeCacheName [private]
 

Definition at line 154 of file shape_bank.h.

TShapeInfoMap NL3D::CShapeBank::ShapePtrToShapeInfo [private]
 

Definition at line 156 of file shape_bank.h.

TWaitingShapesMMap NL3D::CShapeBank::WaitingShapes [private]
 

Definition at line 119 of file shape_bank.h.

IDriver * NL3D::CShapeBank::_pDriver [private]
 

Definition at line 122 of file shape_bank.h.

CAsyncFileManager NL3D::CShapeBank::asyncFileManager [private]
 

Definition at line 121 of file shape_bank.h.


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