llmediaimplfactory.h

Go to the documentation of this file.
00001 
00032 #ifndef LLMEDIAIMPLFACTORY_H
00033 #define LLMEDIAIMPLFACTORY_H
00034 
00035 #include <algorithm>
00036 #include <map>
00037 #include <string>
00038 #include <vector>
00039 
00040 #include "llmediabase.h"
00041 
00043 //
00044 class LLMediaImplMakerBase
00045 {
00046         public:
00047                 virtual bool supportsScheme(std::string scheme) = 0;
00048                 virtual bool supportsMimeType(std::string type) = 0;
00049                 virtual bool supportsMimeTypeCategory(std::string category) = 0;
00050                 virtual LLMediaBase* create() = 0;
00051                 virtual ~LLMediaImplMakerBase() {};
00052 
00053         protected:
00054                 typedef std::vector <std::string> vector_impl_registry_t;
00055                 vector_impl_registry_t mSchema;
00056                 vector_impl_registry_t mMimeTypes;
00057                 vector_impl_registry_t mMimeTypeCategories;
00058 };
00059 
00061 //
00062 class LLMediaImplMaker : public LLMediaImplMakerBase
00063 {
00064         public:
00065                 bool supportsScheme(std::string scheme)
00066                 {
00067                         vector_impl_registry_t::iterator found = std::find(mSchema.begin(), mSchema.end(), scheme);
00068                         return found != mSchema.end();
00069                 }
00070                 bool supportsMimeType(std::string type)
00071                 {
00072                         vector_impl_registry_t::iterator found = std::find(mMimeTypes.begin(), mMimeTypes.end(), type);
00073                         return found != mMimeTypes.end();
00074                 }
00075                 bool supportsMimeTypeCategory(std::string category)
00076                 {
00077                         vector_impl_registry_t::iterator found = std::find(mMimeTypeCategories.begin(), mMimeTypeCategories.end(), category);
00078                         return found != mMimeTypeCategories.end();
00079                 }
00080 };
00081 
00083 //
00084 class LLMediaImplFactory
00085 {
00086         public:
00087                 static LLMediaImplFactory* getInstance();
00088                 void registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker );
00089                 LLMediaImplMakerBase* getImplMaker( const std::string& scheme, const std::string& type );
00090                 LLMediaImplMakerBase* getImplMaker( const std::string& impl_name);
00091 
00092         private:
00093                 typedef std::map< std::string, LLMediaImplMakerBase* > name_impl_maker_container_t;
00094                 name_impl_maker_container_t mNameImplMakerContainer;
00095 
00096                 static LLMediaImplFactory* sInstance;
00097 };
00098 
00099 #endif  // LLMEDIAIMPLFACTORY_H

Generated on Fri May 16 08:32:20 2008 for SecondLife by  doxygen 1.5.5