home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-12 | 1.8 KB | 108 lines | [TEXT/CWIE] |
- /***
- * GOSAID.cp
- *
- * A simple id in a component.
- *
- * Gordon Watts (gwatts@fnal.fnal.gov) © 1995 As Is!
- ***/
-
- #include "GOSAID.h"
- #include "GOSAScriptComponent.h"
- #include "debug.h"
-
- /**
- * GOSAID
- *
- * Remember the component, and, perhaps, the id.
- *
- **/
- GOSAID :: GOSAID (const GOSAScriptComponent *theComp)
- {
- mScriptingComponent = theComp;
- mIDValid = false;
- mDeleteWhenWeGo = false;
- }
-
- GOSAID :: GOSAID (const GOSAScriptComponent *theComp, const OSAID theID)
- {
- mScriptingComponent = theComp;
- mIDValid = true;
- mID = theID;
- mDeleteWhenWeGo = false;
- }
-
- GOSAID :: GOSAID (void)
- {
- mScriptingComponent = GOSAScriptComponent :: GetDefaultComponent ();
- mIDValid = false;
- mDeleteWhenWeGo = false;
- }
-
- GOSAID :: GOSAID (const OSAID theID)
- {
- mScriptingComponent = GOSAScriptComponent :: GetDefaultComponent ();
- mIDValid = true;
- mID = theID;
- mDeleteWhenWeGo = false;
- }
-
- /**
- * ~GOSAID
- *
- * Go away. If we are requested, delete the id as we go.
- *
- **/
- GOSAID :: ~GOSAID (void)
- {
- if (mDeleteWhenWeGo)
- DeleteID ();
- }
-
- /**
- * DeleteID
- *
- * Remove the id from the scripting component...
- *
- **/
- void GOSAID :: DeleteID (void)
- {
- OSAError err = noErr;
-
- if (mIDValid)
- err = OSADispose ((ComponentInstance) mScriptingComponent->instance(), mID);
-
- ThrowIfOSErr_(err);
- }
-
- /**
- * SetID
- *
- * Chnage the id -- delete the old one if we have it. Oneday will do ref
- * counting...
- *
- **/
- void GOSAID :: SetID (OSAID theID)
- {
- DeleteID ();
-
- mID = theID;
- mIDValid = true;
- }
-
- /**
- * GetAEDesc
- *
- * Return an aedesc that represents this puppy.
- *
- **/
- void GOSAID :: GetAEDesc (AEDesc &theDesc)
- {
- AssertStr (mIDValid, "\pInvalid id while trying to get ae desc!");
-
- OSErr err;
-
- err = OSACoerceToDesc ((ComponentInstance) mScriptingComponent->instance(),
- mID, typeWildCard, kOSAModeNull, &theDesc);
- ThrowIfOSErr_(err);
- }
-