Store and retrieve objects in the database

The first use case for the C++ EXPRESS API was to implement converters that convert native CAD/CAE data to and from the ISO 10303-209 (AP209) standard. In this use case data are read from native CAD/CAE files into the memory and translated to an AP209 model in memory. Finally the objects in memory are written to an EDM model on the database in one operation. Two methods for database storage and retrieval are implemented.

  1. Model.writeAllObjectsToDatabase – writes all objects in memory that belong to the Model object into the database model. The database model must be opened for write.
  2. Model.readAllObjectsToMemory – reads all objects in an open database model into memory.

Before reading objects from a database model into memory, filters may be applied by means of the method defineObjectSet. The filter defined by defineObjectSet excludes all but one object type and its possible subtype.
// define an object set of product and all subtypes of product
myModel.defineObjectSet(et_product, 12, true);
myModel.readAllObjectsToMemory(&ma);
SdaiAggr productsList = (SdaiAggr)myModel.getObjectSet(et_product);
entityType productType, ct;
// create a iterator for traversing all products read into memory:
Model *myModelp = &myModel;
Iterator<product*, entityType> products(productsList, myModelp);
for (product *p = products.first(&productType); p; p = products.next(&productType)) {
// handle the product
}
In case one wants to make use of a filter that includes several object types and their possible subtypes, the readObjectClassesToMemory method may be applied. It reads the objects into memory in one shot as well. It accepts an array of object class enumerations as input.
readObjectClassesToMemory(int *objectClasses)
Another variant of this method accepts an advanced filter. Its usage is explained in dbinterface.h .