factory.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <cams/factory.h>
00025 #include <fvutils/system/camargp.h>
00026
00027 #ifdef HAVE_FIREWIRE_CAM
00028 #include <cams/firewire.h>
00029 #endif
00030 #ifdef HAVE_LEUTRON_CAM
00031 #include <cams/leutron.h>
00032 #endif
00033 #ifdef HAVE_FILELOADER_CAM
00034 #include <cams/fileloader.h>
00035 #endif
00036 #ifdef HAVE_SHMEM_CAM
00037 #include <cams/shmem.h>
00038 #endif
00039 #ifdef HAVE_NETWORK_CAM
00040 #include <cams/net.h>
00041 #endif
00042 #ifdef HAVE_V4L_CAM
00043 #include <cams/v4l.h>
00044 #endif
00045 #ifdef HAVE_V4L1_CAM
00046 #include <cams/v4l1.h>
00047 #endif
00048 #ifdef HAVE_V4L2_CAM
00049 #include <cams/v4l2.h>
00050 #endif
00051 #ifdef HAVE_NAO_CAM
00052 #include <cams/nao.h>
00053 #endif
00054 #ifdef HAVE_BUMBLEBEE2_CAM
00055 #include <cams/bumblebee2.h>
00056 #endif
00057 #ifdef HAVE_SWISSRANGER_CAM
00058 #include <cams/swissranger.h>
00059 #endif
00060 #ifdef HAVE_PIKE_CAM
00061 #include <cams/pike.h>
00062 #endif
00063
00064 using namespace std;
00065
00066 namespace firevision {
00067 #if 0
00068 }
00069 #endif
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 Camera *
00089 CameraFactory::instance(const CameraArgumentParser *cap)
00090 {
00091 Camera *c = NULL;
00092
00093
00094 if ( cap->cam_type() == "firewire" ) {
00095 #ifdef HAVE_FIREWIRE_CAM
00096 c = new FirewireCamera(cap);
00097 #else
00098 throw UnknownCameraTypeException("No firewire support at compile time");
00099 #endif
00100 }
00101
00102
00103 if ( cap->cam_type() == "leutron" ) {
00104 #ifdef HAVE_LEUTRON_CAM
00105 c = new LeutronCamera();
00106 #else
00107 throw UnknownCameraTypeException("No Leutron support at compile time");
00108 #endif
00109 }
00110
00111
00112 if ( cap->cam_type() == "file" ) {
00113 #ifdef HAVE_FILELOADER_CAM
00114 c = new FileLoader(cap);
00115 #else
00116 throw UnknownCameraTypeException("No file loader support at compile time");
00117 #endif
00118 }
00119
00120
00121 if ( cap->cam_type() == "shmem" ) {
00122 #ifdef HAVE_SHMEM_CAM
00123 c = new SharedMemoryCamera(cap);
00124 #else
00125 throw UnknownCameraTypeException("No shared memory support at compile time");
00126 #endif
00127 }
00128
00129
00130 if ( cap->cam_type() == "net" ) {
00131 #ifdef HAVE_NETWORK_CAM
00132 c = new NetworkCamera(cap);
00133 #else
00134 throw UnknownCameraTypeException("No network support at compile time");
00135 #endif
00136 }
00137
00138
00139 if ( cap->cam_type() == "v4l" ) {
00140 #ifdef HAVE_V4L_CAM
00141 c = new V4LCamera(cap);
00142 #else
00143 throw UnknownCameraTypeException("No video4linux support at compile time");
00144 #endif
00145 }
00146
00147
00148 if ( cap->cam_type() == "v4l1" ) {
00149 #ifdef HAVE_V4L1_CAM
00150 c = new V4L1Camera(cap);
00151 #else
00152 throw UnknownCameraTypeException("No video4linux1 support at compile time");
00153 #endif
00154 }
00155
00156
00157 if ( cap->cam_type() == "v4l2" ) {
00158 #ifdef HAVE_V4L2_CAM
00159 c = new V4L2Camera(cap);
00160 #else
00161 throw UnknownCameraTypeException("No video4linux2 support at compile time");
00162 #endif
00163 }
00164
00165
00166 if ( cap->cam_type() == "nao" ) {
00167 #ifdef HAVE_NAO_CAM
00168 c = new NaoCamera(cap);
00169 #else
00170 throw UnknownCameraTypeException("No nao camera support at compile time");
00171 #endif
00172 }
00173
00174
00175 if ( cap->cam_type() == "bumblebee2" ) {
00176 #ifdef HAVE_BUMBLEBEE2_CAM
00177 c = new Bumblebee2Camera(cap);
00178 #else
00179 throw UnknownCameraTypeException("No Bumblebee 2 support at compile time");
00180 #endif
00181 }
00182
00183
00184 if ( cap->cam_type() == "swissranger" ) {
00185 #ifdef HAVE_SWISSRANGER_CAM
00186 c = new SwissRangerCamera(cap);
00187 #else
00188 throw UnknownCameraTypeException("No SwissRanger support at compile time");
00189 #endif
00190 }
00191
00192
00193 if ( cap->cam_type() == "pike" ) {
00194 #ifdef HAVE_PIKE_CAM
00195 c = new PikeCamera(cap);
00196 #else
00197 throw UnknownCameraTypeException("No Bumblebee 2 support at compile time");
00198 #endif
00199 }
00200
00201 if ( c == NULL ) {
00202 throw UnknownCameraTypeException();
00203 }
00204
00205 return c;
00206 }
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 Camera *
00227 CameraFactory::instance(const char *as)
00228 {
00229 CameraArgumentParser *cap = new CameraArgumentParser(as);
00230 try {
00231 Camera *cam = instance(cap);
00232 delete cap;
00233 return cam;
00234 } catch (UnknownCameraTypeException &e) {
00235 delete cap;
00236 throw;
00237 }
00238 }
00239
00240 }