ScEng::Block Class Reference

#include <block.h>

Inheritance diagram for ScEng::Block:

ScEng::BlockVector ScEng::Controller ScEng::Data ScEng::DataTable ScEng::MainScene ScEng::Material ScEng::Node ScEng::NodeTransform ScEng::Object ScEng::ToolBlock List of all members.

Public Types

enum  PROPERTIES {
  SCENE = (1<<0), NODE = (1<<1), OBJECT = (1<<2), MODIFIER = (1<<3),
  MATERIAL = (1<<4), TEXTURE = (1<<5), PLACE_TEXTURE = (1<<6), CONTROL = (1<<7),
  DATATABLE = (1<<8), DATA = (1<<9), BLOCKVECTOR = (1<<10), TOOL = (1<<11)
}

Public Member Functions

 Block ()
virtual std::string GetClassName ()=0
 Virtual function.
virtual BlockType GetBlockType ()=0
 Virtual function.
virtual int NumDependencies ()=0
 Returns the number of dependencies of this block.
virtual void SetDependency (int i, Block *se_block)=0
virtual BlockGetDependency (int i)=0
virtual std::string GetDependencyName (int i)=0
virtual unsigned int GetDependencyType (int i)
void MakeDependencyByID (int id, Block *dependency)
void DeleteDependency (int id)
void DeleteAllDependencies ()
 Delete all dependencies.
void TestDependant (Block *dependant, int &res)
bool OkToSetAsDependency (Block *other)
bool MakeDependant (int id, Block *dependant)
bool EraseDependantFromTable (Block *dependant)
void RemoveFromDependants ()
void AddBlockListener (BlockListener *listener)
void RemoveBlockListener (BlockListener *listener)
void DeleteThisBlock (bool delete_this)
virtual int GetNumDataTables ()
 Returns the number of data tables used by this block.
virtual DataTableGetDataTable (int i=0)
 Returns the i_th data table.
virtual void SetDataTable (DataTable *d, int i=0)
 Sets the i_th data table.
virtual void UpdateDataTable (int i=0)
virtual BlockClone ()=0
 Creates a duplicate of this block and all its depenedencies.
int SaveBlockInfo (SceneSave *scene_save)
 Saves the block info.
virtual int Save (SceneSave *scene_save)=0
 Virtual function.
int SaveBlockDependencies (SceneSave *scene_save)
 Save the info for the dependencies.
virtual int Load (SceneLoad *scene_load)=0
 Virtual function.
int LoadBlockDependencies (SceneLoad *scene_load, BlockLoadData *scblock_load_data)
 Loads the inf for the dependencies.
virtual int PostLoad ()
virtual void DeleteThis ()=0
virtual void ActionBegin (int time, int action)
virtual void ActionEnd (int time, int action)
virtual void Update (int time)
virtual void DependancyChanged (Block *dependancy, unsigned int message=0, unsigned int parameters=0)
void ReportChange (unsigned int message=0, unsigned int parameters=0)

Public Attributes

int block_id
 The id for this block.
int saved
 Determines if the block has been saved or not.
int properties
 The properties for this block.
std::list< Block * > dependants
int gui_link

Detailed Description

Block class A Block can have other blocks pointing to it (dependants) and the block can point to other blocks (dependencies)


Member Enumeration Documentation

enum ScEng::Block::PROPERTIES

Enumerator:
SCENE  This block is a main scene
NODE  This block is a node
OBJECT  This block is an object
MODIFIER  This block is a modifier
MATERIAL  This block is a material
TEXTURE  This block is a texture
PLACE_TEXTURE  This block is a place texture
CONTROL  This block is an animation controller
DATATABLE  This block is a Data table
DATA  This block is a Data element
BLOCKVECTOR  This block is a BlockVector
TOOL  This block is ToolBlock


Constructor & Destructor Documentation

ScEng::Block::Block (  ) 

Contructor Sets the block_id to -1, and saved and flags to 0


