# 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::CMOT Class Reference

A composant server, and a traversal container. More...

#include <mot.h>

Inheritance diagram for NL3D::CMOT:

NL3D::CScene List of all members.

Public Methods

 CMOT ()
virtual ~CMOT ()
virtual void release ()
 release all the models and all the traversals created/registred. More...

Traversals Registration .
void addTrav (ITrav *v)
 Register a traversal and add it to the scene. More...

uint getNumTrav () const
 Get the number of registered traversal. More...

ITravgetTrav (uint index) const
 Get a traversal by its index. More...

ITravgetTrav (const NLMISC::CClassId &idTrav) const
 Get a traversal via its class id. More...

Model mgt.
IModelcreateModel (const NLMISC::CClassId &idModel)
 Create a model according to his type id. More...

void deleteModel (IModel *model)
 Delete a model via his pointer. More...

void validateModels ()
 Validate all models and observers. More...


Static Public Methods

Models / Observers registration.
void registerModel (const NLMISC::CClassId &idModel, const NLMISC::CClassId &idModelBase, IModel *(*creator)())
 Register a model, indicating from which he derive. More...

void registerObs (const NLMISC::CClassId &idTrav, const NLMISC::CClassId &idModel, IObs *(*creator)())
 Register an observer, for a given traversal and a given model. More...


Protected Methods

IObsgetModelObs (IModel *m, const NLMISC::CClassId &idTrav) const

Private Methods

IObscreateObs (const ITrav *trav, const NLMISC::CClassId &idModel) const
virtual void dummyForDynamicCast ()

Private Attributes

std::vector< CTravEntryTraversals
std::set< IModel * > Models
IModel_ValidateModelList

Static Private Attributes

std::set< CModelEntryRegModels
std::set< CObsEntryRegObservers

Friends

class IModel

Detailed Description

A composant server, and a traversal container.

Register models and observers globally to the program with static registerModel() and registerObs(). This should be done at the begining of the program.

Before using a CMOT object, Add any traversals you want to support to your scene via addTrav().

Then, you can create any model for this scene with createModel(). The model will be valid for this scene only, since it has only the observers of scene's traversals.

See also:
IModel IObs ITrav
Author:
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 70 of file mot.h.


Constructor & Destructor Documentation

NL3D::CMOT::CMOT  
 

Definition at line 94 of file mot.cpp.

References _ValidateModelList.

NL3D::CMOT::~CMOT   [virtual]
 

Definition at line 99 of file mot.cpp.

References release.


Member Function Documentation

void NL3D::CMOT::addTrav ITrav   v
 

Register a traversal and add it to the scene.

This is done by CSene object, and not globally. Hence, we can have different scene, which doesn't support the same traversals. Undefined result are excepted if you put two or more traversals of the same type in a scene.

Parameters:
v  the traversal to be added. CMOT will never delete it (so the user should do). v->getId() must be the Unique ID of this traversal class.

Reimplemented in NL3D::CScene.

Definition at line 105 of file mot.cpp.

References nlassert, Traversals, and v.

IModel * NL3D::CMOT::createModel const NLMISC::CClassId   idModel
 

Create a model according to his type id.

Model must has been previously registered via registerModel(). This function create all necessary observers, according to the traversals registered with addTrav(), and registerObs(). If a model has no osberver specified for a given traversal Trav, then the father's one will be created. If no ancestor has defined an observer for this traversal, then Trav->createDefaultObs() is taken.

Then, this function attach those observers to the model.

Then, This function attach this model to the Root of all traversals (if not NULL).

Model are deleted with the CMOT::deleteModel() or with CMOT::release() which delete all models ans traversals. NB: Since CMOT own the model, model MUST NOT be used with SmartPtrs (but CRefPtr always work...).

Parameters:
idModel  the Unique Id of the Model
Returns:
a valid model of the required type. NULL, if not found.
See also:
deleteModel()

Definition at line 151 of file mot.cpp.

References createObs, IModel, Models, nlassert, nlstop, RegModels, and Traversals.

Referenced by NL3D::CScene::initCoarseMeshManager, NL3D::CScene::initDefaultRoots, and NL3D::CScene::initGlobalnstanceGroup.

IObs * NL3D::CMOT::createObs const ITrav   trav,
const NLMISC::CClassId   idModel
const [private]
 

