home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Script Builder 1.0 / Helper Source / GOSAID.cp < prev    next >
Encoding:
Text File  |  1995-12-12  |  1.8 KB  |  108 lines  |  [TEXT/CWIE]

  1. /***
  2.  * GOSAID.cp
  3.  *
  4.  *  A simple id in a component.
  5.  *
  6.  *  Gordon Watts (gwatts@fnal.fnal.gov) © 1995 As Is!
  7.  ***/
  8.  
  9. #include "GOSAID.h"
  10. #include "GOSAScriptComponent.h"
  11. #include "debug.h"
  12.  
  13. /**
  14.  * GOSAID
  15.  *
  16.  *  Remember the component, and, perhaps, the id.
  17.  *
  18.  **/
  19. GOSAID :: GOSAID (const GOSAScriptComponent *theComp)
  20. {
  21.     mScriptingComponent = theComp;
  22.     mIDValid = false;
  23.     mDeleteWhenWeGo = false;
  24. }
  25.  
  26. GOSAID :: GOSAID (const GOSAScriptComponent *theComp, const OSAID theID)
  27. {
  28.     mScriptingComponent = theComp;
  29.     mIDValid = true;
  30.     mID = theID;
  31.     mDeleteWhenWeGo = false;
  32. }
  33.  
  34. GOSAID :: GOSAID (void)
  35. {
  36.     mScriptingComponent = GOSAScriptComponent :: GetDefaultComponent ();
  37.     mIDValid = false;
  38.     mDeleteWhenWeGo = false;
  39. }
  40.  
  41. GOSAID :: GOSAID (const OSAID theID)
  42. {
  43.     mScriptingComponent = GOSAScriptComponent :: GetDefaultComponent ();
  44.     mIDValid = true;
  45.     mID = theID;
  46.     mDeleteWhenWeGo = false;
  47. }
  48.  
  49. /**
  50.  * ~GOSAID
  51.  *
  52.  *  Go away.  If we are requested, delete the id as we go.
  53.  *
  54.  **/
  55. GOSAID :: ~GOSAID (void)
  56. {
  57.     if (mDeleteWhenWeGo)
  58.         DeleteID ();
  59. }
  60.  
  61. /**
  62.  * DeleteID
  63.  *
  64.  *  Remove the id from the scripting component...
  65.  *
  66.  **/
  67. void GOSAID :: DeleteID (void)
  68. {
  69.     OSAError        err = noErr;
  70.  
  71.     if (mIDValid)
  72.         err = OSADispose ((ComponentInstance) mScriptingComponent->instance(), mID);
  73.  
  74.     ThrowIfOSErr_(err);
  75. }
  76.  
  77. /**
  78.  * SetID
  79.  *
  80.  *  Chnage the id -- delete the old one if we have it.  Oneday will do ref
  81.  *  counting...
  82.  *
  83.  **/
  84. void GOSAID :: SetID (OSAID theID)
  85. {
  86.     DeleteID ();
  87.     
  88.     mID = theID;
  89.     mIDValid = true;
  90. }
  91.  
  92. /**
  93.  * GetAEDesc
  94.  *
  95.  *  Return an aedesc that represents this puppy.
  96.  *
  97.  **/
  98. void GOSAID :: GetAEDesc (AEDesc &theDesc)
  99. {
  100.     AssertStr (mIDValid, "\pInvalid id while trying to get ae desc!");
  101.  
  102.     OSErr    err;
  103.  
  104.     err = OSACoerceToDesc ((ComponentInstance) mScriptingComponent->instance(),
  105.                     mID, typeWildCard, kOSAModeNull, &theDesc);
  106.     ThrowIfOSErr_(err);
  107. }
  108.