SingleShotSource.cpp
1 2 #include "SingleShotSource.h" 3 #include "Utilities.h" 4 #include <string> 5 6 using namespace std; 7 8 CFStringRef gSingleShotSourceName = CFSTR("Single Shot Source"); 9 10 SingleShotSource::SingleShotSource(CFTypeRef value, Transform* t, CFStringRef name) : 11 Source(gSingleShotSourceName, t, name) 12 { 13 SetValue(value); 14 } 15 16 void SingleShotSource::DoActivate() 17 { 18 // Make sure our destination doesn't vanish while we are sending it data (or the final NULL) 19 CFRetainSafe(mDestination->GetCFObject()); 20 21 // take our value and send it on its way 22 mDestination->SetAttribute(mDestinationName, GetValue()); 23 24 // send an end of stream 25 mDestination->SetAttribute(mDestinationName, NULL); 26 27 CFReleaseSafe(mDestination->GetCFObject()); 28 } 29 30 31 32 Boolean SingleShotSource::Equal(const CoreFoundationObject* obj) 33 { 34 if (Source::Equal(obj)) 35 { 36 const SingleShotSource* sss = (const SingleShotSource*) obj; 37 return CFEqual(GetValue(), sss->GetValue()); 38 } 39 40 return false; 41 } 42 43 44 45 CFTypeRef SingleShotSource::Make(CFTypeRef value, Transform* t, CFStringRef name) 46 { 47 return CoreFoundationHolder::MakeHolder(gInternalCFObjectName, new SingleShotSource(value, t, name)); 48 } 49 50 51 52 std::string SingleShotSource::DebugDescription() 53 { 54 string result = Source::DebugDescription() + ": SingleShotSource "; 55 56 char buffer[256]; 57 snprintf(buffer, sizeof(buffer), "(value = %p)", GetValue()); 58 59 result += buffer; 60 61 return result; 62 }