# 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

Inheritance graph
[legend]
Collaboration diagram for NL3D::CMOT:

Collaboration graph
[legend]
List of all members.

Public Methods

 CMOT ()
 ~CMOT ()
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...

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

Private Attributes

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

Static Private Attributes

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

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(s):
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 159 of file mot.h.


Constructor & Destructor Documentation

NL3D::CMOT::CMOT ( )
 

Definition at line 92 of file mot.cpp.

NL3D::CMOT::~CMOT ( )
 

Definition at line 96 of file mot.cpp.


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 102 of file mot.cpp.

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 145 of file mot.cpp.

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

Definition at line 227 of file mot.cpp.

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 195 of file mot.cpp.

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

Definition at line 266 of file mot.cpp.

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 115 of file mot.cpp.

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 51 of file mot.cpp.

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 67 of file mot.cpp.

void NL3D::CMOT::release ( void )
 

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 128 of file mot.cpp.

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 209 of file mot.cpp.


Member Data Documentation

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

Definition at line 289 of file mot.h.

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

Definition at line 47 of file mot.cpp.

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

Definition at line 48 of file mot.cpp.

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

Definition at line 288 of file mot.h.


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