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 / SCL.EXE / REGISTRY.CPP < prev    next >
Text File  |  1994-08-06  |  5KB  |  196 lines

  1.  
  2. /*
  3. * NIST STEP Core Class Library
  4. * clstepcore/Registry.inline.cc
  5. * February, 1994
  6. * K. C. Morris
  7. * David Sauder
  8.  
  9. * Development of this software was funded by the United States Government,
  10. * and is not subject to copyright.
  11. */
  12.  
  13. /* $Id: Registry.inline.cc,v 2.0.1.2 1994/05/10 21:06:02 kc Exp $  */ 
  14.  
  15. #include <Registry.h>
  16.  
  17.  const TypeDescriptor *  t_INTEGER_TYPE;
  18.  const TypeDescriptor *  t_REAL_TYPE;
  19.  const TypeDescriptor *  t_NUMBER_TYPE;
  20.  const TypeDescriptor *  t_STRING_TYPE;
  21.  const TypeDescriptor *  t_BINARY_TYPE;
  22.  const TypeDescriptor *  t_BOOLEAN_TYPE;
  23.  const TypeDescriptor *  t_LOGICAL_TYPE;
  24.  
  25.  
  26. /* inline */ 
  27. Registry::Registry (CF_init initFunct) 
  28. : entity_cnt (0)
  29.     primordialSwamp = HASHcreate (1000);
  30.     active_schemas = HASHcreate (10);
  31.     active_types = HASHcreate (100);
  32.  
  33.     t_INTEGER_TYPE = new TypeDescriptor("INTEGER",     // Name
  34.                INTEGER_TYPE, // FundamentalType
  35.                "INTEGER");   // Description;
  36.  
  37.     t_REAL_TYPE = new TypeDescriptor("REAL", REAL_TYPE, "Real");
  38.  
  39.     t_STRING_TYPE = new TypeDescriptor("STRING", STRING_TYPE, "String");
  40.  
  41.     t_BINARY_TYPE = new TypeDescriptor("BINARY", BINARY_TYPE, "Binary");
  42.  
  43.     t_BOOLEAN_TYPE = new TypeDescriptor("BOOLEAN", BOOLEAN_TYPE, "Boolean");
  44.  
  45.     t_LOGICAL_TYPE = new TypeDescriptor("LOGICAL", LOGICAL_TYPE, "Logical");
  46.  
  47.     t_NUMBER_TYPE = new TypeDescriptor("NUMBER", NUMBER_TYPE, "Number");
  48.  
  49. /*    t_GENERIC_TYPE = new TypeDescriptor("GENERIC", GENERIC_TYPE, "Generic");*/
  50.  
  51.     initFunct (*this);  
  52.     HASHlistinit (primordialSwamp, &cur_entity);  // initialize cur\'s
  53.     HASHlistinit (active_schemas, &cur_schema);
  54. }
  55.  
  56. /* inline */ 
  57. Registry::~Registry  ()
  58. {
  59.     HASHdestroy (primordialSwamp);
  60.     HASHdestroy (active_schemas);
  61.     HASHdestroy (active_types);
  62. }
  63.  
  64. void 
  65. Registry::DeleteContents ()
  66. {
  67.   // entities first
  68.   HASHlistinit (primordialSwamp, &cur_entity);
  69.   while (HASHlist (&cur_entity))
  70.     delete (EntityDescriptor *) cur_entity.e->data;
  71.  
  72.   // schemas
  73.   HASHlistinit (active_schemas, &cur_schema);
  74.   while (HASHlist (&cur_schema))
  75.     delete (SchemaDescriptor *) cur_schema.e->data;
  76.  
  77.   // types 
  78.  
  79. }
  80.  
  81. /* inline */ const EntityDescriptor *
  82. Registry::FindEntity (const char * e, int check_case) const
  83. {
  84.     if (check_case) 
  85.     return
  86.         (const EntityDescriptor *) HASHfind (primordialSwamp, 
  87.                          (char *)PrettyTmpName (e));
  88.     else return (const EntityDescriptor *) HASHfind (primordialSwamp, (char *) e);
  89. }
  90.  
  91.  
  92. /* inline */ const SchemaDescriptor *
  93. Registry::FindSchema (const char * n, int check_case) const
  94. {
  95.     if (check_case) 
  96.        return (const SchemaDescriptor *) HASHfind (primordialSwamp, 
  97.                            (char *)PrettyTmpName (n));
  98.     return (const SchemaDescriptor *) HASHfind (active_schemas, (char *) n);
  99. }
  100.  
  101. /* inline */ const TypeDescriptor *
  102. Registry::FindType (const char * n, int check_case) const 
  103. {
  104.     if (check_case) 
  105.        return (const TypeDescriptor *) HASHfind (primordialSwamp, 
  106.                          (char *)PrettyTmpName (n));
  107.     return (const TypeDescriptor *) HASHfind (active_types, (char *) n);
  108. }
  109.     
  110. /* inline */ void     
  111. Registry::AddEntity (const EntityDescriptor& e)
  112. {
  113.     HASHinsert (primordialSwamp, (char *) e.Name (), (EntityDescriptor *) &e);
  114.     ++entity_cnt;
  115. }
  116.   
  117.  
  118. /* inline */ void    
  119. Registry::AddSchema (const SchemaDescriptor& d)
  120. {
  121.     HASHinsert (active_schemas, (char *) d.Name(), (SchemaDescriptor *) &d);
  122. }
  123.  
  124. /* inline */ void     
  125. Registry::AddType  (const TypeDescriptor& d)
  126. {
  127.     HASHinsert (active_types, (char *) d.Name(), (TypeDescriptor *) &d);
  128. }
  129.     
  130. /* inline */ void     
  131. Registry::RemoveEntity (const char * n)
  132. {
  133.     struct Element tmp;
  134.     tmp.key = (char *) n;
  135.     HASHsearch (primordialSwamp, &tmp, HASH_DELETE) ? --entity_cnt : 0;
  136.     
  137. }
  138.  
  139. /* inline */ void    
  140. Registry::RemoveSchema (const char * n)
  141. {
  142.     struct Element tmp;
  143.     tmp.key = (char *) n;
  144.     HASHsearch (active_schemas, &tmp, HASH_DELETE);
  145. }
  146.  
  147. /* inline */ void     
  148. Registry::RemoveType (const char * n)
  149. {
  150.     struct Element tmp;
  151.     tmp.key = (char *) n;
  152.     HASHsearch (active_types, &tmp, HASH_DELETE);
  153. }
  154.  
  155. /* inline */ STEPentity *
  156. Registry::ObjCreate (const char * nm, int check_case) const
  157. {    
  158.     const EntityDescriptor *  entd = FindEntity (nm, check_case);
  159.     if (entd) return ((EntityDescriptor *)entd) -> NewSTEPentity ();
  160.     else return ENTITY_NULL;
  161. }    
  162.  
  163. /* inline */ int
  164. Registry::GetEntityCnt ()  
  165. {
  166.     return entity_cnt;
  167. }
  168.  
  169. /* inline */ void
  170. Registry::ResetEntities ()  
  171. {
  172.     HASHlistinit (primordialSwamp, &cur_entity);
  173.     
  174. }
  175.  
  176. /* inline */ const EntityDescriptor *
  177. Registry::NextEntity () 
  178. {
  179.   if (0 == HASHlist (&cur_entity)) return 0;
  180.   return (const EntityDescriptor *) cur_entity.e->data;
  181. }    
  182.  
  183. /* inline */ void
  184. Registry::ResetSchemas ()  
  185. {
  186.     HASHlistinit (active_schemas, &cur_schema);
  187. }
  188.  
  189. /* inline */ const SchemaDescriptor *
  190. Registry::NextSchema () 
  191. {
  192.   if (0 == HASHlist (&cur_schema)) return 0;
  193.   return (const SchemaDescriptor *) cur_schema.e->data;
  194. }
  195.