Database, Repository, Model, Schema and EDMI

A set of populated EXPRESS objects in an EDM database is called a model. EDM models are grouped together in repositories and a database consists of several repositories. To operate on an EDM database the EXPRESS Data Manager™ offers a rich library of functions called EDMI, that is described in EDMassist.
http://edmserver.epmtech.jotne.com/EDMAssist/WebHelp/EDMAssist.htm.
The C++ EXPRESS API is designed to store objects in and retrieve objects from an EXPRESS Data Manager™ (EDM) database. In order to ease the storage and retrieval of C++ objects to/from the EDM database, the C++ EXPRESS API have C++ objects representing Database, Repository and Model. See the following example:
CMemoryAllocator ma(1000000);
// Database object is declared
Database db("database\directory", "database_name", "password");
// Database is opened by implicite call to EDMI
db.open();
// Repositor is declared
Repository cRepository(&db, "DataRepository");
// myModel is declared with reference to the underlying schema.
// The memory allocator assignes memory to the objects in the model.
// my_Schema is a reference to the generated C++ representation
// of the underlying EXPRESS schema. There are naming conventions for the // generated EXPRESS schema object, and the declaration shall be like:
// <name space>_Schema my_Schema = <name_space><schema name>_SchemaObject,
// where <name_space> is given when you generate C++ classes by means of
// the EDMSupervisor™ .
E.g.
ap209_Schema my_Schema = ap209_multidisciplinary_analysis_and_design_mim_lf_SchemaObject;
Model myModel(&cRepository, &ma, &my_Schema);
// nyModel is opened for read and write
myModel.open("myModel", sdaiRW);

Create objects in memory

In the C++ EXPRESS API objects are created with overloading of the new operator. Each new object must belong to a Model, for this reason the new operator takes a reference to a Model object as a parameter. The attributes of new objects are stored in memory by the generated put methods without copying the values to the database. All created objects with their attributes can be written to the database model by means of the method
Model::writeAllObjectsToDatabase();
To create objects in memory the application source must contain the following declaration:
using namespace OIM;
Figure 1 shows a sketch where three objects of the AP209 entities product, product_definition_formation and product_definition are linked together to form the data structure for an AP209 product. The following C++ code sequence exemplifies how the objects are created, how the attributes of the objects are set and how the objects are linked together.
#define newObject(className) new(m)className(m)
Model *m = &myModel;
// Create product object and set its attributes
product* p1 = newObject(product);
p1->put_id("Aircraft 1");
p1->put_name("Aircraft propeller map");
p1->put_description("Aircraft 1");
// Create product_definition_formation object
product_definition_formation* pdf = newObject(product_definition_formation);
pdf->put_description("Aircraft with two front doors and wheel landing gear");
pdf->put_id("1");
// Link product_definition_formation object to product object
pdf->put_of_product(p1);
// Create product_definition object
product_definition* pd = newObject(product_definition);
pd->put_id("pd-1");
pd->put_description("description");
// Link product_definition object to
// product_definition_formation object
pd->put_formation(pdf);
// and update the database
m->writeAllObjectsToDatabase();

Figure 1 Diagram of a small AP209 instantiation (source: AP209ed2 recommended practices)

Create objects in database directly

With the Pre-processor Directive USE_EDMI defined, C++ objects are created directly in the database. If you use the constructor without database object id (InstanceId), an object will be created in the database. If you use the other constructor with database object id, the C++ object will be a reference to an already existing object in the database. To create objects in the database directly the application source must contain the following declaration:
using namespace cppd;
The example in the previous section will then look like:
Model *m;
// Create product object and set its attributes
product p(m);
p.put_id("Aircraft 1");
p.put_name("Aircraft propeller map");
p.put_description("Aircraft 1");
// Create product_definition_formation object
product_definition_formation pdf(m);
pdf.put_description("Aircraft with two front doors and wheel landing gear");
pdf.put_id("1");
// Link product_definition_formation object to product object
Pdf.put_of_product(&p);
// Create product_definition object
product_definition pd(m);
pd.put_id("pd-1");
pd.put_description("description");