Definition at line 245 of file mot.cpp.

References nlassert, RegModels, and RegObservers.

Referenced by createModel.

void NL3D::CMOT::deleteModel IModel   model
 

Delete a model via his pointer.

The model is automatically unlinked from all other model in all traversals, and his observers are automatically destroyed.

Once a model is deleted, all pointer to him should have been deleted.

Definition at line 211 of file mot.cpp.

References Models.

Referenced by NL3D::CScene::deleteInstance, and release.

virtual void NL3D::CMOT::dummyForDynamicCast   [inline, private, virtual]
 

Definition at line 228 of file mot.h.

IObs * NL3D::CMOT::getModelObs IModel   m,
const NLMISC::CClassId   idTrav
const [protected]
 

Definition at line 284 of file mot.cpp.

uint NL3D::CMOT::getNumTrav   const [inline]
 

Get the number of registered traversal.

Definition at line 111 of file mot.h.

References Traversals.

Referenced by NL3D::CScene::release.

ITrav * NL3D::CMOT::getTrav const NLMISC::CClassId   idTrav const
 

Get a traversal via its class id.

Parameters:
idTrav  the Trav Unique Id.
Returns:
the traversal. NULL, if not found.

Definition at line 119 of file mot.cpp.

References Traversals.

ITrav* NL3D::CMOT::getTrav uint    index const [inline]
 

Get a traversal by its index.

Definition at line 113 of file mot.h.

References index, nlassert, and Traversals.

Referenced by NL3D::CScene::initGlobalnstanceGroup, and NL3D::CScene::release.

void NL3D::CMOT::registerModel const NLMISC::CClassId   idModel,
const NLMISC::CClassId   idModelBase,
IModel *(*    creator)()
[static]
 

Register a model, indicating from which he derive.

By default, model's observer are those of his father (idModelBase).

Parameters:
idModel  the Unique Id of the registered model
idModelBase  the Unique Id of the base calss of the registered model
creator  the function which create the registered model.

Definition at line 53 of file mot.cpp.

References nlassert, and RegModels.

void NL3D::CMOT::registerObs const NLMISC::CClassId   idTrav,
const NLMISC::CClassId   idModel,
IObs *(*    creator)()
[static]
 

Register an observer, for a given traversal and a given model.

If an observer was previously specified for the couple Trav/Model, he is replaced.

Parameters:
idTrav  the Unique Id of the observer's traversal
idModel  the Unique Id of the observer's model
creator  the function which create the registered observer.

Definition at line 69 of file mot.cpp.

References nlassert, and RegObservers.

void NL3D::CMOT::release   [virtual]
 

release all the models and all the traversals created/registred.

Remind that Models are deleted, but not Traversals, since CMOT do not own traversals.

Reimplemented in NL3D::CScene.

Definition at line 132 of file mot.cpp.

References _ValidateModelList, deleteModel, Models, and Traversals.

Referenced by ~CMOT.

void NL3D::CMOT::validateModels  
 

Validate all models and observers.

All dirty models are cleaned, and so their observers. This should be called, before any ITrav traversal.

Definition at line 225 of file mot.cpp.

References _ValidateModelList, and IModel.


Friends And Related Function Documentation

friend class IModel [friend]
 

Definition at line 208 of file mot.h.

Referenced by createModel, and validateModels.


Member Data Documentation

IModel* NL3D::CMOT::_ValidateModelList [private]
 

Definition at line 212 of file mot.h.

Referenced by CMOT, release, and validateModels.

std::set<IModel*> NL3D::CMOT::Models [private]
 

Definition at line 211 of file mot.h.

Referenced by createModel, deleteModel, and release.

set< CMOT::CModelEntry > NL3D::CMOT::RegModels [static, private]
 

Definition at line 49 of file mot.cpp.

Referenced by createModel, createObs, and registerModel.

set< CMOT::CObsEntry > NL3D::CMOT::RegObservers [static, private]
 

Definition at line 50 of file mot.cpp.

Referenced by createObs, and registerObs.

std::vector<CTravEntry> NL3D::CMOT::Traversals [private]
 

Definition at line 210 of file mot.h.

Referenced by addTrav, createModel, getNumTrav, getTrav, and release.


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