Member Function Documentation

virtual void ScEng::Block::SetDependency ( int  i,
Block se_block 
) [pure virtual]

Sets the specified dependency to the block.

Parameters:
id The id of this dependency to set
se_block The block that will be the new dependency

Implemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NodeTransform, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

virtual Block* ScEng::Block::GetDependency ( int  i  )  [pure virtual]

Returns the i-th dependency of this block.

Returns:
The dependency block

Implemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NodeTransform, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

virtual std::string ScEng::Block::GetDependencyName ( int  i  )  [pure virtual]

Returns the name of the i-th dependency of this block.

Returns:
The name of the dependency.

Implemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NodeTransform, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

unsigned int ScEng::Block::GetDependencyType ( int  i  )  [virtual]

Returns the type of the i-th dependency of this block.

Returns:
The type of the dependency. This is the type defined in BlockType::type.
See also:
BlockType

Reimplemented in ScEng::BitmapTexture, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::NodeMaterials, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::StandardMaterial, ScEng::TextureLayers, and ScEng::WoodTexture.

void ScEng::Block::MakeDependencyByID ( int  id,
Block dependency 
)

Makes a dependency to a specified block Creates a dependency between this scene_block (From) an the dependency block The dependency->MakeDependant is called to store the from Block in the vector of blocks that reference the dependency Block

Parameters:
id the id where the block will be dependency
dependency the block to be dependency

void ScEng::Block::DeleteDependency ( int  id  ) 

Removes this block from the dependants table in the dependency, and sets it to NULL.

Parameters:
id the dependency to be deleted

void ScEng::Block::TestDependant ( Block dependant,
int &  res 
)

Test a dependency Before creating a dependency between two Blocks, we need to be sure that this is a valid dependency to avoid cyclic dependencies. ie. that the child node is not trying to be a parent node of its own parent

Parameters:
dependant the block to be tested
res in this variable will be stored the result of the test. If is 0 is a valid dependency

bool ScEng::Block::OkToSetAsDependency ( Block other  ) 

This method tests the other block to find if it can be set as a dependency of this block.

Parameters:
other The block that would be set as dependency of this block.
See also:
TestDependant

bool ScEng::Block::MakeDependant ( int  id,
Block dependant 
)

Makes a dependency in

Parameters:
id the id for this dependency
dependant the block to be dependency in
Returns:
True if the block was dependency, if not return False

bool ScEng::Block::EraseDependantFromTable ( Block dependant  ) 

Looks in the dependants table for this dependant block and if it finds it then it erases this block from the dependants table. If after erasing the dependant from the table the dependants table is empty, then this Block is deleted using DeleteThis.

Parameters:
dependant the dependant block to be erased from the table
Returns:
Returns true if this block was deleted by this method.

void ScEng::Block::RemoveFromDependants (  ) 

Searches in the dependants' dependencies for this block and sets the dependency that matches this block in the dependant as NULL.

void ScEng::Block::AddBlockListener ( BlockListener listener  ) 

Adds a new BlockListener to this block's listeners list.

Parameters:
listener The new BlockListener. All messages that this block reports are sent to this block listener

void ScEng::Block::RemoveBlockListener ( BlockListener listener  ) 

Removes the specified BlockListener from this listeners list.

Parameters:
listener The BlockListener that will be removed.

void ScEng::Block::DeleteThisBlock ( bool  delete_this  ) 

Delete all the dependencies of this block and removes this block from all its dependants.

Parameters:
delete_this if true, calls DeleteThis for this block so it is deleted. Don't set to true if somebody else deletes this block, like for example if this block was not created with new.

void ScEng::Block::UpdateDataTable ( int  i = 0  )  [virtual]

Updates the data table. This fills the name variables in the data table so it can be used properly. This function is called after a scene is loaded and each block must call it after its data_table has been built or set.

Reimplemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::NodeMaterials, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

