The following Fictional_Characters, Friend_Table, and Enemy_Table Object Classes and Relationships tables list the object classes and objects created by the example code in this section.
Story_Star (char) | Birthday (char) | Age (short) | Friends_of (link) | Enemies_of (link) | Do_This (method) |
---|---|---|---|---|---|
Cinderella | Once upon a time | 19 | Cinderella | Cinderella | echo Cleans House |
Snow White | Once upon a time | 18 | Snow White | Snow White | echo Cleans House |
Friend_of (char) | Friend (char) |
---|---|
Cinderella | Fairy Godmother |
Cinderella | mice |
Snow White | Sneezy |
Snow White | Sleepy |
Cinderella | Prince |
Snow White | Happy |
Enemy_of (char) | Enemy (char) |
---|---|
Cinderella | midnight |
Cinderella | Mean Stepmother |
Snow White | Mean Stepmother |
The following example code in the MyObjects.cre file creates three object classes when used as an input file with the odmcreate command:
* MyObjects.cre * An input file for ODM create utilities. * Creates three object classes: * Friend_Table * Enemy_Table * Fictional_Characters
class Friend_Table { char Friend_of[20]; char Friend[20]; };
class Enemy_Table { char Enemy_of[20]; char Enemy[20]; };
class Fictional_Characters { char Story_Star[20]; char Birthday[20]; short Age; link Friend_Table Friend_Table Friend_of Friends_of; link Enemy_Table Enemy_Table Enemy_of Enemies_of; method Do_This; };
* End of MyObjects.cre input file for ODM create utilities. *
The Fictional_Characters object class contains six descriptors:
Note: Note that the object class link is repeated twice.
The file containing this code must be processed with the odmcreate command to generate the object class files required by ODM.
Processing the code in the MyObjects.cre file with the odmcreate command generates the following structures in a .h file:
* MyObjects.h * The file output from ODM processing of the MyObjects.cre input * file. Defines structures for the three object classes: * Friend_Table * Enemy_Table * Fictional_Characters #include <odmi.h>
struct Friend_Table { long _id; * unique object id within object class * long _reserved; * reserved field * long _scratch; * extra field for application use * char Friend_of[20]; char Friend[20]; };
#define Friend_Table_Descs 2 extern struct Class Friend_Table_CLASS[]; #define get_Friend_Table_list(a,b,c,d,e) (struct Friend_Table * )odm_get_list (a,b,c,d,e)
struct Enemy_Table { long _id; long _reserved; long _scratch; char Enemy_of[20]; char Enemy[20]; }; #define Enemy_Table_Descs 2 extern struct Class Enemy_Table_CLASS[]; #define get_Enemy_Table_list(a,b,c,d,e) (struct Enemy_Table * )odm_get_list (a,b,c,d,e)
struct Fictional_Characters { long _id; long _reserved; long _scratch; char Story_Star[20]; char Birthday[20]; short Age; struct Friend_Table *Friends_of; * link * struct listinfo *Friends_of_info; * link * char Friends_of_Lvalue[20]; * link * struct Enemy_Table *Enemies_of; * link * struct listinfo *Enemies_of_info; * link * char Enemies_of_Lvalue[20]; * link * char Do_This[256]; * method * };
#define Fictional_Characters_Descs 6 extern struct Class Fictional_Characters_CLASS[]; #define get_Fictional_Characters_list(a,b,c,d,e) (struct Fictional_Characters * )odm_get_list (a,b,c,d,e)
* End of MyObjects.h structure definition file output from ODM * processing.
The following code can be processed by the odmadd command to populate the object classes created by the processing of the MyObjects.cre input file:
* MyObjects.add * An input file for ODM add utilities. * Populates three created object classes: * Friend_Table * Enemy_Table * Fictional_Characters
Fictional_Characters: Story_Star = "Cinderella" #a comment for the MyObjects.add file. Birthday = "Once upon a time" Age = 19 Friends_of = "Cinderella" Enemies_of = "Cinderella" Do_This = "echo Cleans house"
Fictional_Characters: Story_Star = "Snow White" Birthday = "Once upon a time" Age = 18 Friends_of = "Snow White" Enemies_of = "Snow White" Do_This = "echo Cleans house"
Friend_Table: Friend_of = "Cinderella" Friend = "Fairy Godmother"
Friend_Table: Friend_of = "Cinderella" Friend = "mice"
Friend_Table: Friend_of = "Snow White" Friend = "Sneezy"
Friend_Table: Friend_of = "Snow White" Friend = "Sleepy"
Friend_Table: Friend_of = "Cinderella" Friend = "Prince"
Friend_Table: Friend_of = "Snow White" Friend = "Happy"
Enemy_Table: Enemy_of = "Cinderella" Enemy = "midnight"
Enemy_Table: Enemy_of = "Cinderella" Enemy = "Mean Stepmother"
Enemy_Table: Enemy_of = "Snow White" Enemy = "Mean Stepmother"
* End of MyObjects.add input file for ODM add utilities. *
Note: The * (asterisk) or the # (pound sign) comment above will not go into the object file; it is only for the .add file as a comment. The comment will be included in the file and treated as a string if it is included inside the " " (double quotes).