![]() |
FemProcess
The GeMA Fem Process Plugin
|
A simple factory used to register material type names, their numeric indices and their instance functions. Several names can be tied to the same function. More...
#include <gmpFemPhysicsCommonMaterial.h>
Public Types | |
typedef GmpFemPhysicsCommonMaterial *(* | MaterialObjCreator) (GmSimulationData *simulation, int typeIndex, QString typeName, const GmLogCategory &logger) |
Type for the instance function. | |
Public Member Functions | |
void | registerMaterial (int typeIndex, QString typeName, MaterialObjCreator instanceFunction, bool defaultMaterial=false) |
Register the instance function for a material type. Assumes that typeName hasn't been registered before and also that typeIndex hasn't been used before. More... | |
GmpFemPhysicsCommonMaterial * | instance (GmSimulationData *simulation, QString typeName, const GmLogCategory &logger) const |
Creates a new material object for the specified type. If the type is unknown, returns NULL. | |
int | numMaterialTypes () const |
Returns the number of materials registered in the factory. Equal to the greatest index number + 1 if checkTypeMap() returned ok. | |
QString | defaultMaterialType () const |
Returns the name of the default material type. | |
int | typeIndex (QString typeName) const |
Returns the type index associated to the given type name or -1 if not found. | |
bool | checkTypeMap () const |
Check that the map contents is consistent: The set of type indices should be an ordered set begining in 0 and ending with the number of map entries - 1. | |
Private Attributes | |
QMap< QString, QPair< int, MaterialObjCreator > > | _factoryMap |
The map associating material names with their instance functions / index numbers. | |
QString | _defTypeName |
The default material name. | |
A simple factory used to register material type names, their numeric indices and their instance functions. Several names can be tied to the same function.
In order to allow the physics to index materials through their indices, the set of registered materials should form a continuous numeric set. This can be checked by the checkTypeMap() function.
void GmpFemPhysicsCommonMaterialFactory::registerMaterial | ( | int | typeIndex, |
QString | typeName, | ||
MaterialObjCreator | instanceFunction, | ||
bool | defaultMaterial = false |
||
) |
Register the instance function for a material type. Assumes that typeName hasn't been registered before and also that typeIndex hasn't been used before.
If defaultMaterial is set to true, this material type will become the new default material. At least one material should be labeled as the default material.