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

4.7 Using CEL from c++

CEL can (also) be used directly from c++, either for making pure cpp apps or mixing it with the scripting languages supported.

This section has some important notes on specific c++ usage of cel, also refer to API to see all available functionality.

Property Classes

Property Class Factory Initialization

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 ‘pcobject.mesh’ property class):

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

Creating Property Classes

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,
        ... (other property classes)

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

iCelPropertyClass* pc = pl->CreatePropertyClass (entity, "pcobject.mesh");

Getting Property Classes from an entity

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 ‘pcobject.mesh’ 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, "pcobject.mesh",

And to fetch a tagged property class you can use:

csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS_TAG_ENT (entity, iPcMesh,

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 ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html 1.76.