Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ofxsParam.h

Go to the documentation of this file.
00001 #ifndef _ofxsParam_H_
00002 #define _ofxsParam_H_
00003 
00004 /*
00005   OFX Support Library, a library that skins the OFX plug-in API with C++ classes.
00006   Copyright (C) 2004-2005 The Foundry Visionmongers Ltd
00007   Author Bruno Nicoletti bruno@thefoundry.co.uk
00008 
00009 Redistribution and use in source and binary forms, with or without
00010 modification, are permitted provided that the following conditions are met:
00011 
00012     * Redistributions of source code must retain the above copyright notice,
00013       this list of conditions and the following disclaimer.
00014     * Redistributions in binary form must reproduce the above copyright notice,
00015       this list of conditions and the following disclaimer in the documentation
00016       and/or other materials provided with the distribution.
00017     * Neither the name The Foundry Visionmongers Ltd, nor the names of its 
00018       contributors may be used to endorse or promote products derived from this
00019       software without specific prior written permission.
00020 
00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00025 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00028 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 
00032 The Foundry Visionmongers Ltd
00033 1 Wardour St
00034 London W1D 6PA
00035 England
00036 
00037 
00038 
00039 */
00040 
00041 
00053 #include "ofxsCore.h"
00054 
00056 #define mDeclareProtectedAssignAndCC(CLASS) \
00057   CLASS &operator=(const CLASS &v1) {assert(false); return *this;}      \
00058   CLASS(const CLASS &v) {assert(false); } 
00059 
00062 namespace OFX {
00063 
00064     class ParamInteractDescriptor;
00065     /* forward class declarations of the  descriptors */
00066     class ParamDescriptor;
00067     class ValueParamDescriptor;
00068     class IntParamDescriptor;
00069     class Int2DParamDescriptor;
00070     class Int3DParamDescriptor;    
00071     class DoubleParamDescriptor;
00072     class Double2DParamDescriptor;
00073     class Double3DParamDescriptor;    
00074     class StringParamDescriptor;
00075     class RGBAParamDescriptor;
00076     class RGBParamDescriptor;
00077     class BooleanParamDescriptor;
00078     class ChoiceParamDescriptor;
00079     class GroupParamDescriptor;
00080     class PageParamDescriptor;
00081     class PushButtonParamDescriptor;
00082     class CustomParamDescriptor;
00083     class ParamSetDescriptor;
00084 
00085     /* forward class declarations of the instances */
00086     class Param;
00087     class ValueParam;
00088     class IntParam;
00089     class Int2DParam;
00090     class Int3DParam;    
00091     class DoubleParam;
00092     class Double2DParam;
00093     class Double3DParam;    
00094     class RGBAParam;
00095     class RGBParam;
00096     class StringParam;
00097     class BooleanParam;
00098     class ChoiceParam;
00099     class CustomParam;
00100     class GroupParam;
00101     class PageParam;
00102     class PushButtonParam;
00103     class ParamSet;
00104 
00105 
00107     enum ParamTypeEnum {eDummyParam,
00108                         eStringParam,
00109                         eIntParam,
00110                         eInt2DParam,
00111                         eInt3DParam,
00112                         eDoubleParam,
00113                         eDouble2DParam,
00114                         eDouble3DParam,
00115                         eRGBParam,
00116                         eRGBAParam,
00117                         eBooleanParam,
00118                         eChoiceParam,
00119                         eCustomParam,
00120                         eGroupParam,
00121                         ePageParam,
00122                         ePushButtonParam};
00123 
00125     enum CacheInvalidationEnum {eCacheInvalidateValueChange,
00126                                 eCacheInvalidateValueChangeToEnd,
00127                                 eCacheInvalidateValueAll};
00128 
00130     enum KeySearchEnum {eKeySearchBackwards,
00131                         eKeySearchNear,
00132                         eKeySearchForwards};
00133 
00135     enum StringTypeEnum {
00136         eStringTypeSingleLine,
00137         eStringTypeMultiLine,
00138         eStringTypeFilePath,
00139         eStringTypeDirectoryPath,
00140         eStringTypeLabel
00141     };
00142 
00144     enum DoubleTypeEnum {
00145         eDoubleTypePlain,
00146         eDoubleTypeAngle,
00147         eDoubleTypeScale,
00148         eDoubleTypeTime,
00149         eDoubleTypeAbsoluteTime,
00150         eDoubleTypeNormalisedX,
00151         eDoubleTypeNormalisedY,
00152         eDoubleTypeNormalisedXAbsolute,
00153         eDoubleTypeNormalisedYAbsolute,
00154         eDoubleTypeNormalisedXY,
00155         eDoubleTypeNormalisedXYAbsolute    
00156     };
00157 
00159     const char *
00160     mapParamTypeEnumToString(ParamTypeEnum v);
00161 
00163 
00164     class ParamDescriptor {
00165     protected :
00166         mDeclareProtectedAssignAndCC(ParamDescriptor);
00167         ParamDescriptor(void) {assert(false);}
00168 
00169     protected :
00170         std::string    _paramName;
00171         ParamTypeEnum  _paramType;
00172         PropertySet    _paramProps;
00173 
00175         ParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props);
00176 
00177         friend class ParamSetDescriptor;
00178     public :
00180         virtual ~ParamDescriptor();
00181 
00182         ParamTypeEnum getType(void) const {return _paramType;}
00183 
00185         const std::string &getName(void) const {return _paramName;}
00186 
00188       PropertySet &getPropertySet()
00189       {
00190         return _paramProps;
00191       }
00192 
00193 
00195         void setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel);
00196 
00198         void setHint(const std::string &hint);
00199 
00201         void setScriptName(const std::string &hint);
00202 
00204         void setIsSecret(bool v);
00205 
00207         void setParent(const GroupParamDescriptor &v);
00208     
00210         void setEnabled(bool v);
00211     };
00212 
00214 
00215     class DummyParamDescriptor : public ParamDescriptor {
00216     public :
00218         DummyParamDescriptor(const std::string &name) 
00219           : ParamDescriptor(name, eDummyParam, 0)
00220         {}  
00221     };
00222 
00224 
00225     class ValueParamDescriptor : public ParamDescriptor {
00226     protected :
00227         mDeclareProtectedAssignAndCC(ValueParamDescriptor);
00228         ValueParamDescriptor(void) {assert(false);}
00229 
00230     protected :
00232         ValueParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props);
00233 
00234         friend class ParamSetDescriptor;
00235         std::auto_ptr<ParamInteractDescriptor> _interact;
00236     public :
00238         ~ValueParamDescriptor();
00239 
00241         void setAnimates(bool v);
00242 
00244         void setIsPersistant(bool v);
00245 
00247         void setEvaluateOnChange(bool v);
00248     
00250         void setCacheInvalidation(CacheInvalidationEnum v);
00251 
00253         void setCanUndo(bool v);
00254 
00255         void setInteractDescriptor(ParamInteractDescriptor* desc);
00256     };
00257 
00259 
00260     class StringParamDescriptor : public ValueParamDescriptor {
00261     protected :
00262         mDeclareProtectedAssignAndCC(StringParamDescriptor);
00263         StringParamDescriptor(void) {assert(false);}
00264 
00265     protected :
00267         StringParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00268 
00269         friend class ParamSetDescriptor;
00270 
00271     public :
00273         void setDefault(const std::string &v);
00274 
00276         void setStringType(StringTypeEnum v);
00277 
00279         void setFilePathExists(bool v);    
00280     };
00281 
00283 
00284     class IntParamDescriptor : public ValueParamDescriptor {
00285     protected :
00286         mDeclareProtectedAssignAndCC(IntParamDescriptor);
00287         IntParamDescriptor(void) {assert(false);}
00288 
00289     protected :
00291         IntParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00292 
00293         friend class ParamSetDescriptor;
00294 
00295     public :
00297         void setDefault(int v);
00298 
00300         void setRange(int min, int max);
00301 
00303         void setDisplayRange(int min, int max);
00304     };
00305     
00307 
00308     class Int2DParamDescriptor : public ValueParamDescriptor {
00309     protected :
00310         mDeclareProtectedAssignAndCC(Int2DParamDescriptor);
00311         Int2DParamDescriptor(void) {assert(false);}
00312 
00313     protected :
00315         Int2DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00316 
00317         friend class ParamSetDescriptor;
00318 
00319     public :
00321         void setDimensionLabels(const std::string &x,
00322                                 const std::string &y);
00323 
00325         void setDefault(int x, int y);
00326 
00328         void setRange(int minX, int minY,
00329                       int maxX, int maxY);
00330 
00332         void setDisplayRange(int minX, int minY,
00333                             int maxX, int maxY);
00334     };
00335   
00337 
00338     class Int3DParamDescriptor : public ValueParamDescriptor {
00339     protected :
00340         mDeclareProtectedAssignAndCC(Int3DParamDescriptor);
00341         Int3DParamDescriptor(void) {assert(false);}
00342 
00343     protected :
00345         Int3DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00346 
00347         friend class ParamSetDescriptor;
00348 
00349     public :
00351         void setDimensionLabels(const std::string &x,
00352                                 const std::string &y,
00353                                 const std::string &z);
00354 
00356         void setDefault(int x, int y, int z);
00357 
00359         void setRange(int minX, int minY, int minZ,
00360                       int maxX, int maxY, int maxZ);
00361 
00363         void setDisplayRange(int minX, int minY, int minZ,
00364                             int maxX, int maxY, int maxZ);
00365     };
00366 
00368 
00369     class BaseDoubleParamDescriptor : public ValueParamDescriptor {
00370     protected :
00371         mDeclareProtectedAssignAndCC(BaseDoubleParamDescriptor);
00372         BaseDoubleParamDescriptor(void) {assert(false);}
00373 
00374     protected :
00376         BaseDoubleParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props);
00377 
00378         friend class ParamSetDescriptor;
00379     public :
00381         void setDoubleType(DoubleTypeEnum v);
00382 
00384         void setIncrement(double v);
00385 
00387         void setDigits(int v);
00388     };
00389   
00391 
00392     class DoubleParamDescriptor : public BaseDoubleParamDescriptor {
00393     protected :
00394         mDeclareProtectedAssignAndCC(DoubleParamDescriptor);
00395         DoubleParamDescriptor(void) {assert(false);}
00396 
00397     protected :
00399         DoubleParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00400 
00401         friend class ParamSetDescriptor;
00402 
00403     public :
00405         void setShowTimeMarker(bool v);
00406 
00408         void setDefault(double v);
00409 
00411         void setRange(double min, double max);
00412 
00414         void setDisplayRange(double min, double max);
00415     };
00416   
00418 
00419     class Double2DParamDescriptor : public BaseDoubleParamDescriptor {
00420     protected :
00421         mDeclareProtectedAssignAndCC(Double2DParamDescriptor);
00422         Double2DParamDescriptor(void) {assert(false);}
00423 
00424     protected :
00426         Double2DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00427 
00428         friend class ParamSetDescriptor;
00429 
00430     public :
00432         void setDimensionLabels(const std::string &x,
00433                                 const std::string &y);
00434 
00436         void setDefault(double x, double y);
00437 
00439         void setRange(double minX, double minY,
00440                       double maxX, double maxY);
00441 
00443         void setDisplayRange(double minX, double minY,
00444                             double maxX, double maxY);
00445     };
00446   
00448 
00449     class Double3DParamDescriptor : public BaseDoubleParamDescriptor {
00450     protected :
00451         mDeclareProtectedAssignAndCC(Double3DParamDescriptor);
00452         Double3DParamDescriptor(void) {assert(false);}
00453 
00454     protected :
00456         Double3DParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00457 
00458         friend class ParamSetDescriptor;
00459 
00460     public :
00462         void setDimensionLabels(const std::string &x,
00463                                 const std::string &y,
00464                                 const std::string &z);
00465 
00467         void setDefault(double x, double y, double z);
00468 
00470         void setRange(double minX, double minY, double minZ,
00471                       double maxX, double maxY, double maxZ);
00472 
00474         void setDisplayRange(double minX, double minY, double minZ,
00475                             double maxX, double maxY, double maxZ);
00476     };
00477 
00479 
00480     class RGBParamDescriptor : public ValueParamDescriptor {
00481     protected :
00482         mDeclareProtectedAssignAndCC(RGBParamDescriptor);
00483         RGBParamDescriptor(void) {assert(false);}
00484 
00485     protected :
00487         RGBParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00488 
00489         // so it can make one
00490         friend class ParamSetDescriptor;
00491     public :
00493         void setDefault(double r, double g, double b);
00494     };
00495 
00497 
00498     class RGBAParamDescriptor : public ValueParamDescriptor {
00499     protected :
00500         mDeclareProtectedAssignAndCC(RGBAParamDescriptor);
00501         RGBAParamDescriptor(void) {assert(false);}
00502 
00503     protected :
00505         RGBAParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00506 
00507         // so it can make one
00508         friend class ParamSetDescriptor;
00509     public :
00511         void setDefault(double r, double g, double b, double a);
00512     };
00513 
00515 
00516     class BooleanParamDescriptor : public ValueParamDescriptor {
00517     protected :
00518         mDeclareProtectedAssignAndCC(BooleanParamDescriptor);
00519         BooleanParamDescriptor(void) {assert(false);}
00520 
00521     protected :
00523         BooleanParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00524 
00525         // so it can make one
00526         friend class ParamSetDescriptor;
00527     public :
00529         void setDefault(bool v);
00530     };
00531   
00533 
00534     class ChoiceParamDescriptor : public ValueParamDescriptor {
00535     protected :
00536         mDeclareProtectedAssignAndCC(ChoiceParamDescriptor);
00537         ChoiceParamDescriptor(void) {assert(false);}
00538 
00539     protected :
00541         ChoiceParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00542 
00543         // so it can make one
00544         friend class ParamSetDescriptor;
00545     public :
00547         void setDefault(int v);
00548 
00550         void appendOption(const std::string &v);
00551     
00553         int getNOptions(void);
00554     
00556         void resetOptions(void);
00557     };
00558 
00560 
00561     class GroupParamDescriptor : public ParamDescriptor {
00562     protected :
00563         mDeclareProtectedAssignAndCC(GroupParamDescriptor);
00564         GroupParamDescriptor(void) {assert(false);}
00565 
00566     protected :
00568         GroupParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00569 
00570         // so it can make one
00571         friend class ParamSetDescriptor;
00572     public :
00573     };
00574 
00576 
00577     class PageParamDescriptor : public ParamDescriptor {
00578     protected :
00579         mDeclareProtectedAssignAndCC(PageParamDescriptor);
00580         PageParamDescriptor(void) {assert(false);}
00581 
00582     protected :
00584         PageParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00585 
00586         // so it can make one
00587         friend class ParamSetDescriptor;
00588     public :
00589 
00591         void addChild(const ParamDescriptor &p);
00592 
00594         static DummyParamDescriptor gSkipRow;
00595 
00597         static DummyParamDescriptor gSkipColumn;
00598     };
00599 
00601 
00602     class PushButtonParamDescriptor : public ParamDescriptor {
00603     protected :
00604         mDeclareProtectedAssignAndCC(PushButtonParamDescriptor);
00605         PushButtonParamDescriptor(void) {assert(false);}
00606 
00607     protected :
00609         PushButtonParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00610 
00611         // so it can make one
00612         friend class ParamSetDescriptor;
00613     public :
00614     };
00615 
00617 
00618     class CustomParamDescriptor : public ValueParamDescriptor {
00619     protected :
00620         mDeclareProtectedAssignAndCC(CustomParamDescriptor);
00621         CustomParamDescriptor(void) {assert(false);}
00622 
00623     protected :
00625         CustomParamDescriptor(const std::string &name, OfxPropertySetHandle props);
00626 
00627         // so it can make one
00628         friend class ParamSetDescriptor;
00629     public :
00631         void setDefault(const std::string &v);    
00632     };
00633 
00635 
00636     class ParamSetDescriptor { 
00637     protected :
00638         mDeclareProtectedAssignAndCC(ParamSetDescriptor);
00639 
00641         void defineRawParam(const std::string &name, ParamTypeEnum paramType, OfxPropertySetHandle &props);
00642 
00644         template <class T> bool
00645         defineParamDescriptor(const std::string &name, ParamTypeEnum paramType, T * &paramPtr)
00646         {
00647             paramPtr = NULL;
00648 
00649             // have we made it already in this param set and is it of the correct type
00650             if(ParamDescriptor *param  = findPreviouslyDefinedParam(name)) {
00651                 if(param->getType() == paramType) {
00652                     paramPtr = (T *) param; // could be a dynamic cast here
00653                     return true;
00654                 }
00655                 else
00656                     return false; // SHOULD THROW SOMETHING HERE!!!!!!!
00657             }
00658             else {
00659                 // ok define one and add it in
00660                 OfxPropertySetHandle props;
00661                 defineRawParam(name, paramType, props);
00662     
00663                 // make out support descriptor class
00664                 paramPtr = new T(name, props);
00665 
00666                 // add it to our map of described ones
00667                 _definedParams[name] = paramPtr;
00668             }
00669             return true;
00670         }
00671 
00672     protected :
00674         PropertySet _paramSetProps;
00675 
00677         OfxParamSetHandle _paramSetHandle;
00678 
00680         std::map<std::string, ParamDescriptor *> _definedParams;
00681 
00683         ParamSetDescriptor(void);
00684 
00686         void setParamSetHandle(OfxParamSetHandle h);
00687 
00689         ParamDescriptor *findPreviouslyDefinedParam(const std::string &name);
00690 
00691     public :
00692         virtual ~ParamSetDescriptor();
00694         ParamDescriptor* getParamDescriptor(const std::string& name) const;
00695 
00697         void setPageParamOrder(PageParamDescriptor &p);
00698 
00700         IntParamDescriptor *defineIntParam(const std::string &name);
00701 
00703         Int2DParamDescriptor *defineInt2DParam(const std::string &name);
00704 
00706         Int3DParamDescriptor *defineInt3DParam(const std::string &name);
00707     
00709         DoubleParamDescriptor *defineDoubleParam(const std::string &name);
00710 
00712         Double2DParamDescriptor *defineDouble2DParam(const std::string &name);
00713 
00715         Double3DParamDescriptor *defineDouble3DParam(const std::string &name);
00716     
00718         StringParamDescriptor *defineStringParam(const std::string &name);
00719 
00721         RGBAParamDescriptor *defineRGBAParam(const std::string &name);
00722 
00724         RGBParamDescriptor *defineRGBParam(const std::string &name);
00725 
00727         BooleanParamDescriptor *defineBooleanParam(const std::string &name);
00728 
00730         ChoiceParamDescriptor *defineChoiceParam(const std::string &name);
00731 
00733         GroupParamDescriptor *defineGroupParam(const std::string &name);
00734 
00736         PageParamDescriptor *definePageParam(const std::string &name);
00737 
00739         PushButtonParamDescriptor *definePushButtonParam(const std::string &name);
00740 
00742         CustomParamDescriptor *defineCustomParam(const std::string &name);
00743     };
00744 
00746 
00747     class Param {
00748     protected :
00749         // don't ever use these!
00750         Param &operator=(const Param &v1) {assert(false); return *this;} 
00751         Param(const Param &v) : _paramSet(v._paramSet) {assert(false); } 
00752         Param(void) {assert(false);}
00753     
00754     protected :
00755         std::string    _paramName;
00756         ParamTypeEnum  _paramType;
00757         PropertySet    _paramProps;
00758         OfxParamHandle _paramHandle;
00759         const ParamSet      *_paramSet; // who do I belong to
00760 
00762         Param(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle);
00763 
00764         friend class ParamSet;
00765     public :
00767         virtual ~Param();
00768 
00770         const std::string &getName(void) const;
00771     
00773         void setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel);
00774 
00776         ParamTypeEnum getType(void) const {return _paramType;}
00777 
00779         void setIsSecret(bool v);
00780 
00782         void setHint(const std::string &hint);
00783 
00785         void setEnabled(bool v);
00786 
00788         void getLabels(std::string &label, std::string &shortLabel, std::string &longLabel) const;
00789     
00791         bool getIsSecret(void) const;
00792 
00794         bool getIsEnable(void) const;
00795     
00797         std::string getHint(void) const;
00798 
00800         std::string getScriptName(void) const;
00801 
00803         GroupParam *getParent(void) const;
00804     };
00805   
00807 
00808     class ValueParam : public Param {
00809     protected :
00810         mDeclareProtectedAssignAndCC(ValueParam);
00811         ValueParam(void) {assert(false);}
00812     protected :
00814         ValueParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle);
00815       
00816         friend class ParamSet;
00817     public :
00819         ~ValueParam();
00820 
00822         void setEvaluateOnChange(bool v);
00823     
00825         bool getIsAnimating(void) const;
00826 
00828         bool getIsAutoKeying(void) const;
00829     
00831         bool getIsPersistant(void) const;
00832     
00834         bool getEvaluateOnChange(void) const;
00835 
00837         CacheInvalidationEnum getCacheInvalidation(void) const;
00838 
00840         unsigned int getNumKeys(void);
00841 
00843         double getKeyTime(int nthKey) throw(OFX::Exception::Suite, std::out_of_range);
00844 
00846         int getKeyIndex(double time, 
00847                         KeySearchEnum searchDir);
00848     
00850         void deleteKeyAtTime(double time);
00851 
00853         void deleteAllKeys(void);
00854     };
00855 
00857 
00858     class IntParam : public ValueParam {
00859     protected :
00860         mDeclareProtectedAssignAndCC(IntParam);
00861         IntParam(void) {assert(false);}
00862 
00863     protected :
00865         IntParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
00866 
00867         friend class ParamSet;
00868     public :
00870         void setDefault(int v);
00871 
00873         void setRange(int min, int max);
00874 
00876         void setDisplayRange(int min, int max);
00877 
00879         void getDefault(int &v);
00880 
00882         int getDefault(void) {int v; getDefault(v); return v;}
00883 
00885         void getRange(int &min, int &max);
00886 
00888         void getDisplayRange(int &min, int &max);
00889 
00891         void  getValue(int &v);
00892 
00894         int getValue(void) {int v; getValue(v); return v;}
00895 
00897         void getValueAtTime(double t, int &v);
00898 
00900         int getValueAtTime(double t) {int v; getValueAtTime(t, v); return v;}
00901 
00903         void setValue(int v);
00904 
00906         void setValueAtTime(double t, int v);
00907     };  
00908 
00910 
00911     class Int2DParam : public ValueParam {
00912     protected :
00913         mDeclareProtectedAssignAndCC(Int2DParam);
00914         Int2DParam(void) {assert(false);}
00915 
00916     protected :
00918         Int2DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
00919 
00920         friend class ParamSet;
00921     public :
00923         void setDefault(int x, int y);
00924 
00926         void setDefault(const OfxPointI &v) {setDefault(v.x, v.y);}
00927 
00929         void setRange(int minX, int minY,
00930                       int maxX, int maxY);
00931 
00933         void setDisplayRange(int minX, int minY,
00934                             int maxX, int maxY);
00935 
00937         void getDefault(int &x, int &y);
00938 
00940         OfxPointI getDefault(void) {OfxPointI v; getDefault(v.x, v.y); return v;}
00941 
00943         void getRange(int &minX, int &minY,
00944                       int& maxX, int &maxY);
00945 
00947         void getDisplayRange(int &minX, int &minY,
00948                             int &maxX, int &maxY);
00949 
00951         void getValue(int &x, int &y);
00952 
00954         OfxPointI getValue(void) {OfxPointI v; getValue(v.x, v.y); return v;}
00955 
00957         void getValueAtTime(double t, int &x, int &y);
00958 
00960         OfxPointI getValueAtTime(double t) {OfxPointI v; getValueAtTime(t, v.x, v.y); return v;}
00961 
00963         void setValue(int x, int y);
00964 
00966         void setValue(const OfxPointI &v) {setValue(v.x, v.y);}
00967 
00969         void setValueAtTime(double t, int x, int y);
00970 
00972         void setValueAtTime(double t, const OfxPointI &v) {setValueAtTime(t, v.x, v.y);}
00973     };  
00974 
00976 
00977     class Int3DParam : public ValueParam {
00978     protected :
00979         mDeclareProtectedAssignAndCC(Int3DParam);
00980         Int3DParam(void) {assert(false);}
00981 
00982     protected :
00984         Int3DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
00985 
00986         friend class ParamSet;
00987     public :
00989         void setDefault(int x, int y, int z);
00990 
00992         void setRange(int minX, int minY, int minZ,
00993                       int maxX, int maxY, int maxZ);
00994 
00996         void setDisplayRange(int minX, int minY, int minZ,
00997                             int maxX, int maxY, int maxZ);
00998 
01000         void getDefault(int &x, int &y, int &z);
01001 
01003         void getRange(int &minX, int &minY, int &minZ,
01004                       int& maxX, int &maxY, int &maxZ);
01005 
01007         void getDisplayRange(int &minX, int &minY, int &minZ,
01008                             int& maxX, int &maxY, int &maxZ);
01009 
01011         void getValue(int &x, int &y, int &z);
01012 
01014         void getValueAtTime(double t, int &x, int &y, int &z);
01015 
01017         void setValue(int x, int y, int z);
01018 
01020         void setValueAtTime(double t, int x, int y, int z);
01021     };  
01022 
01024 
01025     class BaseDoubleParam : public ValueParam {
01026     protected :
01027         mDeclareProtectedAssignAndCC(BaseDoubleParam);
01028         BaseDoubleParam(void) {assert(false);}
01029 
01030     protected :
01032         BaseDoubleParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle);
01033 
01034         friend class ParamSet;
01035     public :
01037         void setIncrement(double v);
01038 
01040         void setDigits(int v);
01041 
01043         void getIncrement(double &v);
01044 
01046         void getDigits(int &v);
01047 
01049         void getDoubleType(DoubleTypeEnum &v);
01050     };
01051 
01053 
01054     class DoubleParam : public BaseDoubleParam {
01055     protected :
01056         mDeclareProtectedAssignAndCC(DoubleParam);
01057         DoubleParam(void) {assert(false);}
01058 
01059     protected :
01061         DoubleParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01062 
01063         friend class ParamSet;
01064     public :
01066         void setDefault(double v);
01067 
01069         void setShowTimeMarker(bool v);
01070 
01072         void setRange(double min, double max);
01073 
01075         void setDisplayRange(double min, double max);
01076 
01078         void getDefault(double &v);
01079 
01081         double getDefault(void) {double v; getDefault(v); return v;}
01082 
01084         void getRange(double &min, double &max);
01085 
01087         void getDisplayRange(double &min, double &max);
01088 
01090         void getValue(double &v);
01091 
01093         double getValue(void) {double v; getValue(v); return v;}
01094 
01096         void getValueAtTime(double t, double &v);
01097 
01099         double getValueAtTime(double t) {double v; getValueAtTime(t, v); return v;}
01100 
01102         void setValue(double v);
01103 
01105         void setValueAtTime(double t, double v);
01106 
01108         void differentiate(double t, double &v);
01109 
01111         double differentiate(double t) {double v; differentiate(t, v); return v;}
01112 
01114         void integrate(double t1, double t2, double &v);
01115 
01117         double integrate(double t1, double t2) {double v; integrate(t1, t2, v); return v;}
01118     };  
01119 
01121 
01122     class Double2DParam : public BaseDoubleParam {
01123     protected :
01124         mDeclareProtectedAssignAndCC(Double2DParam);
01125         Double2DParam(void) {assert(false);}
01126 
01127     protected :
01129         Double2DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01130 
01131         friend class ParamSet;
01132     public :
01134         void setDefault(double x, double y);
01135 
01137         void setRange(double minX, double minY,
01138                       double maxX, double maxY);
01139 
01141         void setDisplayRange(double minX, double minY,
01142                             double maxX, double maxY);
01143 
01145         void getDefault(double &x, double &y);
01146 
01148         void getRange(double &minX, double &minY,
01149                       double& maxX, double &maxY);
01150 
01152         void getDisplayRange(double &minX, double &minY,
01153                             double &maxX, double &maxY);
01154 
01156         void getValue(double &x, double &y);
01157 
01159         void getValueAtTime(double t, double &x, double &y);
01160 
01162         void setValue(double x, double y);
01163 
01165         void setValueAtTime(double t, double x, double y);
01166 
01168         void differentiate(double t, double &x, double &y);
01169 
01171         OfxPointD differentiate(double t) {OfxPointD v; differentiate(t, v.x, v.y); return v;}
01172 
01174         void integrate(double t1, double t2, double &x, double &y);
01175 
01177         OfxPointD integrate(double t1, double t2) {OfxPointD v; integrate(t1, t2, v.x, v.y); return v;}
01178     };  
01179 
01181 
01182     class Double3DParam : public BaseDoubleParam {
01183     protected :
01184         mDeclareProtectedAssignAndCC(Double3DParam);
01185         Double3DParam(void) {assert(false);}
01186 
01187     protected :
01189         Double3DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01190 
01191         friend class ParamSet;
01192     public :
01194         void setDefault(double x, double y, double z);
01195 
01197         void setRange(double minX, double minY, double minZ,
01198                       double maxX, double maxY, double maxZ);
01199 
01201         void setDisplayRange(double minX, double minY, double minZ,
01202                             double maxX, double maxY, double maxZ);
01203 
01205         void getDefault(double &x, double &y, double &z);
01206 
01208         void getRange(double &minX, double &minY, double &minZ,
01209                       double& maxX, double &maxY, double &maxZ);
01210 
01212         void getDisplayRange(double &minX, double &minY, double &minZ,
01213                             double& maxX, double &maxY, double &maxZ);
01214 
01216         void getValue(double &x, double &y, double &z);
01217 
01219         void getValueAtTime(double t, double &x, double &y, double &z);
01220 
01222         void setValue(double x, double y, double z);
01223 
01225         void setValueAtTime(double t, double x, double y, double z);
01226 
01228         void differentiate(double t, double &x, double &y, double &z);
01229 
01231         Ofx3DPointD differentiate(double t) {Ofx3DPointD v; differentiate(t, v.x, v.y, v.z); return v;}
01232 
01234         void integrate(double t1, double t2, double &x, double &y, double &z);
01235 
01237         Ofx3DPointD integrate(double t1, double t2) {Ofx3DPointD v; integrate(t1, t2, v.x, v.y, v.z); return v;}
01238     };  
01239   
01241 
01242     class RGBParam : public ValueParam {
01243     protected :
01244         mDeclareProtectedAssignAndCC(RGBParam);
01245         RGBParam(void) {assert(false);}
01246 
01247     protected :
01249         RGBParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01250 
01251         friend class ParamSet;
01252     public :
01254         void setDefault(double r, double g, double b);
01255 
01257         void getDefault(double &r, double &g, double &b);
01258 
01260         void getValue(double &r, double &g, double &b);
01261 
01263         void getValueAtTime(double t, double &r, double &g, double &b);
01264 
01266         void setValue(double r, double g, double b);
01267 
01269         void setValueAtTime(double t, double r, double g, double b);
01270     };  
01271  
01272   
01274 
01275     class RGBAParam : public ValueParam {
01276     protected :
01277         mDeclareProtectedAssignAndCC(RGBAParam);
01278         RGBAParam(void) {assert(false);}
01279 
01280     protected :
01282         RGBAParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01283 
01284         friend class ParamSet;
01285     public :
01287         void setDefault(double r, double g, double b, double a);
01288 
01290         void getDefault(double &r, double &g, double &b, double &a);
01291 
01293         void getValue(double &r, double &g, double &b, double &a);
01294 
01296         void getValueAtTime(double t, double &r, double &g, double &b, double &a);
01297 
01299         void setValue(double r, double g, double b, double a);
01300 
01302         void setValueAtTime(double t, double r, double g, double b, double a);
01303     };  
01304 
01306 
01307     class StringParam : public ValueParam {
01308     protected :
01309         mDeclareProtectedAssignAndCC(StringParam);
01310         StringParam(void) {assert(false);}
01311 
01312     protected :
01314         StringParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01315 
01316         friend class ParamSet;
01317 
01318     public :
01320         void setDefault(const std::string &v);
01321 
01323         void getDefault(std::string &v);
01324 
01326         void getValue(std::string &v);
01327 
01329         void getValueAtTime(double t, std::string &v);
01330 
01332         void setValue(const std::string &v);
01333 
01335         void setValueAtTime(double t, const std::string &v);
01336     };
01337 
01339 
01340     class ChoiceParam : public ValueParam {
01341     protected :
01342         mDeclareProtectedAssignAndCC(ChoiceParam);
01343         ChoiceParam(void) {assert(false);}
01344 
01345     protected :
01347         ChoiceParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01348 
01349         // so it can make one
01350         friend class ParamSet;
01351     public :
01353         void setDefault(int v);
01354 
01356         void getDefault(int &v);
01357 
01359         int getNOptions(void);
01360 
01362         void appendOption(const std::string &v);
01363     
01365         void resetOptions(void);
01366 
01368         void getValue(int &v);
01369 
01371         void getValueAtTime(double t, int &v);
01372 
01374         void setValue(int v);
01375 
01377         void setValueAtTime(double t, int v);
01378     };
01379 
01381 
01382     class BooleanParam : public ValueParam {
01383     protected :
01384         mDeclareProtectedAssignAndCC(BooleanParam);
01385         BooleanParam(void) {assert(false);}
01386 
01387     protected :
01389         BooleanParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01390 
01391         // so it can make one
01392         friend class ParamSet;
01393     public :
01395         void setDefault(bool v);
01396 
01398         void getDefault(bool &v);
01399 
01401         bool getDefault(void) {bool v; getDefault(v); return v;}
01402 
01404         void getValue(bool &v);
01405 
01407         bool getValue(void) {bool v; getValue(v); return v;}
01408 
01410         void getValueAtTime(double t, bool &v);
01411 
01413         bool getValueAtTime(double t) {bool v; getValueAtTime(t, v); return v;}
01414 
01416         void setValue(bool v);
01417 
01419         void setValueAtTime(double t, bool v);
01420     };
01421 
01423 
01424     class GroupParam : public Param {
01425     protected :
01426         mDeclareProtectedAssignAndCC(GroupParam);
01427         GroupParam(void) {assert(false);}
01428 
01429     protected :
01431         GroupParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01432 
01433         // so it can make one
01434         friend class ParamSet;
01435     public :
01436     };
01437 
01439 
01440     class PageParam : public Param {
01441     protected :
01442         mDeclareProtectedAssignAndCC(PageParam);
01443         PageParam(void) {assert(false);}
01444 
01445     protected :
01447         PageParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01448 
01449         // so it can make one
01450         friend class ParamSet;
01451     public :
01452     };
01453 
01455 
01456     class CustomParam : public ValueParam {
01457     protected :
01458         mDeclareProtectedAssignAndCC(CustomParam);
01459         CustomParam(void) {assert(false);}
01460 
01461     protected :
01463         CustomParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01464 
01465         // so it can make one
01466         friend class ParamSet;
01467     public :
01469         void setDefault(const std::string &v);    
01470 
01472         void getDefault(std::string &v);    
01473 
01475         void getValue(std::string &v);
01476 
01478         void getValueAtTime(double t, std::string &v);
01479 
01481         void setValue(const std::string &v);
01482 
01484         void setValueAtTime(double t, const std::string &v);
01485     };
01486 
01488 
01489     class PushButtonParam : public Param {
01490     protected :
01491         mDeclareProtectedAssignAndCC(PushButtonParam);
01492         PushButtonParam(void) {assert(false);}
01493 
01494     protected :
01496         PushButtonParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle);
01497 
01498         // so it can make one
01499         friend class ParamSet;
01500     public :
01501     };
01502 
01504 
01505     class ParamSet { 
01506     protected :
01507         mDeclareProtectedAssignAndCC(ParamSet);
01508         ParamTypeEnum getParamType(const std::string& name) const;
01509     private :
01511         PropertySet _paramSetProps;
01512 
01514         OfxParamSetHandle _paramSetHandle;
01515 
01517         mutable std::map<std::string, Param *> _fetchedParams;
01518 
01520         Param *findPreviouslyFetchedParam(const std::string &name) const;
01521 
01523         void fetchRawParam(const std::string &name, ParamTypeEnum paramType, OfxParamHandle &handle) const;
01524 
01525 
01527         template <class T> void
01528         fetchParam(const std::string &name, ParamTypeEnum paramType, T * &paramPtr) const
01529         {
01530             paramPtr = NULL;
01531 
01532             // have we made it already in this param set and is it an int?
01533             if(Param *param  = findPreviouslyFetchedParam(name)) {
01534                 if(param->getType() == paramType) {
01535                     paramPtr = (T *) param; // could be a dynamic cast here
01536                 }
01537                 else
01538                   throw OFX::Exception::TypeRequest("Fetching param and attempting to return the wrong type");
01539             }
01540             else {
01541                 // ok define one and add it in
01542                 OfxParamHandle paramHandle;
01543                 fetchRawParam(name, paramType, paramHandle);
01544     
01545                 // make out support descriptor class
01546                 paramPtr = new T(this, name, paramHandle);
01547 
01548                 // add it to our map of described ones
01549                 _fetchedParams[name] = paramPtr;
01550             }
01551         }
01552 
01553     protected :
01555         ParamSet(void);
01556 
01558         void setParamSetHandle(OfxParamSetHandle h);
01559 
01560     public :
01561         virtual ~ParamSet();
01562 
01563         bool paramExists(const std::string& name) const;
01564 
01566         void beginEditBlock(const std::string &name);
01567 
01569         void endEditBlock();
01570 
01571         Param* getParam(const std::string& name) const;
01572 
01574         IntParam *fetchIntParam(const std::string &name) const;
01575 
01577         Int2DParam *fetchInt2DParam(const std::string &name) const;
01578 
01580         Int3DParam *fetchInt3DParam(const std::string &name) const;
01581     
01583         DoubleParam *fetchDoubleParam(const std::string &name) const;
01584 
01586         Double2DParam *fetchDouble2DParam(const std::string &name) const;
01587 
01589         Double3DParam *fetchDouble3DParam(const std::string &name) const;
01590     
01592         StringParam *fetchStringParam(const std::string &name) const;
01593 
01595         RGBAParam *fetchRGBAParam(const std::string &name) const;
01596 
01598         RGBParam *fetchRGBParam(const std::string &name) const;
01599 
01601         BooleanParam *fetchBooleanParam(const std::string &name) const;
01602 
01604         ChoiceParam *fetchChoiceParam(const std::string &name) const;
01605 
01607         GroupParam *fetchGroupParam(const std::string &name) const;
01608 
01610         PageParam *fetchPageParam(const std::string &name) const;
01611 
01613         PushButtonParam *fetchPushButtonParam(const std::string &name) const;
01614 
01616         CustomParam *fetchCustomParam(const std::string &name) const;
01617     };
01618 
01619 };
01620 
01621 // undeclare the protected assign and CC macro
01622 #undef mDeclareProtectedAssignAndCC
01623 
01624 #endif

Generated on Thu Oct 9 13:03:49 2008 for OFX Support by  doxygen 1.3.9.1