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