00001 #ifndef _ofxsCore_H_
00002 #define _ofxsCore_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00086 #ifdef _MSC_VER
00087 #pragma warning( disable : 4290 )
00088 #endif
00089
00090 #include "ofxCore.h"
00091 #include "ofxImageEffect.h"
00092 #include "ofxInteract.h"
00093 #include "ofxKeySyms.h"
00094 #include "ofxMemory.h"
00095 #include "ofxMessage.h"
00096 #include "ofxMultiThread.h"
00097 #include "ofxParam.h"
00098 #include "ofxProperty.h"
00099
00100 #include <assert.h>
00101 #include <vector>
00102 #include <string>
00103 #include <map>
00104 #include <exception>
00105 #include <stdexcept>
00106 #include <sstream>
00107
00108 #ifdef OFX_CLIENT_EXCEPTION_HEADER
00109 #include OFX_CLIENT_EXCEPTION_HEADER
00110 #endif
00111
00116 struct OfxRGBColourB {
00117 unsigned char r, g, b;
00118 };
00119
00124 struct OfxRGBColourS {
00125 unsigned short r, g, b;
00126 };
00127
00132 struct OfxRGBColourF {
00133 float r, g, b;
00134 };
00135
00140 struct OfxRGBColourD {
00141 double r, g, b;
00142 };
00143
00148 struct Ofx3DPointI {
00149 int x, y, z;
00150 };
00151
00156 struct Ofx3DPointD {
00157 double x, y, z;
00158 };
00159
00161 #define mDeclareProtectedAssignAndCC(CLASS) \
00162 CLASS &operator=(const CLASS &v1) {assert(false); return *this;} \
00163 CLASS(const CLASS &v) {assert(false); }
00164
00167 namespace OFX {
00169 class PropertySet;
00170
00172 enum PropertyTypeEnum {
00173 ePointer,
00174 eInt,
00175 eString,
00176 eDouble
00177 };
00178
00180 enum InstanceChangeReason {
00181 eChangeUserEdit,
00182 eChangePluginEdit,
00183 eChangeTime
00184 };
00185
00187 char * mapStatusToString(OfxStatus stat);
00188
00190 namespace Exception {
00191
00194 class Suite : public std::exception {
00195 protected :
00196 OfxStatus _status;
00197 public :
00198 Suite(OfxStatus s) : _status(s) {}
00199 OfxStatus status(void) {return _status;}
00200 operator OfxStatus() {return _status;}
00201
00203 virtual const char * what () const throw () {return mapStatusToString(_status);}
00204
00205 };
00206
00208 class PropertyUnknownToHost : public std::exception {
00209 protected :
00210 std::string _what;
00211 public :
00212 PropertyUnknownToHost(const char *what) : _what(what) {}
00213 virtual ~PropertyUnknownToHost() throw() {}
00214
00216 virtual const char * what () const throw ()
00217 {
00218 return _what.c_str();
00219 }
00220 };
00221
00223 class PropertyValueIllegalToHost : public std::exception {
00224 protected :
00225 std::string _what;
00226 public :
00227 PropertyValueIllegalToHost(const char *what) : _what(what) {}
00228 virtual ~PropertyValueIllegalToHost() throw() {}
00229
00231 virtual const char * what () const throw ()
00232 {
00233 return _what.c_str();
00234 }
00235 };
00236
00240 class TypeRequest : public std::exception {
00241 protected :
00242 std::string _what;
00243 public :
00244 TypeRequest(const char *what) : _what(what) {}
00245 virtual ~TypeRequest() throw() {}
00246
00248 virtual const char * what () const throw ()
00249 {
00250 return _what.c_str();
00251 }
00252 };
00253
00255
00256
00257
00258
00260 class HostInadequate : public std::exception {
00261 protected :
00262 std::string _what;
00263 public :
00264 HostInadequate(char *what) : _what(what) {}
00265 virtual ~HostInadequate() throw() {}
00266
00268 virtual const char * what () const throw ()
00269 {
00270 return _what.c_str();
00271 }
00272 };
00273
00274 };
00275
00277 void
00278 throwSuiteStatusException(OfxStatus stat)
00279 throw(OFX::Exception::Suite, std::bad_alloc);
00280
00281 void
00282 throwHostMissingSuiteException(std::string name)
00283 throw(OFX::Exception::Suite);
00284
00289 class ImageEffectDescriptor;
00290 class ImageEffect;
00291
00293 class PropertySet {
00294 protected :
00296 OfxPropertySetHandle _propHandle;
00297
00299 static int _gPropLogging;
00300
00302 static bool _gThrowOnUnsupported;
00303
00304 public :
00306 static void propEnableLogging(void) {++_gPropLogging;}
00307
00309 static void propDisableLogging(void) {--_gPropLogging;}
00310
00312 static void setThrowOnUnsupportedProperties(bool v) {_gThrowOnUnsupported = v;}
00313
00315 static bool getThrowOnUnsupportedProperties(void) {return _gThrowOnUnsupported;}
00316
00318 PropertySet(OfxPropertySetHandle h = 0) : _propHandle(h) {}
00319 virtual ~PropertySet();
00320
00322 void propSetHandle(OfxPropertySetHandle h) { _propHandle = h;}
00323
00325 OfxPropertySetHandle propSetHandle(void) {return _propHandle;}
00326
00327 int propGetDimension(const char* property, bool throwOnFailure = true) const throw(std::bad_alloc,
00328 OFX::Exception::PropertyUnknownToHost,
00329 OFX::Exception::PropertyValueIllegalToHost,
00330 OFX::Exception::Suite);
00331 void propReset(const char* property) throw(std::bad_alloc,
00332 OFX::Exception::PropertyUnknownToHost,
00333 OFX::Exception::PropertyValueIllegalToHost,
00334 OFX::Exception::Suite);
00335
00336
00337 void propSetPointer(const char* property, void *value, int idx, bool throwOnFailure = true) throw(std::bad_alloc,
00338 OFX::Exception::PropertyUnknownToHost,
00339 OFX::Exception::PropertyValueIllegalToHost,
00340 OFX::Exception::Suite);
00341 void propSetString(const char* property, const std::string &value, int idx, bool throwOnFailure = true) throw(std::bad_alloc,
00342 OFX::Exception::PropertyUnknownToHost,
00343 OFX::Exception::PropertyValueIllegalToHost,
00344 OFX::Exception::Suite);
00345 void propSetDouble(const char* property, double value, int idx, bool throwOnFailure = true) throw(std::bad_alloc,
00346 OFX::Exception::PropertyUnknownToHost,
00347 OFX::Exception::PropertyValueIllegalToHost,
00348 OFX::Exception::Suite);
00349 void propSetInt(const char* property, int value, int idx, bool throwOnFailure = true) throw(std::bad_alloc,
00350 OFX::Exception::PropertyUnknownToHost,
00351 OFX::Exception::PropertyValueIllegalToHost,
00352 OFX::Exception::Suite);
00353
00354 void propSetPointer(const char* property, void *value, bool throwOnFailure = true) throw(std::bad_alloc,
00355 OFX::Exception::PropertyUnknownToHost,
00356 OFX::Exception::PropertyValueIllegalToHost,
00357 OFX::Exception::Suite)
00358 {propSetPointer(property, value, 0, throwOnFailure);}
00359
00360 void propSetString(const char* property, const std::string &value, bool throwOnFailure = true) throw(std::bad_alloc,
00361 OFX::Exception::PropertyUnknownToHost,
00362 OFX::Exception::PropertyValueIllegalToHost,
00363 OFX::Exception::Suite)
00364 {propSetString(property, value, 0, throwOnFailure);}
00365
00366 void propSetDouble(const char* property, double value, bool throwOnFailure = true) throw(std::bad_alloc,
00367 OFX::Exception::PropertyUnknownToHost,
00368 OFX::Exception::PropertyValueIllegalToHost,
00369 OFX::Exception::Suite)
00370 {propSetDouble(property, value, 0, throwOnFailure);}
00371
00372 void propSetInt(const char* property, int value, bool throwOnFailure = true) throw(std::bad_alloc,
00373 OFX::Exception::PropertyUnknownToHost,
00374 OFX::Exception::PropertyValueIllegalToHost,
00375 OFX::Exception::Suite)
00376 {propSetInt(property, value, 0, throwOnFailure);}
00377
00378
00380 void *propGetPointer(const char* property, int idx, bool throwOnFailure = true) const throw(std::bad_alloc,
00381 OFX::Exception::PropertyUnknownToHost,
00382 OFX::Exception::PropertyValueIllegalToHost,
00383 OFX::Exception::Suite);
00384
00386 std::string propGetString(const char* property, int idx, bool throwOnFailure = true) const throw(std::bad_alloc,
00387 OFX::Exception::PropertyUnknownToHost,
00388 OFX::Exception::PropertyValueIllegalToHost,
00389 OFX::Exception::Suite);
00391 double propGetDouble(const char* property, int idx, bool throwOnFailure = true) const throw(std::bad_alloc,
00392 OFX::Exception::PropertyUnknownToHost,
00393 OFX::Exception::PropertyValueIllegalToHost,
00394 OFX::Exception::Suite);
00395
00397 int propGetInt(const char* property, int idx, bool throwOnFailure = true) const throw(std::bad_alloc,
00398 OFX::Exception::PropertyUnknownToHost,
00399 OFX::Exception::PropertyValueIllegalToHost,
00400 OFX::Exception::Suite);
00401
00403 void* propGetPointer(const char* property, bool throwOnFailure = true) const throw(std::bad_alloc,
00404 OFX::Exception::PropertyUnknownToHost,
00405 OFX::Exception::PropertyValueIllegalToHost,
00406 OFX::Exception::Suite)
00407 {
00408 return propGetPointer(property, 0, throwOnFailure);
00409 }
00410
00412 std::string propGetString(const char* property, bool throwOnFailure = true) const throw(std::bad_alloc,
00413 OFX::Exception::PropertyUnknownToHost,
00414 OFX::Exception::PropertyValueIllegalToHost,
00415 OFX::Exception::Suite)
00416 {
00417 return propGetString(property, 0, throwOnFailure);
00418 }
00419
00421 double propGetDouble(const char* property, bool throwOnFailure = true) const throw(std::bad_alloc,
00422 OFX::Exception::PropertyUnknownToHost,
00423 OFX::Exception::PropertyValueIllegalToHost,
00424 OFX::Exception::Suite)
00425 {
00426 return propGetDouble(property, 0, throwOnFailure);
00427 }
00428
00430 int propGetInt(const char* property, bool throwOnFailure = true) const throw(std::bad_alloc,
00431 OFX::Exception::PropertyUnknownToHost,
00432 OFX::Exception::PropertyValueIllegalToHost,
00433 OFX::Exception::Suite)
00434 {
00435 return propGetInt(property, 0, throwOnFailure);
00436 }
00437 };
00438
00439
00440 class ImageEffect;
00441
00443 namespace Memory {
00445 void *alloc(size_t nBytes,
00446 ImageEffect *handle = 0) throw(std::bad_alloc);
00447
00449 void free(void *ptr) throw();
00450
00451 };
00452 };
00453
00454
00455 #undef mDeclareProtectedAssignAndCC
00456
00457 #endif