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/control/factory.h>
00025 #include <fvutils/system/camargp.h>
00026 #include <core/exceptions/software.h>
00027
00028 #include <cams/control/color.h>
00029 #include <cams/control/image.h>
00030 #include <cams/control/effect.h>
00031 #include <cams/control/focus.h>
00032 #include <cams/control/pantilt.h>
00033 #include <cams/control/zoom.h>
00034 #include <cams/control/source.h>
00035 #include <cams/control/dummy.h>
00036 #include <cams/cam_exceptions.h>
00037
00038 #ifdef HAVE_VISCA_CTRL
00039 #include <cams/control/visca.h>
00040 #endif
00041 #ifdef HAVE_EVID100P_CTRL
00042 #include <cams/control/sony_evid100p.h>
00043 #endif
00044 #ifdef HAVE_DPPTU_CTRL
00045 #include <cams/control/dp_ptu.h>
00046 #endif
00047
00048 #include <typeinfo>
00049
00050 using namespace std;
00051
00052 namespace firevision {
00053 #if 0
00054 }
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 CameraControl *
00076 CameraControlFactory::instance(const CameraArgumentParser *cap)
00077 {
00078 CameraControl *c = NULL;
00079
00080
00081 if ( cap->cam_type() == "evid100p" ) {
00082 #ifdef HAVE_EVID100P_CTRL
00083 c = new SonyEviD100PControl(cap);
00084 #else
00085 throw UnknownCameraControlTypeException("No EviD100P/Visca support at compile time");
00086 #endif
00087 }
00088
00089
00090 if ( cap->cam_type() == "dpptu" ) {
00091 #ifdef HAVE_DPPTU_CTRL
00092 c = new DPPTUControl(cap);
00093 #else
00094 throw UnknownCameraControlTypeException("No DPPTU support at compile time");
00095 #endif
00096 }
00097
00098
00099 if ( cap->cam_type() == "dummy" ) {
00100 c = new DummyCameraControl();
00101 }
00102
00103 if ( c == NULL ) {
00104 throw UnknownCameraControlTypeException();
00105 }
00106
00107 return c;
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 CameraControl *
00125 CameraControlFactory::instance(const char *as)
00126 {
00127 CameraArgumentParser *cap = new CameraArgumentParser(as);
00128 try {
00129 return instance(cap);
00130 } catch (UnknownCameraControlTypeException &e) {
00131 throw;
00132 }
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 CameraControl *
00148 CameraControlFactory::instance(Camera *camera)
00149 {
00150 CameraControl *c = dynamic_cast<CameraControl *>(camera);
00151 if (c) {
00152 return c;
00153 } else {
00154 throw fawkes::TypeMismatchException("Camera does not provide requested camera control");
00155 }
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 CameraControl *
00172 CameraControlFactory::instance(const std::type_info &typeinf, Camera *camera)
00173 {
00174 CameraControl *c = NULL;
00175
00176 if (typeid(CameraControlColor) == typeinf) {
00177 c = dynamic_cast<CameraControlColor *>(camera);
00178
00179 } else if (typeid(CameraControlImage) == typeinf) {
00180 c = dynamic_cast<CameraControlImage *>(camera);
00181
00182 } else if (typeid(CameraControlPanTilt) == typeinf) {
00183 c = dynamic_cast<CameraControlPanTilt *>(camera);
00184
00185 } else if (typeid(CameraControlFocus) == typeinf) {
00186 c = dynamic_cast<CameraControlFocus *>(camera);
00187
00188 } else if (typeid(CameraControlZoom) == typeinf) {
00189 c = dynamic_cast<CameraControlZoom *>(camera);
00190
00191 } else if (typeid(CameraControlEffect) == typeinf) {
00192 c = dynamic_cast<CameraControlEffect *>(camera);
00193
00194 } else if (typeid(CameraControlSource) == typeinf) {
00195 c = dynamic_cast<CameraControlSource *>(camera);
00196
00197 } else {
00198 throw UnknownCameraControlTypeException();
00199 }
00200
00201 if (c) {
00202 return c;
00203 } else {
00204 throw fawkes::TypeMismatchException("Camera does not provide requested camera control");
00205 }
00206 }
00207
00208 }