-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPKDecoder.cpp
73 lines (58 loc) · 1.62 KB
/
PKDecoder.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* PKDecoder.cpp
* PKLite
*
* Created by Peter MacWhinnie on 5/23/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#include "PKDecoder.h"
#include <dispatch/dispatch.h>
#include "PKCoreAudioDecoder.h"
#pragma mark PKDecoder
#pragma mark Class Cluster
static std::vector<PKDecoder::Description> &RegisteredDecoders()
{
static std::vector<PKDecoder::Description> *registeredDecoders = NULL;
if(!registeredDecoders)
{
registeredDecoders = new std::vector<PKDecoder::Description>();
registeredDecoders->push_back(PKCoreAudioDecoderDescription);
}
return *registeredDecoders;
}
void PKDecoder::RegisterDecoder(const Description &decoderDescription)
{
RegisteredDecoders().push_back(decoderDescription);
}
PKDecoder *PKDecoder::DecoderForURL(CFURLRef location) throw(RBException)
{
std::vector<PKDecoder::Description> &decoders = RegisteredDecoders();
for (std::vector<PKDecoder::Description>::const_iterator it = decoders.begin(); it != decoders.end(); it++)
{
PKDecoder::Description decoder = *it;
if(decoder.CanDecode(location))
return decoder.CreateInstance(location);
}
return NULL;
}
bool PKDecoder::CanDecodeURL(CFURLRef location) throw(RBException)
{
std::vector<PKDecoder::Description> &decoders = RegisteredDecoders();
for (std::vector<PKDecoder::Description>::const_iterator it = decoders.begin(); it != decoders.end(); it++)
{
PKDecoder::Description decoder = *it;
if(decoder.CanDecode(location))
return true;
}
return false;
}
#pragma mark -
#pragma mark Lifetime
PKDecoder::PKDecoder(const char *className) :
RBObject(className)
{
}
PKDecoder::~PKDecoder()
{
}