home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / CAE-GROUP / SCL-WIN3x / FED_PLUS.EXE / ENTITY.H < prev    next >
Text File  |  1994-07-23  |  7KB  |  190 lines

  1. #ifndef ENTITY_H
  2. #define ENTITY_H
  3.  
  4. /* $Id: entity.h,v 1.10 1994/05/11 19:51:05 libes Exp $ */
  5.  
  6. /************************************************************************
  7. ** Module:    Entity
  8. ** Description:    This module represents Express entity definitions.  An
  9. **    entity definition consists of a name, a list of attributes, a
  10. **    collection of uniqueness sets, a specification of the entity's
  11. **    position in a class hierarchy (i.e., sub- and supertypes), and
  12. **    a list of constraints which must be satisfied by instances of
  13. **    the entity.  A uniquess set is a set of one or more attributes
  14. **    which, when taken together, uniquely identify a specific instance
  15. **    of the entity.  Thus, the uniqueness set { name, ssn } indicates
  16. **    that no two instances of the entity may share both the same
  17. **    values for both name and ssn.
  18. ** Constants:
  19. **    ENTITY_NULL    - the null entity
  20. **
  21. ************************************************************************/
  22.  
  23. /*
  24.  * This software was developed by U.S. Government employees as part of
  25.  * their official duties and is not subject to copyright.
  26.  *
  27.  * $Log: entity.h,v $
  28.  * Revision 1.10  1994/05/11  19:51:05  libes
  29.  * numerous fixes
  30.  *
  31.  * Revision 1.9  1993/10/15  18:48:24  libes
  32.  * CADDETC certified
  33.  *
  34.  * Revision 1.7  1993/02/16  03:14:47  libes
  35.  * simplified find calls
  36.  *
  37.  * Revision 1.6  1993/01/19  22:45:07  libes
  38.  * *** empty log message ***
  39.  *
  40.  * Revision 1.5  1992/08/18  17:12:41  libes
  41.  * rm'd extraneous error messages
  42.  *
  43.  * Revision 1.4  1992/06/08  18:06:24  libes
  44.  * prettied up interface to print_objects_when_running
  45.  * 
  46.  */
  47.  
  48. /*************/
  49. /* constants */
  50. /*************/
  51.  
  52. #define ENTITY_NULL                (Entity)0
  53. #define ENTITY_INHERITANCE_UNINITIALIZED    -1
  54.  
  55. /*****************/
  56. /* packages used */
  57. /*****************/
  58.  
  59. #include "expbasic.h"    /* get basic definitions */
  60. #include "symbol.h"
  61. #include "scope.h"
  62.  
  63. /************/
  64. /* typedefs */
  65. /************/
  66.  
  67. typedef struct Scope *Entity;
  68.  
  69. /****************/
  70. /* modules used */
  71. /****************/
  72.  
  73. #include "expr.h"
  74. #include "variable.h"
  75. #include "schema.h"
  76.  
  77. /***************************/
  78. /* hidden type definitions */
  79. /***************************/
  80.  
  81. struct Entity {
  82.     Linked_List    supertype_symbols; /* linked list of original symbols*/
  83.                 /* as generated by parser */
  84.     Linked_List    supertypes;    /* linked list of supertypes (as entities) */
  85.     Linked_List    subtypes;    /* simple list of subtypes */
  86.             /* useful for simple lookups */
  87.     Expression    subtype_expression;    /* DAG of subtypes, with complete */
  88.             /* information including, OR, AND, and ONEOF */
  89.     Linked_List    attributes;    /* explicit attributes */
  90.     int        inheritance;    /* total number of attributes */
  91.                     /* inherited from supertypes */
  92.     int        attribute_count;
  93.     Linked_List    unique;    /* list of identifiers that are unique */
  94.     Linked_List    instances;    /* hook for applications */
  95.     int        mark;    /* usual hack - prevent traversing sub/super */
  96.                 /* graph twice */
  97.     Boolean        abstract;/* is this an abstract supertype? */
  98.     Type        type;    /* type pointing back to ourself */
  99.                 /* Useful to have when evaluating */
  100.                 /* expressions involving entities */
  101. };
  102.  
  103. /********************/
  104. /* global variables */
  105. /********************/
  106.  
  107. #ifdef ENTITY_C
  108. #include "defstart.h"
  109. #else
  110. #include "decstart.h"
  111. #endif    /*  ENTITY_C  */
  112.  
  113. GLOBAL struct freelist_head ENTITY_fl;
  114.  
  115. GLOBAL int    ENTITY_MARK    INITIALLY(0);
  116.  
  117. #include "de_end.h"
  118.  
  119. /******************************/
  120. /* macro function definitions */
  121. /******************************/
  122.  
  123. #define ENTITY_new()        (struct Entity *)MEM_new(&ENTITY_fl)
  124. #define ENTITY_destroy(x)    MEM_destroy(&ENTITY_fl,(Freelist *)(char *)x)
  125.  
  126. #define ENTITYget_symbol(e)    SCOPEget_symbol(e)
  127. /* returns a function (i.e., which can be passed to other functions) */
  128. #define ENTITY_get_symbol    SCOPE_get_symbol
  129.  
  130. #define ENTITYget_attributes(e)    ((e)->u.entity->attributes)
  131. #define ENTITYget_subtypes(e)    ((e)->u.entity->subtypes)
  132. #define ENTITYget_supertypes(e)    ((e)->u.entity->supertypes)
  133. #define ENTITYget_name(e)    ((e)->symbol.name)
  134. #define ENTITYget_uniqueness_list(e) ((e)->u.entity->unique)
  135. #define ENTITYget_where(e)    ((e)->where)
  136. #define ENTITYput_where(e,w)    ((e)->where = (w))
  137.  
  138. #define ENTITYget_abstract(e)    ((e)->u.entity->abstract)
  139. #define ENTITYget_mark(e)    ((e)->u.entity->mark)
  140. #define ENTITYput_mark(e,m)    ((e)->u.entity->mark = (m))
  141. #define ENTITYput_inheritance_count(e,c) ((e)->u.entity->inheritance = (c))
  142. #define ENTITYget_inheritance_count(e)    ((e)->u.entity->inheritance)
  143. #define ENTITYget_size(e)    ((e)->u.entity->attribute_count + (e)->u.entity->inheritance)
  144. #define ENTITYget_attribute_count(e)    ((e)->u.entity->attribute_count)
  145. #define ENTITYput_attribute_count(e,c)    ((e)->u.entity->attribute_count = (c))
  146.  
  147. #define ENTITYget_clientData(e)        ((e)->clientData)
  148. #define ENTITYput_clientData(e,d)        ((e)->clientData = (d))
  149.  
  150. /***********************/
  151. /* function prototypes */
  152. /***********************/
  153.  
  154. extern struct Scope *    ENTITYcreate PROTO((struct Symbol *));
  155. extern void        ENTITYinitialize PROTO((void));
  156. extern void        ENTITYadd_attribute PROTO((struct Scope*, struct Variable *));
  157. extern struct Scope    *ENTITYcopy PROTO((struct Scope*));
  158. extern struct Variable    *ENTITYfind_inherited_attribute PROTO((struct Scope *,char *));
  159. extern Entity         ENTITYfind_inherited_entity PROTO((struct Scope *,char *));
  160. extern Boolean        ENTITYhas_immediate_supertype PROTO((Entity, Entity));
  161. extern Variable        ENTITYget_named_attribute PROTO((Entity, char *));
  162. extern Linked_List    ENTITYget_all_attributes PROTO((Entity));
  163. extern Boolean        ENTITYhas_supertype PROTO((Entity, Entity));
  164. extern void        ENTITYadd_instance PROTO((Entity, Generic));
  165. extern int        ENTITYget_initial_offset PROTO((Entity));
  166. extern int        ENTITYdeclares_variable PROTO((Entity, struct Variable *));
  167.  
  168. #if 0
  169. extern void        ENTITYdelete_instance PROTO((Entity, Generic));
  170. extern Boolean        ENTITYhas_subtype PROTO((Entity, Entity));
  171. extern Entity        ENTITYget_supertype PROTO((Entity,String));
  172. extern Entity        ENTITYget_subtype PROTO((Entity,String));
  173. extern Boolean        ENTITYhas_immediate_subtype PROTO((Entity, Entity));
  174. extern Expression    ENTITYget_subtype_expression PROTO((Entity));
  175. extern int        ENTITYget_attribute_offset PROTO((Entity, Variable));
  176. extern int        ENTITYget_named_attribute_offset PROTO((Entity, String));
  177. extern Linked_List    ENTITYget_uniqueness_list PROTO((Entity));
  178. extern Linked_List    ENTITYget_constraints PROTO((Entity));
  179. extern Linked_List    ENTITYget_instances PROTO((Entity));
  180. #endif /*0*/
  181.  
  182. /********************/
  183. /* inline functions */
  184. /********************/
  185.  
  186. #if supports_inline_functions || defined(ENTITY_C)
  187. #endif /* supports_inline_functions || defined(ENTITY_C) */
  188.     
  189. #endif    /*  ENTITY_H  */
  190.