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

A base model. More...

#include <mot.h>

Inheritance diagram for NL3D::IModel

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

Collaboration graph
[legend]
List of all members.

Notification system

enum  TDirty {
  Dirty = 0,
  Last
}
 The Dirty states. More...

void foul (uint flag)
 The derived model should call foul() in update() or other mutator functions. More...

void validate ()
 check if the model is modified, and if yes, update him and his observers. More...

NLMISC::CBitSet TouchObs
 TouchObs say what part of the model has changed, so Observers can deal with this in Obs::update(). More...


Protected Types

typedef std::map<NLMISC::CClassId,
IObs*> 
CObsMap

Protected Methods

 IModel ()
 Init a model. More...

virtual ~IModel ()
 Destrutor. More...

IObsgetObs (const NLMISC::CClassId &idTrav) const
 Get an observer according to his Traversal Id. NULL, if not found. More...

Notification system specification.
virtual void update ()
 This function must update the model (called by CMOT::validateModels()), and foul() necessary flags. More...

virtual void cleanTouch ()
 This function must clean the Touch information of the model (called by CMOT::validateModels()) It is called AFTER his observers are validated according to him. More...


Protected Attributes

CObsMap Observers
NLMISC::CClassId LastClassId
IObsLastObs

Friends

class  CMOT
class  IObs
class  ITrav

Detailed Description

A base model.

A model is the base structure for any node. The user directly manipulates Models implemented by the deriver.

The deriver must implement a notification system so observers can know if they must update themselves. This is done with a NLMISC::CBitSet TouchObs. Deriver may add Additional flags, or additional info which may serves just as hint, to not compute everything (eg: vertex interval...). In CMOT::validateModels(), for each model, do:

DERIVERS RULES:
  • Possibly Add his own TDirty state (see TDirty and TouchObs), and resize TouchObs (see IModel()).
  • Implement the notification system (see update()/cleanTouch()), as descripted above.
The deriver may choose how to foul() himself: either automatic (on any mutator function), or by user (which may call a foul function).
See also:
CMOT IObs ITrav
Author(s):
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 328 of file mot.h.


Member Typedef Documentation

typedef std::map<NLMISC::CClassId, IObs*> NL3D::IModel::CObsMap [protected]
 

Definition at line 378 of file mot.h.


Member Enumeration Documentation

enum NL3D::IModel::TDirty
 

The Dirty states.

Derived models may add flags with similar enum. The first enum element must begin at CBaseClass::Last (where CBaseClass is the base class), so falg compatibility is maintained.

Enumeration values:
Dirty  
Last  

Reimplemented in NL3D::CTransform.

Definition at line 357 of file mot.h.


Constructor & Destructor Documentation

NL3D::IModel::IModel ( ) [protected]
 

Init a model.

The user must create a Model only with CMOT::createModel(). This is required since, CMOT::createModel() create observers for his traversals and link them to this created model.

The deriver should do a TouchObs.resize(Last), to ensure he resize the BitSet correctly. The dervier should keep/declare ctor and dtor protected, to avoid user error (new and delete).

Definition at line 433 of file mot.cpp.

NL3D::IModel::~IModel ( ) [protected, virtual]
 

Destrutor.

Model's observers are deleted automatically. The user must delete a Model only with CMOT::deleteModel(). This ensure that model validity is correct during the life of CMOT.

The dervier should keep/declare ctor and dtor protected, to avoid user error (new and delete).

Definition at line 440 of file mot.cpp.


Member Function Documentation

void NL3D::IModel::cleanTouch ( ) [inline, protected, virtual]
 

This function must clean the Touch information of the model (called by CMOT::validateModels()) It is called AFTER his observers are validated according to him.

This function Must :

  • call BaseClass::cleanTouch() (eg: IModel::cleanTouch()).
  • maybe clean other Touch information (vertex intervals...).
NB: Touch bits are leared in validateModels().

The default behavior is just to clear flags of TouchObs, which may be sufficient, except if you have special touch information (eg: a vertex interval).

Definition at line 421 of file mot.h.

void NL3D::IModel::foul ( uint flag ) [inline]
 

The derived model should call foul() in update() or other mutator functions.

Definition at line 365 of file mot.h.

IObs * NL3D::IModel::getObs ( const NLMISC::CClassId & idTrav ) const [protected]
 

Get an observer according to his Traversal Id. NULL, if not found.

Definition at line 450 of file mot.cpp.

void NL3D::IModel::update ( ) [inline, protected, virtual]
 

This function must update the model (called by CMOT::validateModels()), and foul() necessary flags.

Must :

  • call BaseClass::update() (eg: IModel::update()).
  • test if something is different (eg: animation modification). update Model information (eg compute new Matrix).
  • foul() good bits. (eg: foul(TransformDirty)).
  • maybe set other Touch information (vertex intervals...).
The default behavior is to do nothing.

NB: Touch information is reseted after observers validation in CMOT::validateModels(), using Model::cleanTouch()

Reimplemented in NL3D::CCamera, and NL3D::CTransform.

Definition at line 405 of file mot.h.

void NL3D::IModel::validate ( )
 

check if the model is modified, and if yes, update him and his observers.

Definition at line 469 of file mot.cpp.


Friends And Related Function Documentation

class CMOT [friend]
 

Definition at line 375 of file mot.h.

class IObs [friend]
 

Definition at line 376 of file mot.h.

class ITrav [friend]
 

Definition at line 377 of file mot.h.


Member Data Documentation

NLMISC::CClassId NL3D::IModel::LastClassId [mutable, protected]
 

Definition at line 382 of file mot.h.

IObs * NL3D::IModel::LastObs [mutable, protected]
 

Definition at line 383 of file mot.h.

CObsMap NL3D::IModel::Observers [protected]
 

Definition at line 379 of file mot.h.

NLMISC::CBitSet NL3D::IModel::TouchObs
 

TouchObs say what part of the model has changed, so Observers can deal with this in Obs::update().

Definition at line 363 of file mot.h.


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