[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.3 Property Classes

Here in this chapter the various property classes are documented.

### Using a Property Class in General

Here are a few generic guidelines on using property classes. Before you can use any property class you must first ensure that the property class factory for that property class is loaded and registered with the physical layer. To do that you need the Factory ID for the property class which is documented in every property class documentation. Then you add the following line to the initialization of your application (example for ``pcmesh'` property class):

    if (!pl->LoadPropertyClassFactory ("cel.pcfactory.mesh"))
      return false;

To use the API from that property class you must load the header (also given with every property class documentation). There are two ways to create a property class for an entity. The first way creates them together with the entity itself:

    csRef<iCelEntity> entity = pl->CreateEntity (entname, behaviourlayer,
    	behavename,
    	"pcmesh",
    	... (other property classes)
    	CEL_PROPCLASS_END);

The second way creates a property class on an entity that is already created:

    iCelPropertyClass* pc = pl->CreatePropertyClass (entity, "pcmesh");

To request a property class from an entity you can use:

    csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS_ENT (entity, iPcMesh);

### Tagged Property Classes

Normally an entity only has one instance of a given property class type (i.e. only one ``pcmesh'` maximum). Sometimes it is useful to be able to add multiple property class instances of the same type. To distinguish between the different instances you can use tags. Here is how you can create a tagged property class for an entity:

    iCelPropertyClass* pc = pl->CreateTaggedPropertyClass (entity, "pcmesh",
    	"main_mesh");

And to fetch a tagged property class you can use:

    csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS_TAG_ENT (entity, iPcMesh,
    	"main_mesh");

Note that there is the concept of a default property class for a given type. Usually the default property class is the one that has no tag (tag equal to 0). So when you call `CEL_QUERY_PROPCLASS_ENT` it will first try to look for the property class with tag equal to 0. If all property classes have a tag then it will return a random one.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.