00001 // This is core/vidl/vidl_v4l2_devices.h 00002 #ifndef vidl_v4l2_devices_h_ 00003 #define vidl_v4l2_devices_h_ 00004 //: 00005 // \file 00006 // \brief A class for a singleton with video devices 00007 // 00008 // \author Antonio Garrido 00009 // \verbatim 00010 // Modifications 00011 // 15 Apr 2009 Created (A. Garrido) 00012 //\endverbatim 00013 00014 #include <vcl_vector.h> 00015 #include "vidl_v4l2_device.h" 00016 #include "vidl_v4l2_device_sptr.h" 00017 00018 00019 //: A class which stores all devices in an object 00020 // This object is a singleton initialized automatically by detecting all devices in the system, 00021 // The devices are detected iterating over all files in the device directory. 00022 // 00023 // This singleton can be accessed as vidl_v4l2_devices::all() 00024 // Note that you can work with devices without using this singleton, because you can 00025 // create a vidl_v4l2_device directly from the file name. However, it is better to 00026 // look for the device in this singleton using directly de card name. 00027 // \see vidl_v4l2_device 00028 class vidl_v4l2_devices 00029 { 00030 vcl_vector<vidl_v4l2_device_sptr> vecdev; 00031 vidl_v4l2_devices(); 00032 void load_devices(const char *name); 00033 public: 00034 //: Instance 00035 static vidl_v4l2_devices& all(); 00036 00037 //: Return number of detected devices in the system 00038 unsigned int size() const { return vecdev.size(); } 00039 // Return device i (0..size()-1) 00040 //vidl_v4l2_device& device(unsigned int i) {return *vecdev[i];} 00041 //: Return device i (0..size()-1) 00042 vidl_v4l2_device& operator()(unsigned int i) {return *vecdev[i];} 00043 }; 00044 00045 #endif // vidl_v4l2_devices_h_