00001 /* 00002 * This file is part of ALVAR, A Library for Virtual and Augmented Reality. 00003 * 00004 * Copyright 2007-2012 VTT Technical Research Centre of Finland 00005 * 00006 * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi> 00007 * <http://www.vtt.fi/multimedia/alvar.html> 00008 * 00009 * ALVAR is free software; you can redistribute it and/or modify it under the 00010 * terms of the GNU Lesser General Public License as published by the Free 00011 * Software Foundation; either version 2.1 of the License, or (at your option) 00012 * any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, but WITHOUT 00015 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00016 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00017 * for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public License 00020 * along with ALVAR; if not, see 00021 * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>. 00022 */ 00023 00024 #ifndef CAPTUREFACTORY_H 00025 #define CAPTUREFACTORY_H 00026 00035 #include "Alvar.h" 00036 #include "Capture.h" 00037 #include "CaptureDevice.h" 00038 #include "Platform.h" 00039 #include "Util.h" 00040 00041 namespace alvar { 00042 00043 class CaptureFactoryPrivate; 00044 00052 class ALVAR_EXPORT CaptureFactory 00053 { 00054 public: 00058 static CaptureFactory *instance(); 00059 00063 typedef std::vector<std::string> CapturePluginVector; 00064 00072 CapturePluginVector enumeratePlugins(); 00073 00077 typedef std::vector<CaptureDevice> CaptureDeviceVector; 00078 00089 CaptureDeviceVector enumerateDevices(const std::string &captureType = ""); 00090 00100 Capture *createCapture(const CaptureDevice captureDevice); 00101 00102 protected: 00106 ~CaptureFactory(); 00107 00108 private: 00112 class CaptureFactoryDestroyer 00113 { 00114 public: 00115 CaptureFactoryDestroyer(CaptureFactory *instance = NULL) : mInstance(instance) {} 00116 ~CaptureFactoryDestroyer() {delete mInstance;} 00117 void set(CaptureFactory *instance) {mInstance = instance;} 00118 private: 00119 CaptureFactory *mInstance; 00120 }; 00121 00122 // private constructors and assignment operator for singleton implementation 00123 CaptureFactory(); 00124 CaptureFactory(const CaptureFactory&); 00125 CaptureFactory &operator=(const CaptureFactory&); 00126 00127 // static members for singleton implementation 00128 static CaptureFactory *mInstance; 00129 static Mutex mMutex; 00130 static CaptureFactoryDestroyer mDestroyer; 00131 00132 // members 00133 CaptureFactoryPrivate *d; 00134 }; 00135 00136 } // namespace alvar 00137 00138 #endif