diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llmedia/llmediaimplfactory.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llmedia/llmediaimplfactory.cpp')
-rw-r--r-- | linden/indra/llmedia/llmediaimplfactory.cpp | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/linden/indra/llmedia/llmediaimplfactory.cpp b/linden/indra/llmedia/llmediaimplfactory.cpp new file mode 100644 index 0000000..0ca7757 --- /dev/null +++ b/linden/indra/llmedia/llmediaimplfactory.cpp | |||
@@ -0,0 +1,104 @@ | |||
1 | /** | ||
2 | * @file llmediaimplfactory.cpp | ||
3 | * @brief Creates media impls that have registered themselves with LLMediaRegster | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llmediaimplfactory.h" | ||
33 | |||
34 | #include <iostream> | ||
35 | |||
36 | LLMediaImplFactory* LLMediaImplFactory::sInstance = NULL; | ||
37 | |||
38 | /////////////////////////////////////////////////////////////////////////////// | ||
39 | // static | ||
40 | LLMediaImplFactory* LLMediaImplFactory::getInstance() | ||
41 | { | ||
42 | if ( ! sInstance ) | ||
43 | sInstance = new LLMediaImplFactory(); | ||
44 | |||
45 | return sInstance; | ||
46 | } | ||
47 | |||
48 | /////////////////////////////////////////////////////////////////////////////// | ||
49 | // | ||
50 | void LLMediaImplFactory::registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker ) | ||
51 | { | ||
52 | mNameImplMakerContainer.insert( name_impl_maker_container_t::value_type( impl_name, impl_maker ) ); | ||
53 | } | ||
54 | |||
55 | /////////////////////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& scheme, const std::string& type ) | ||
58 | { | ||
59 | name_impl_maker_container_t::const_iterator iter; | ||
60 | name_impl_maker_container_t::const_iterator begin = mNameImplMakerContainer.begin(); | ||
61 | name_impl_maker_container_t::const_iterator end = mNameImplMakerContainer.end(); | ||
62 | |||
63 | for(iter = begin; iter != end; ++iter) | ||
64 | { | ||
65 | if(( *iter->second ).supportsScheme(scheme)) | ||
66 | { | ||
67 | return ( iter->second ); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | for(iter = begin; iter != end; ++iter) | ||
72 | { | ||
73 | if(( *iter->second ).supportsMimeType(type)) | ||
74 | { | ||
75 | return ( iter->second ); | ||
76 | } | ||
77 | } | ||
78 | int idx1 = type.find("/"); | ||
79 | int len = (idx1 == std::string::npos) ? 0 : idx1; | ||
80 | std::string category = type.substr(0,len); | ||
81 | for(iter = begin; iter != end; ++iter) | ||
82 | { | ||
83 | if(( *iter->second ).supportsMimeTypeCategory(category)) | ||
84 | { | ||
85 | return ( iter->second ); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | return NULL; | ||
90 | }; | ||
91 | |||
92 | /////////////////////////////////////////////////////////////////////////////// | ||
93 | // | ||
94 | LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& impl_name ) | ||
95 | { | ||
96 | name_impl_maker_container_t::const_iterator found = mNameImplMakerContainer.find( impl_name ); | ||
97 | |||
98 | if ( found == mNameImplMakerContainer.end() ) | ||
99 | { | ||
100 | return NULL; | ||
101 | }; | ||
102 | |||
103 | return found->second; | ||
104 | } | ||