home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / toolkt21 / cplus / os2h / somcm.xh < prev    next >
Encoding:
Text File  |  1993-05-02  |  9.6 KB  |  296 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: somcm.xh.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitxh: 1.11
  8.  */
  9.  
  10. /*
  11.  *  SOMClassMgr: System Object Model class manager
  12.  *  Copyright (c) International Business Machines Corporation
  13.  *          1991, 1992
  14.  */
  15.  
  16. #ifndef somcm_xh
  17. #define somcm_xh
  18. class SOMClassMgr;
  19.  
  20. #define SOMClassMgr_MajorVersion 1
  21. #define SOMClassMgr_MinorVersion 1
  22.  
  23. /* C++ som defs */
  24. #include <somcls.xh>
  25.  
  26. /* C++ parent def */
  27. #ifndef somobj_xh
  28. #include <somobj.xh>
  29. #endif
  30.  
  31. #ifndef SOMClassMgr_API
  32. #define SOMClassMgr_API
  33. /*
  34.  * The Class API
  35.  */
  36.  
  37. /* A procedure to create the SOMClassMgr Class */
  38. SOMEXTERN SOMClass * SOMLINK SOMClassMgrNewClass(
  39.         integer4 majorVersion,
  40.         integer4 minorVersion);
  41.  
  42. /* A macro to return the SOMClassMgr class object */
  43. #define _SOMClassMgr ((SOMClass*)SOMClassMgrClassData.classObject)
  44.  
  45. /* The static interface to SOMClassMgr and its instances */
  46. SOMEXTERN struct SOMClassMgrClassDataStructure {
  47.     SOMClass *classObject;
  48.     somMToken somFindClsInFile;
  49.     somMToken somFindClass;
  50.     somMToken somClassFromId;
  51.     somMToken somRegisterClass;
  52.     somMToken somUnregisterClass;
  53.     somMToken somLocateClassFile;
  54.     somMToken somLoadClassFile;
  55.     somMToken somUnloadClassFile;
  56.     somMToken somGetInitFunction;
  57.     somMToken somMergeInto;
  58.     somMToken somGetRelatedClasses;
  59. } SOMClassMgrClassData;
  60.  
  61. /*
  62.  * -- Typedefs for Procedures that support SOMClassMgr Methods
  63.  */
  64. extern "C" {
  65. typedef SOMClass *   (SOMLINK *somTD_SOMClassMgr_somLoadClassFile)(SOMClassMgr *somSelf,INOUT somId classId,IN integer4 majorVersion,IN integer4 minorVersion,IN zString file);
  66. typedef zString    (SOMLINK *somTD_SOMClassMgr_somLocateClassFile)(SOMClassMgr *somSelf,INOUT somId classId,IN integer4 majorVersion,IN integer4 minorVersion);
  67. typedef void    (SOMLINK *somTD_SOMClassMgr_somRegisterClass)(SOMClassMgr *somSelf,IN SOMClass *classObj);
  68. typedef int    (SOMLINK *somTD_SOMClassMgr_somUnloadClassFile)(SOMClassMgr *somSelf,IN SOMClass *classObj);
  69. typedef int    (SOMLINK *somTD_SOMClassMgr_somUnregisterClass)(SOMClassMgr *somSelf,IN SOMClass *classObj);
  70. typedef zString    (SOMLINK *somTD_SOMClassMgr_somGetInitFunction)(SOMClassMgr *somSelf);
  71. typedef SOMClass **   (SOMLINK *somTD_SOMClassMgr_somGetRelatedClasses)(SOMClassMgr *somSelf,IN SOMClass *classObj);
  72. typedef SOMClass *   (SOMLINK *somTD_SOMClassMgr_somClassFromId)(SOMClassMgr *somSelf,IN somId classId);
  73. typedef SOMClass *   (SOMLINK *somTD_SOMClassMgr_somFindClass)(SOMClassMgr *somSelf,INOUT somId classId,IN integer4 majorVersion,IN integer4 minorVersion);
  74. typedef SOMClass *   (SOMLINK *somTD_SOMClassMgr_somFindClsInFile)(SOMClassMgr *somSelf,INOUT somId classId,IN integer4 majorVersion,IN integer4 minorVersion,IN zString file);
  75. typedef void    (SOMLINK *somTD_SOMClassMgr_somMergeInto)(SOMClassMgr *somSelf,IN SOMObject *targetObj);
  76. }
  77.  
  78.  
  79. #endif /* SOMClassMgr_API */
  80.  
  81.  
  82. /*
  83.  * -- The C++ Wrapper Class for SOMClassMgr
  84.  */
  85. class SOMClassMgr : public SOMObject
  86. {
  87. public:
  88.  
  89. void *operator new(size_t size)
  90. {
  91.    (void) size;
  92.    if (!SOMClassMgrClassData.classObject) 
  93.       SOMClassMgrNewClass(SOMClassMgr_MajorVersion,SOMClassMgr_MinorVersion);
  94.    return (void *)
  95.       ((somTD_SOMClass_somNew)
  96.       somResolve(SOM_TestCls((SOMAny *)(SOMClassMgrClassData.classObject),
  97.                              SOMClassClassData.classObject),
  98.                  SOMClassClassData.somNew))
  99.          ((SOMClass*)(SOMClassMgrClassData.classObject));
  100. }
  101.  
  102. void operator delete(void * obj)
  103. {
  104.    ((SOMObject *)obj)->somFree();
  105. }
  106.  
  107. /* public method: somLoadClassFile */
  108.  
  109. /*
  110.  *  Loads the class' code and initializes the class object.
  111.  */
  112. SOMClass *   somLoadClassFile(INOUT somId classId,
  113.         IN integer4 majorVersion,
  114.         IN integer4 minorVersion,
  115.         IN zString file)
  116. {
  117.    return (SOMClass*) SOM_Resolve((SOMAny *)this,SOMClassMgr,somLoadClassFile)
  118.     (this,classId,majorVersion,minorVersion,file);
  119. }
  120.  
  121.  
  122. /* public method: somLocateClassFile */
  123.  
  124. /*
  125.  *  Real implementation supplied by subclasses.  Default implementation
  126.  *  returns the class name as the file name.   Subclasses may use
  127.  *  version number info to assist in deriving the file name.
  128.  */
  129. zString    somLocateClassFile(INOUT somId classId,
  130.         IN integer4 majorVersion,
  131.         IN integer4 minorVersion)
  132. {
  133.    return (zString) SOM_Resolve((SOMAny *)this,SOMClassMgr,somLocateClassFile)
  134.     (this,classId,majorVersion,minorVersion);
  135. }
  136.  
  137.  
  138. /* public method: somRegisterClass */
  139.  
  140. /*
  141.  *  Lets the class manager know that the specified class is installed
  142.  *  and tells it where the class object is.
  143.  */
  144. void    somRegisterClass(IN SOMClass *classObj)
  145. {
  146.    SOM_Resolve((SOMAny *)this,SOMClassMgr,somRegisterClass)
  147.     (this,classObj);
  148. }
  149.  
  150.  
  151. /* public method: somUnloadClassFile */
  152.  
  153. /*
  154.  *  Releases the class' code and unregisters all classes in the
  155.  *  same affinity group (see somGetRelatedClasses below).
  156.  */
  157. int    somUnloadClassFile(IN SOMClass *classObj)
  158. {
  159.    return (int) SOM_Resolve((SOMAny *)this,SOMClassMgr,somUnloadClassFile)
  160.     (this,classObj);
  161. }
  162.  
  163.  
  164. /* public method: somUnregisterClass */
  165.  
  166. /*
  167.  *  Free the class object and removes the class from the SOM registry.
  168.  *  If the class caused dynamic loading to occur, it is also unloaded
  169.  *  (causing its entire affinity group to be unregistered as well).
  170.  */
  171. int    somUnregisterClass(IN SOMClass *classObj)
  172. {
  173.    return (int) SOM_Resolve((SOMAny *)this,SOMClassMgr,somUnregisterClass)
  174.     (this,classObj);
  175. }
  176.  
  177.  
  178. /* public method: somGetInitFunction */
  179.  
  180. /*
  181.  *  Supplies the name of the initialization function in the class' code
  182.  *  file.  Default implementation returns (*SOMClassInitFuncName)().
  183.  */
  184. zString    somGetInitFunction()
  185. {
  186.    return (zString) SOM_Resolve((SOMAny *)this,SOMClassMgr,somGetInitFunction)
  187.     (this);
  188. }
  189.  
  190.  
  191. /* public method: somGetRelatedClasses */
  192.  
  193. /*
  194.  *  Returns an array of class objects that were all registered during
  195.  *  the dynamic loading of a class.    These classes are considered to
  196.  *  define an affinity group.  Any class is a member of at most one
  197.  *  affinity group.    The affinity group returned by this call is the
  198.  *  one containing the class identified by classObj.  The first element
  199.  *  in the array is the class that caused the group to be loaded, or the
  200.  *  special value -1 which means that the SOMClassMgr is currently in the
  201.  *  process of unregistering and deleting the affinity group (only
  202.  *  SOMClassMgr subclasses would ever see this value).
  203.  *  The remainder of the array (elements one thru n) consists of
  204.  *  pointers to class objects ordered in reverse chronological sequence
  205.  *  to that in which they were originally registered.  This list includes
  206.  *  the given argument, classObj, as one of its elements, as well as the
  207.  *  class, if any, returned as element[0] above.  The array is terminated
  208.  *  by a NULL pointer as the last element.  Use SOMFree to release the
  209.  *  array when it is no longer needed.  If the supplied class was not
  210.  *  dynamically loaded, it is not a member of any affinity
  211.  *  group and NULL is returned.
  212.  */
  213. SOMClass **   somGetRelatedClasses(IN SOMClass *classObj)
  214. {
  215.    return (SOMClass**) SOM_Resolve((SOMAny *)this,SOMClassMgr,somGetRelatedClasses)
  216.     (this,classObj);
  217. }
  218.  
  219.  
  220. /* public method: somClassFromId */
  221.  
  222. /*
  223.  *  Finds the class object, given its Id, if it already exists.
  224.  *  Does not load the class.  Returns NULL if the class object does
  225.  *  not yet exist.
  226.  */
  227. SOMClass *   somClassFromId(IN somId classId)
  228. {
  229.    return (SOMClass*) SOM_Resolve((SOMAny *)this,SOMClassMgr,somClassFromId)
  230.     (this,classId);
  231. }
  232.  
  233.  
  234. /* public method: somFindClass */
  235.  
  236. /*
  237.  *  Returns the class object for the specified class.  This may result
  238.  *  in dynamic loading.  Uses somLocateClassFile to obtain the name of
  239.  *  the file where the class' code resides, then uses somFindClsInFile.
  240.  */
  241. SOMClass *   somFindClass(INOUT somId classId,
  242.         IN integer4 majorVersion,
  243.         IN integer4 minorVersion)
  244. {
  245.    return (SOMClass*) SOM_Resolve((SOMAny *)this,SOMClassMgr,somFindClass)
  246.     (this,classId,majorVersion,minorVersion);
  247. }
  248.  
  249.  
  250. /* public method: somFindClsInFile */
  251.  
  252. /*
  253.  *  Returns the class object for the specified class.  This may result
  254.  *  in dynamic loading.  If the class already exists <file> is ignored,
  255.  *  otherwise it is used to locate and dynamically load the class.
  256.  *  Values of 0 for major and minor version numbers bypass version checking.
  257.  */
  258. SOMClass *   somFindClsInFile(INOUT somId classId,
  259.         IN integer4 majorVersion,
  260.         IN integer4 minorVersion,
  261.         IN zString file)
  262. {
  263.    return (SOMClass*) SOM_Resolve((SOMAny *)this,SOMClassMgr,somFindClsInFile)
  264.     (this,classId,majorVersion,minorVersion,file);
  265. }
  266.  
  267.  
  268. /* public method: somMergeInto */
  269.  
  270. /*
  271.  *  Merges the SOMClassMgr registry information from the receiver to
  272.  *  <targetObj>.  <targetObj> is required to be an instance of SOMClassMgr
  273.  *  or one of its subclasses.  At the completion of this operation,
  274.  *  the <targetObj> should be able to function as a replacement for the
  275.  *  receiver.  At the end of the operation the receiver object (which is
  276.  *  then in a newly uninitialized state) is freed.  Subclasses that
  277.  *  override this method should similarly transfer their sections of
  278.  *  the object and pass this method to their parent as the final step.
  279.  *  If the receiving object is the distinguished instance pointed to
  280.  *  from the global variable SOMClassMgrObject, SOMCLassMgrObject is
  281.  *  then reassigned to point to <targetObj>.
  282.  */
  283. void    somMergeInto(IN SOMObject *targetObj)
  284. {
  285.    SOM_Resolve((SOMAny *)this,SOMClassMgr,somMergeInto)
  286.     (this,targetObj);
  287. }
  288.  
  289.  
  290.  
  291. };   /* SOMClassMgr */
  292.  
  293.  
  294.  
  295. #endif       /* somcm_xh */
  296.