int ScEng::Block::PostLoad (  )  [virtual]

This virtual method is called after the scene has been loaded and the dependencies has been set. This method allows the blocks to perform any action when the scene is completely valid

Reimplemented in ScEng::Node.

virtual void ScEng::Block::DeleteThis (  )  [pure virtual]

This method has to be implemented in all blocks as delete this; This method is called by the garbage collector when this block looses all its dependants. Since SceneEngine is an object oriented sdk and virtual destructors are not declared, then this method is called in many places in SceneEngine to make sure that the right destructor is called. Don't delete any dependencies in this method or in the destructor. Dependencies are deleted by the DAG methods in the Block class. If you delete a dependency, then the DAG can try to delete it again and crash, or you can leave a lot of dependencies of the dependency you deleted without a link into the DAG, and they will become memory leaks.

Implemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NodeTransform, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

void ScEng::Block::ActionBegin ( int  time,
int  action 
) [virtual]

Informs the block that an action will begin

Parameters:
time the time at which the action begins. more details about the action, for example, it can be a RENDER_ACTION, or a SAVE_ACTION.

Reimplemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

void ScEng::Block::ActionEnd ( int  time,
int  action 
) [virtual]

Informs the block that an action will end.

Parameters:
time the time at which the action ends. more details about the action, for example, it can be a RENDER_ACTION, or a SAVE_ACTION.

Reimplemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

void ScEng::Block::Update ( int  time  )  [virtual]

Informs the block that it needs to update its data. For example, texture and material blocks usually move all their animated parameters from the data_table to int or float variables. This is specially useful when rendering, so there is no need to interpolate a data_value every time.

Parameters:
time the time at which the block needs to update its data.

Reimplemented in ScEng::BitmapTexture, ScEng::BlockVector, ScEng::Camera, ScEng::FloatBezierController, ScEng::PRS3Controller, ScEng::Point3FController, ScEng::DataBool, ScEng::DataColor, ScEng::DataFloat, ScEng::DataInt, ScEng::DataPoint3F, ScEng::DataTable, ScEng::SourceLight, ScEng::MainScene, ScEng::MarbleTexture, ScEng::MaskTexture, ScEng::MixTexture, ScEng::Node, ScEng::NodeMaterials, ScEng::NoiseTexture, ScEng::Place2DTexture, ScEng::Place3DTexture, ScEng::PolyLineObject, ScEng::PolyMeshObject, ScEng::BoxObject, ScEng::SimbionTexture, ScEng::Bezier3DSplineObject, ScEng::StandardMaterial, ScEng::TextureLayers, ScEng::TriMeshObject, and ScEng::WoodTexture.

void ScEng::Block::DependancyChanged ( Block dependancy,
unsigned int  message = 0,
unsigned int  parameters = 0 
) [virtual]

A block receives this message when one of its dependencies has changed.

Parameters:
dependency The dependancy that changed
message A message about the change

Reimplemented in ScEng::BlockVector, ScEng::Controller, ScEng::Data, ScEng::DataTable, ScEng::MainScene, ScEng::Material, ScEng::Node, ScEng::Object, and ScEng::BoxObject.

void ScEng::Block::ReportChange ( unsigned int  message = 0,
unsigned int  parameters = 0 
)

This function is used to notify all dependants that this block has changed.

Parameters:
message The message that is being sent
parameters More parameters for this message.


Member Data Documentation

std::list<Block*> ScEng::Block::dependants

This list holds all the dependant pointers. When a block starts pointing this block the dependants vector is updated, and when the link is broken, the pointer is removed. When this table size gets to 0, the block is deleted. (smart pointers -> smart blocks).

int ScEng::Block::gui_link

This variable can be used to link the block to the user interface or any other table to avoid look ups through all the scene blocks.


The documentation for this class was generated from the following files:
Generated on Thu Sep 6 10:49:21 2007 for SceneEngine by  doxygen 1.5.1-p1