next up previous
Next: Access to the detailed Up: Entities and Events Previous: Minimum output delay

Querying an entity's class

Where a large number of entities share a common structure, it makes sense to store the class specific information once, and let the entities just hold the variables (such as compartment voltages).

An entity's own class can be obtained using:

  EntityClass ec = getClass();

Or any named entity's class is available using a class lookup:

  EntityClass ec = lookupEntityClass("classname");

Particular classes of entities can then provide more information, e.g. an entity class which is specified by a Genesis P-file:-

class GenesisPfileClass extends EntityClass {
  GenesisPfileClass(String pfilename);
  Entity makeEntity( Population p, int i ) { // read in entity from pfile }
  String getPFilename();
}

This can be accessed using:-

  EntityClass ec = lookupEntityClass("GenesisPfileClass");
  GenesisPfileClass gpf = (GenesisPfileClass)ec;
  System.out.println(".p file name is "+ gpf.getPFilename());

Additional methods could be added to store class-specific data structures, initialisation values, etc.



Fred Howell
8/15/1999