#include "ofxCore.h"
#include "ofxImageEffect.h"
#ifdef OFX_SUPPORTS_PARAMETRIC
#include "ofxParametricParam.h"
#endif
#include "ofxhBinary.h"
#include "ofxhPropertySuite.h"
#include "ofxhParam.h"
#include "ofxhImageEffect.h"
#include "ofxOld.h"
#include <assert.h>
#include <float.h>
#include <limits.h>
#include <stdarg.h>
namespace OFX {
namespace Host {
namespace Param {
Base::Base(const std::string &name, const std::string& type) :
_paramName(name),
_paramType(type)
{
assert(_paramType.c_str());
}
Base::Base(const std::string &name, const std::string &type, const Property::Set &properties) :
_paramName(name),
_paramType(type),
_properties(properties)
{
assert(_paramType.c_str());
}
Base::~Base() {}
OfxParamHandle Base::getHandle() const {
return (OfxParamHandle)this;
}
OfxPropertySetHandle Base::getPropHandle() const {
return _properties.getHandle();
}
Property::Set &Base::getProperties() {
return _properties;
}
const Property::Set &Base::getProperties() const {
return _properties;
}
const std::string &Base::getType() const {
return _paramType;
}
const std::string &Base::getName() const {
return _paramName;
}
const std::string &Base::getParentName() const {
return _properties.getStringProperty(kOfxParamPropParent);
}
const std::string &Base::getScriptName() const {
return _properties.getStringProperty(kOfxParamPropScriptName);
}
const std::string &Base::getLabel() const {
return _properties.getStringProperty(kOfxPropLabel);
}
const std::string &Base::getLongLabel() const {
return _properties.getStringProperty(kOfxPropLongLabel);
}
const std::string &Base::getShortLabel() const {
return _properties.getStringProperty(kOfxPropShortLabel);
}
const std::string &Base::getDoubleType() const {
return _properties.getStringProperty(kOfxParamPropDoubleType, 0);
}
const std::string &Base::getDefaultCoordinateSystem() const {
return _properties.getStringProperty(kOfxParamPropDefaultCoordinateSystem, 0);
}
const std::string &Base::getHint() const {
return _properties.getStringProperty(kOfxParamPropHint, 0);
}
bool Base::getEnabled() const {
return _properties.getIntProperty(kOfxParamPropEnabled, 0) != 0;
}
bool Base::getSecret() const {
return _properties.getIntProperty(kOfxParamPropSecret, 0) != 0;
}
bool Base::getIsPersistant() const {
return _properties.getIntProperty(kOfxParamPropPersistant, 0) != 0;
}
bool Base::getEvaluateOnChange() const {
return _properties.getIntProperty(kOfxParamPropEvaluateOnChange, 0) != 0;
}
bool Base::getCanUndo() const {
if (_properties.fetchProperty(kOfxParamPropCanUndo)) {
return _properties.getIntProperty(kOfxParamPropCanUndo) != 0;
}
return false;
}
bool Base::getCanAnimate() const {
if (_properties.fetchProperty(kOfxParamPropAnimates)) {
return _properties.getIntProperty(kOfxParamPropAnimates) != 0;
}
return false;
}
struct TypeMap {
const char *paramType;
Property::TypeEnum propType;
int propDimension;
};
static
bool isDoubleParam(const std::string ¶mType)
{
return paramType == kOfxParamTypeDouble ||
paramType == kOfxParamTypeDouble2D ||
paramType == kOfxParamTypeDouble3D
#ifdef OFX_SUPPORTS_PARAMETRIC
|| paramType == kOfxParamTypeParametric
#endif
;
}
bool isColourParam(const std::string ¶mType)
{
return
paramType == kOfxParamTypeRGBA ||
paramType == kOfxParamTypeRGB;
}
bool isIntParam(const std::string ¶mType)
{
return paramType == kOfxParamTypeInteger ||
paramType == kOfxParamTypeInteger2D ||
paramType == kOfxParamTypeInteger3D;
}
static const TypeMap typeMap[] = {
{ kOfxParamTypeInteger, Property::eInt, 1 },
{ kOfxParamTypeDouble, Property::eDouble, 1 },
{ kOfxParamTypeBoolean, Property::eInt, 1 },
{ kOfxParamTypeChoice, Property::eInt, 1 },
{ kOfxParamTypeRGBA, Property::eDouble, 4 },
{ kOfxParamTypeRGB, Property::eDouble, 3 },
{ kOfxParamTypeDouble2D, Property::eDouble, 2 },
{ kOfxParamTypeInteger2D, Property::eInt, 2 },
{ kOfxParamTypeDouble3D, Property::eDouble, 3 },
{ kOfxParamTypeInteger3D, Property::eInt, 3 },
{ kOfxParamTypeString, Property::eString, 1 },
{ kOfxParamTypeCustom, Property::eString, 1 },
{ kOfxParamTypeGroup, Property::eNone, 0 },
{ kOfxParamTypePage, Property::eNone, 0 },
{ kOfxParamTypePushButton,Property::eNone, 0 },
#ifdef OFX_SUPPORTS_PARAMETRIC
{ kOfxParamTypeParametric,Property::eDouble, 0 },
#endif
{ 0, Property::eNone, 0 }
};
bool isStandardType(const std::string &type)
{
const TypeMap *tm = typeMap;
while (tm->paramType) {
if (tm->paramType == type)
return true;
tm++;
}
return false;
}
static
bool findType(const std::string paramType, Property::TypeEnum &propType, int &propDim)
{
const TypeMap *tm = typeMap;
while (tm->paramType) {
if (tm->paramType == paramType) {
propType = tm->propType;
propDim = tm->propDimension;
return true;
}
tm++;
}
return false;
}
Descriptor::Descriptor(const std::string &type,
const std::string &name) : Base(name, type)
{
const char *ctype = type.c_str();
const char *cname = name.c_str();
Property::PropSpec universalProps[] = {
{ kOfxPropType, Property::eString, 1, true, kOfxTypeParameter },
{ kOfxParamPropSecret, Property::eInt, 1, false, "0"},
{ kOfxParamPropHint, Property::eString, 1, false, ""},
{ kOfxParamPropScriptName, Property::eString, 1, false, cname },
{ kOfxParamPropParent, Property::eString, 1, false, "" },
{ kOfxParamPropEnabled, Property::eInt, 1, false, "1" },
{ kOfxParamPropDataPtr, Property::ePointer, 1, false, 0 },
{ kOfxParamPropType, Property::eString, 1, true, ctype },
{ kOfxPropName, Property::eString, 1, false, cname },
{ kOfxPropLabel, Property::eString, 1, false, cname },
{ kOfxPropShortLabel, Property::eString, 1, false, cname },
{ kOfxPropLongLabel, Property::eString, 1, false, cname },
{ kOfxPropIcon, Property::eString, 2, false, "" },
Property::propSpecEnd
};
_properties.addProperties(universalProps);
}
void Descriptor::addStandardParamProps(const std::string &type)
{
Property::TypeEnum propType = Property::eString;
int propDim = 1;
findType(type, propType, propDim);
static const Property::PropSpec allString[] = {
{ kOfxParamPropStringMode, Property::eString, 1, false, kOfxParamStringIsSingleLine },
{ kOfxParamPropStringFilePathExists, Property::eInt, 1, false, "1" },
Property::propSpecEnd
};
static const Property::PropSpec allChoice[] = {
{ kOfxParamPropChoiceOption, Property::eString, 0, false, "" },
Property::propSpecEnd
};
static const Property::PropSpec allCustom[] = {
{ kOfxParamPropCustomInterpCallbackV1, Property::ePointer, 1, false, 0 },
Property::propSpecEnd
};
static const Property::PropSpec allPage[] = {
{ kOfxParamPropPageChild, Property::eString, 0, false, "" },
Property::propSpecEnd
};
static const Property::PropSpec allGroup[] = {
{ kOfxParamPropGroupOpen, Property::eInt, 1, false, "1" },
Property::propSpecEnd
};
# ifdef OFX_SUPPORTS_PARAMETRIC
static const Property::PropSpec allParametric[] = {
{ kOfxParamPropParametricDimension, Property::eInt, 1, false, "1" },
{ kOfxParamPropParametricUIColour, Property::eDouble, 0, false, "" },
{ kOfxParamPropParametricInteractBackground,Property::ePointer, 1, false, 0 },
{ kOfxParamPropParametricRange, Property::eDouble, 2, false, "0" },
Property::propSpecEnd
};
# endif
if (propType != Property::eNone) {
addValueParamProps(type, propType, propDim);
}
if (type == kOfxParamTypeString) {
_properties.addProperties(allString);
}
if (isDoubleParam(type) || isIntParam(type) || isColourParam(type)) {
addNumericParamProps(type, propType, propDim);
}
if (type != kOfxParamTypeGroup && type != kOfxParamTypePage) {
addInteractParamProps(type);
}
if (type == kOfxParamTypeChoice) {
_properties.addProperties(allChoice);
}
if (type == kOfxParamTypeCustom) {
_properties.addProperties(allCustom);
}
if (type == kOfxParamTypePage) {
_properties.addProperties(allPage);
}
if (type == kOfxParamTypeGroup) {
_properties.addProperties(allGroup);
}
# ifdef OFX_SUPPORTS_PARAMETRIC
if (type == kOfxParamTypeParametric) {
_properties.addProperties(allParametric);
_properties.setDoubleProperty(kOfxParamPropParametricRange, 0., 0);
_properties.setDoubleProperty(kOfxParamPropParametricRange, 1., 1);
}
# endif
}
void Descriptor::addInteractParamProps(const std::string &)
{
static const Property::PropSpec allButGroupPageProps[] = {
{ kOfxParamPropInteractV1, Property::ePointer, 1, false, 0 },
{ kOfxParamPropInteractSize, Property::eDouble, 2, false, "0" },
{ kOfxParamPropInteractSizeAspect, Property::eDouble, 1, false, "1" },
{ kOfxParamPropInteractMinimumSize, Property::eDouble, 2, false, "10" },
{ kOfxParamPropInteractPreferedSize,Property::eInt, 2, false, "10" },
Property::propSpecEnd
};
_properties.addProperties(allButGroupPageProps);
}
void Descriptor::addValueParamProps(const std::string &type, Property::TypeEnum valueType, int dim)
{
static const Property::PropSpec invariantProps[] = {
{ kOfxParamPropIsAnimating, Property::eInt, 1, false, "0" },
{ kOfxParamPropIsAutoKeying,Property::eInt, 1, false, "0" },
{ kOfxParamPropPersistant, Property::eInt, 1, false, "1" },
{ kOfxParamPropEvaluateOnChange, Property::eInt, 1, false, "1" },
# ifdef kOfxParamPropPluginMayWrite
{ kOfxParamPropPluginMayWrite, Property::eInt, 1, false, "0" }, # endif
{ kOfxParamPropCanUndo, Property::eInt, 1, false, "1" },
{ kOfxParamPropCacheInvalidation, Property::eString, 1, false, kOfxParamInvalidateValueChange },
Property::propSpecEnd
};
bool animates = type != kOfxParamTypeCustom && type != kOfxParamTypeString && type != kOfxParamTypeBoolean && type != kOfxParamTypeChoice;
Property::PropSpec variantProps[] = {
{ kOfxParamPropAnimates, Property::eInt, 1, false, animates ? "1" : "0" },
{ kOfxParamPropDefault, valueType, dim, false, valueType == Property::eString ? "" : "0" },
Property::propSpecEnd
};
_properties.addProperties(invariantProps);
_properties.addProperties(variantProps);
}
void Descriptor::addNumericParamProps(const std::string &type, Property::TypeEnum valueType, int dim)
{
static std::string dbl_minstr, dbl_maxstr, int_minstr, int_maxstr;
static bool doneOne = false;
if(!doneOne) {
std::ostringstream dbl_min, dbl_max, int_min, int_max;
doneOne = true;
dbl_min << -DBL_MAX; dbl_max << DBL_MAX;
int_min << INT_MIN;
int_max << INT_MAX;
dbl_minstr = dbl_min.str();
dbl_maxstr = dbl_max.str();
int_minstr = int_min.str();
int_maxstr = int_max.str();
}
Property::PropSpec allNumeric[] = {
{ kOfxParamPropDisplayMin, valueType, dim, false, isColourParam(type) ? "0" : (valueType == Property::eDouble ? dbl_minstr : int_minstr).c_str() },
{ kOfxParamPropDisplayMax, valueType, dim, false, isColourParam(type) ? "1" : (valueType == Property::eDouble ? dbl_maxstr : int_maxstr).c_str() },
{ kOfxParamPropMin, valueType, dim, false, (valueType == Property::eDouble ? dbl_minstr : int_minstr).c_str() },
{ kOfxParamPropMax, valueType, dim, false, (valueType == Property::eDouble ? dbl_maxstr : int_maxstr).c_str() },
Property::propSpecEnd
};
_properties.addProperties(allNumeric);
if (valueType == Property::eDouble) {
static const Property::PropSpec allDouble[] = {
{ kOfxParamPropIncrement, Property::eDouble, 1, false, "1" },
{ kOfxParamPropDigits, Property::eInt, 1, false, "2" },
Property::propSpecEnd
};
_properties.addProperties(allDouble);
}
if(isDoubleParam(type)) {
static const Property::PropSpec allDouble[] = {
{ kOfxParamPropDoubleType, Property::eString, 1, false, kOfxParamDoubleTypePlain },
{ kOfxParamPropDefaultCoordinateSystem, Property::eString, 1, false, kOfxParamCoordinatesCanonical },
Property::propSpecEnd
};
_properties.addProperties(allDouble);
if(dim == 1) {
static const Property::PropSpec allDouble1D[] = {
{ kOfxParamPropShowTimeMarker, Property::eInt, 1, false, "0" },
Property::propSpecEnd
};
_properties.addProperties(allDouble1D);
}
}
if ((isDoubleParam(type) || isIntParam(type)) && (dim == 2 || dim == 3
#ifdef OFX_SUPPORTS_PARAMETRIC
|| dim == 0
#endif
)) {
static const Property::PropSpec all2D3D[] = {
{ kOfxParamPropDimensionLabel, Property::eString, dim, false, "" },
Property::propSpecEnd
};
_properties.addProperties(all2D3D);
_properties.setStringProperty(kOfxParamPropDimensionLabel, "x", 0);
_properties.setStringProperty(kOfxParamPropDimensionLabel, "y", 1);
if (dim == 3) {
_properties.setStringProperty(kOfxParamPropDimensionLabel, "z", 2);
}
}
if (isColourParam(type)) {
static const Property::PropSpec allColor[] = {
{ kOfxParamPropDimensionLabel, Property::eString, dim, false, "" },
Property::propSpecEnd
};
_properties.addProperties(allColor);
_properties.setStringProperty(kOfxParamPropDimensionLabel, "r", 0);
_properties.setStringProperty(kOfxParamPropDimensionLabel, "g", 1);
_properties.setStringProperty(kOfxParamPropDimensionLabel, "b", 2);
if (dim == 4) {
_properties.setStringProperty(kOfxParamPropDimensionLabel, "a", 3);
}
}
}
BaseSet::~BaseSet() {}
SetDescriptor::SetDescriptor()
{
}
OfxParamSetHandle BaseSet::getParamSetHandle() const
{
return (OfxParamSetHandle)this;
}
SetDescriptor::~SetDescriptor()
{
std::list<Descriptor *>::iterator i;
for(i = _paramList.begin(); i != _paramList.end(); ++i) {
if(*i)
delete (*i);
}
}
const std::map<std::string, Descriptor*> &SetDescriptor::getParams() const
{
return _paramMap;
}
const std::list<Descriptor*> &SetDescriptor::getParamList() const
{
return _paramList;
}
void SetDescriptor::addParam(const std::string &name, Descriptor *p) {
_paramList.push_back(p);
_paramMap[name] = p;
}
Descriptor *SetDescriptor::paramDefine(const char *paramType,
const char *name)
{
if(!isStandardType(paramType))
return NULL;
Descriptor *desc = new Descriptor(paramType, name);
desc->addStandardParamProps(paramType);
addParam(name, desc);
return desc;
}
Instance::~Instance() {}
Instance::Instance(Descriptor& descriptor, Param::SetInstance* paramSet)
: Base(descriptor.getName(), descriptor.getType(), descriptor.getProperties())
, _paramSetInstance(paramSet)
, _parentInstance(0)
{
_properties.addNotifyHook(kOfxParamPropEnabled, this);
_properties.addNotifyHook(kOfxParamPropSecret, this);
_properties.addNotifyHook(kOfxPropLabel, this);
_properties.addNotifyHook(kOfxParamPropMin, this);
_properties.addNotifyHook(kOfxParamPropMax, this);
_properties.addNotifyHook(kOfxParamPropDisplayMin, this);
_properties.addNotifyHook(kOfxParamPropDisplayMax, this);
_properties.addNotifyHook(kOfxParamPropEvaluateOnChange, this);
}
void Instance::setEnabled()
{
}
void Instance::setSecret()
{
}
void Instance::setLabel()
{
}
void Instance::setRange()
{
}
void Instance::setDisplayRange()
{
}
void Instance::setEvaluateOnChange()
{
}
OfxStatus Instance::getV(va_list )
{
return kOfxStatErrUnsupported;
}
OfxStatus Instance::getV(OfxTime , va_list )
{
return kOfxStatErrUnsupported;
}
OfxStatus Instance::setV(va_list )
{
return kOfxStatErrUnsupported;
}
OfxStatus Instance::setV(OfxTime , va_list )
{
return kOfxStatErrUnsupported;
}
OfxStatus Instance::deriveV(OfxTime , va_list )
{
return kOfxStatErrUnsupported;
}
OfxStatus Instance::integrateV(OfxTime , OfxTime , va_list )
{
return kOfxStatErrUnsupported;
}
void Instance::notify(const std::string &name, bool , int ) OFX_EXCEPTION_SPEC
{
if (name == kOfxPropLabel) {
setLabel();
}
if (name == kOfxParamPropEnabled) {
setEnabled();
}
if (name == kOfxParamPropSecret) {
setSecret();
}
if (name == kOfxParamPropMin || name == kOfxParamPropMax) {
setRange();
}
if (name == kOfxParamPropDisplayMin || name == kOfxParamPropDisplayMax) {
setDisplayRange();
}
if (name == kOfxParamPropEvaluateOnChange) {
setEvaluateOnChange();
}
}
OfxStatus Instance::copyFrom(const Instance &, OfxTime , const OfxRangeD* ) {
return kOfxStatErrMissingHostFeature;
}
void Instance::setParentInstance(Instance* instance){
_parentInstance = instance;
}
Instance* Instance::getParentInstance(){
return _parentInstance;
}
OfxStatus KeyframeParam::getNumKeys(unsigned int &) const {
return kOfxStatErrMissingHostFeature;
}
OfxStatus KeyframeParam::getKeyTime(int , OfxTime& ) const {
return kOfxStatErrMissingHostFeature;
}
OfxStatus KeyframeParam::getKeyIndex(OfxTime , int , int & ) const {
return kOfxStatErrMissingHostFeature;
}
OfxStatus KeyframeParam::deleteKey(OfxTime ) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus KeyframeParam::deleteAllKeys() {
return kOfxStatErrMissingHostFeature;
}
void GroupInstance::setChildren(std::vector<Param::Instance*> children)
{
_children = children;
for (std::vector<Param::Instance*>::iterator it=children.begin(); it!=children.end(); ++it) {
if(*it){
(*it)->setParentInstance(this);
}
}
}
const std::vector<Param::Instance*> &GroupInstance::getChildren() const
{
return _children;
}
const std::map<int,Param::Instance*> &PageInstance::getChildren() const
{
if(_children.size() == 0 )
{
int nChildren = _properties.getDimension(kOfxParamPropPageChild);
for(int i=0;i<nChildren;i++)
{
std::string childName = _properties.getStringProperty(kOfxParamPropPageChild,i);
Param::Instance* child = _paramSetInstance->getParam(childName);
if(child)
_children[i]=child;
}
}
return _children;
}
ChoiceInstance::ChoiceInstance(Descriptor& descriptor, Param::SetInstance* instance)
: Instance(descriptor,instance)
{
_properties.addNotifyHook(kOfxParamPropChoiceOption, this);
}
void ChoiceInstance::setOption(int )
{
}
OfxStatus ChoiceInstance::getV(va_list arg)
{
int *value = va_arg(arg, int*);
OfxStatus stat = get(*value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus ChoiceInstance::getV(OfxTime time, va_list arg)
{
int *value = va_arg(arg, int*);
OfxStatus stat = get(time, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus ChoiceInstance::setV(va_list arg)
{
int value = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(value);
}
OfxStatus ChoiceInstance::setV(OfxTime time, va_list arg)
{
int value = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(time, value);
}
void ChoiceInstance::notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC
{
Instance::notify(name, single, num);
if (name == kOfxParamPropChoiceOption) {
setOption(num);
}
}
OfxStatus IntegerInstance::derive(OfxTime , int&) {
return kOfxStatErrUnsupported;
}
OfxStatus IntegerInstance::integrate(OfxTime , OfxTime , int&) {
return kOfxStatErrUnsupported;
}
OfxStatus IntegerInstance::getV(va_list arg)
{
int *value = va_arg(arg, int*);
OfxStatus stat = get(*value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus IntegerInstance::getV(OfxTime time, va_list arg)
{
int *value = va_arg(arg, int*);
OfxStatus stat = get(time, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus IntegerInstance::setV(va_list arg)
{
int value = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(value);
}
OfxStatus IntegerInstance::setV(OfxTime time, va_list arg)
{
int value = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(time, value);
}
OfxStatus IntegerInstance::deriveV(OfxTime time, va_list arg)
{
int *value = va_arg(arg, int*);
OfxStatus stat = derive(time, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus IntegerInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
int *value = va_arg(arg, int*);
OfxStatus stat = integrate(time1, time2, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus DoubleInstance::getV(va_list arg)
{
double *value = va_arg(arg, double*);
OfxStatus stat = get(*value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus DoubleInstance::getV(OfxTime time, va_list arg)
{
double *value = va_arg(arg, double*);
OfxStatus stat = get(time, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus DoubleInstance::setV(va_list arg)
{
double value = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(value);
}
OfxStatus DoubleInstance::setV(OfxTime time, va_list arg)
{
double value = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(time, value);
}
OfxStatus DoubleInstance::deriveV(OfxTime time, va_list arg)
{
double *value = va_arg(arg, double*);
OfxStatus stat = derive(time, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus DoubleInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
double *value = va_arg(arg, double*);
OfxStatus stat = integrate(time1, time2, *value);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus BooleanInstance::getV(va_list arg)
{
bool v;
OfxStatus stat = get(v);
int *value = va_arg(arg, int*);
*value = v;
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus BooleanInstance::getV(OfxTime time, va_list arg)
{
bool v;
OfxStatus stat = get(time, v);
int *value = va_arg(arg, int*);
*value = v;
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus BooleanInstance::setV(va_list arg)
{
bool value = va_arg(arg, int) != 0;
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(value);
}
OfxStatus BooleanInstance::setV(OfxTime time, va_list arg)
{
bool value = va_arg(arg, int) != 0;
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(time, value);
}
OfxStatus RGBAInstance::derive(OfxTime , double&, double&, double&, double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus RGBAInstance::integrate(OfxTime , OfxTime , double&,double&,double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus RGBAInstance::getV(va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
double *a = va_arg(arg, double*);
OfxStatus stat = get(*r, *g, *b, *a);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b << ' ' << *a;
}
# endif
return stat;
}
OfxStatus RGBAInstance::getV(OfxTime time, va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
double *a = va_arg(arg, double*);
OfxStatus stat = get(time, *r, *g, *b, *a);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b << ' ' << *a;
}
# endif
return stat;
}
OfxStatus RGBAInstance::setV(va_list arg)
{
double r = va_arg(arg, double);
double g = va_arg(arg, double);
double b = va_arg(arg, double);
double a = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << r << ',' << g << ',' << b << ',' << a << ')';
# endif
return set(r, g, b, a);
}
OfxStatus RGBAInstance::setV(OfxTime time, va_list arg)
{
double r = va_arg(arg, double);
double g = va_arg(arg, double);
double b = va_arg(arg, double);
double a = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << r << ',' << g << ',' << b << ',' << a << ')';
# endif
return set(time, r, g, b, a);
}
OfxStatus RGBAInstance::deriveV(OfxTime time, va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
double *a = va_arg(arg, double*);
OfxStatus stat = derive(time, *r, *g, *b, *a);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b << ' ' << *a;
}
# endif
return stat;
}
OfxStatus RGBAInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
double *a = va_arg(arg, double*);
OfxStatus stat = integrate(time1, time2, *r, *g, *b, *a);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b << ' ' << *a;
}
# endif
return stat;
}
OfxStatus RGBInstance::derive(OfxTime , double&,double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus RGBInstance::integrate(OfxTime , OfxTime , double&,double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus RGBInstance::getV(va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
OfxStatus stat = get(*r, *g, *b);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b;
}
# endif
return stat;
}
OfxStatus RGBInstance::getV(OfxTime time, va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
OfxStatus stat = get(time, *r, *g, *b);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b;
}
# endif
return stat;
}
OfxStatus RGBInstance::setV(va_list arg)
{
double r = va_arg(arg, double);
double g = va_arg(arg, double);
double b = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << r << ',' << g << ',' << b << ')';
# endif
return set(r, g, b);
}
OfxStatus RGBInstance::setV(OfxTime time, va_list arg)
{
double r = va_arg(arg, double);
double g = va_arg(arg, double);
double b = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << r << ',' << g << ',' << b << ')';
# endif
return set(time, r, g, b);
}
OfxStatus RGBInstance::deriveV(OfxTime time, va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
OfxStatus stat = derive(time, *r, *g, *b);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b;
}
# endif
return stat;
}
OfxStatus RGBInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
double *r = va_arg(arg, double*);
double *g = va_arg(arg, double*);
double *b = va_arg(arg, double*);
OfxStatus stat = integrate(time1, time2, *r, *g, *b);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *r << ' ' << *g << ' ' << *b;
}
# endif
return stat;
}
OfxStatus Double2DInstance::derive(OfxTime , double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Double2DInstance::integrate(OfxTime , OfxTime , double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Double2DInstance::getV(va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
OfxStatus stat = get(*value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Double2DInstance::getV(OfxTime time, va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
OfxStatus stat = get(time, *value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Double2DInstance::setV(va_list arg)
{
double value1 = va_arg(arg, double);
double value2 = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ')';
# endif
return set(value1, value2);
}
OfxStatus Double2DInstance::setV(OfxTime time, va_list arg)
{
double value1 = va_arg(arg, double);
double value2 = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ')';
# endif
return set(time, value1, value2);
}
OfxStatus Double2DInstance::deriveV(OfxTime time, va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
OfxStatus stat = derive(time, *value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Double2DInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
OfxStatus stat = integrate(time1, time2, *value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Integer2DInstance::derive(OfxTime , int&,int&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Integer2DInstance::integrate(OfxTime , OfxTime , int&,int&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Integer2DInstance::getV(va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
OfxStatus stat = get(*value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Integer2DInstance::getV(OfxTime time, va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
OfxStatus stat = get(time, *value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Integer2DInstance::setV(va_list arg)
{
int value1 = va_arg(arg, int);
int value2 = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ')';
# endif
return set(value1, value2);
}
OfxStatus Integer2DInstance::setV(OfxTime time, va_list arg)
{
int value1 = va_arg(arg, int);
int value2 = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ')';
# endif
return set(time, value1, value2);
}
OfxStatus Integer2DInstance::deriveV(OfxTime time, va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
OfxStatus stat = derive(time, *value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Integer2DInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
OfxStatus stat = integrate(time1, time2, *value1, *value2);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2;
}
# endif
return stat;
}
OfxStatus Double3DInstance::derive(OfxTime , double&,double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Double3DInstance::integrate(OfxTime , OfxTime , double&,double&,double&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Double3DInstance::getV(va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
double *value3 = va_arg(arg, double*);
OfxStatus stat = get(*value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Double3DInstance::getV(OfxTime time, va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
double *value3 = va_arg(arg, double*);
OfxStatus stat = get(time, *value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Double3DInstance::setV(va_list arg)
{
double value1 = va_arg(arg, double);
double value2 = va_arg(arg, double);
double value3 = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ',' << value3 << ')';
# endif
return set(value1, value2, value3);
}
OfxStatus Double3DInstance::setV(OfxTime time, va_list arg)
{
double value1 = va_arg(arg, double);
double value2 = va_arg(arg, double);
double value3 = va_arg(arg, double);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ',' << value3 << ')';
# endif
return set(time, value1, value2, value3);
}
OfxStatus Double3DInstance::deriveV(OfxTime time, va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
double *value3 = va_arg(arg, double*);
OfxStatus stat = derive(time, *value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Double3DInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
double *value1 = va_arg(arg, double*);
double *value2 = va_arg(arg, double*);
double *value3 = va_arg(arg, double*);
OfxStatus stat = integrate(time1, time2, *value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Integer3DInstance::derive(OfxTime , int&,int&,int&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Integer3DInstance::integrate(OfxTime , OfxTime , int&,int&,int&) {
return kOfxStatErrMissingHostFeature;
}
OfxStatus Integer3DInstance::getV(va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
int *value3 = va_arg(arg, int*);
OfxStatus stat = get(*value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Integer3DInstance::getV(OfxTime time, va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
int *value3 = va_arg(arg, int*);
OfxStatus stat = get(time, *value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Integer3DInstance::setV(va_list arg)
{
int value1 = va_arg(arg, int);
int value2 = va_arg(arg, int);
int value3 = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ',' << value3 << ')';
# endif
return set(value1, value2, value3);
}
OfxStatus Integer3DInstance::setV(OfxTime time, va_list arg)
{
int value1 = va_arg(arg, int);
int value2 = va_arg(arg, int);
int value3 = va_arg(arg, int);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << '(' << value1 << ',' << value2 << ',' << value3 << ')';
# endif
return set(time, value1, value2, value3);
}
OfxStatus Integer3DInstance::deriveV(OfxTime time, va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
int *value3 = va_arg(arg, int*);
OfxStatus stat = derive(time, *value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus Integer3DInstance::integrateV(OfxTime time1, OfxTime time2, va_list arg)
{
int *value1 = va_arg(arg, int*);
int *value2 = va_arg(arg, int*);
int *value3 = va_arg(arg, int*);
OfxStatus stat = integrate(time1, time2, *value1, *value2, *value3);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value1 << ' ' << *value2 << ' ' << *value3;
}
# endif
return stat;
}
OfxStatus StringInstance::getV(va_list arg)
{
const char **value = va_arg(arg, const char **);
OfxStatus stat = get(_returnValue); *value = _returnValue.c_str();
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus StringInstance::getV(OfxTime time, va_list arg)
{
const char **value = va_arg(arg, const char **);
OfxStatus stat = get(time, _returnValue); *value = _returnValue.c_str();
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *value;
}
# endif
return stat;
}
OfxStatus StringInstance::setV(va_list arg)
{
char *value = va_arg(arg, char*);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(value);
}
OfxStatus StringInstance::setV(OfxTime time, va_list arg)
{
char *value = va_arg(arg, char*);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << value;
# endif
return set(time, value);
}
SetInstance::SetInstance()
{}
SetInstance::~SetInstance()
{
std::list<Instance *>::iterator i;
for(i = _paramList.begin(); i != _paramList.end(); ++i) {
if(*i)
delete (*i);
}
}
const std::map<std::string, Instance*> &SetInstance::getParams() const
{
return _params;
}
const std::list<Instance*> &SetInstance::getParamList() const
{
return _paramList;
}
OfxStatus SetInstance::addParam(const std::string& name, Instance* instance)
{
if(_params.find(name)==_params.end()){
_params[name] = instance;
_paramList.push_back(instance);
}
else
return kOfxStatErrExists;
return kOfxStatOK;
}
static OfxStatus paramDefine(OfxParamSetHandle paramSet,
const char *paramType,
const char *name,
OfxPropertySetHandle *propertySet)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramDefine - " << paramSet << ' ' << paramType << ' ' << name << ' ' << propertySet << " ...";
# endif
SetDescriptor *paramSetDescriptor = reinterpret_cast<SetDescriptor*>(paramSet);
if (!paramSetDescriptor) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
Descriptor *desc = paramSetDescriptor->paramDefine(paramType, name);
if(desc) {
if (propertySet)
*propertySet = desc->getPropHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatOK) << std::endl;
# endif
return kOfxStatOK;
} else {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrUnsupported) << std::endl;
# endif
return kOfxStatErrUnsupported;
}
}
static OfxStatus paramGetHandle(OfxParamSetHandle paramSet,
const char *name,
OfxParamHandle *param,
OfxPropertySetHandle *propertySet)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetHandle - " << paramSet << ' ' << name << ' ' << param << ' ' << propertySet << " ...";
# endif
BaseSet *baseSet = reinterpret_cast<BaseSet*>(paramSet);
if (!baseSet) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
SetInstance *setInstance = dynamic_cast<SetInstance*>(baseSet);
if(setInstance){
const std::map<std::string,Instance*>& params = setInstance->getParams();
std::map<std::string,Instance*>::const_iterator it = params.find(name);
if(it==params.end()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' '<< StatStr(kOfxStatErrUnknown) << std::endl;
# endif
return kOfxStatErrUnknown;
}
if (param) {
*param = (it->second)->getHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << *param;
# endif
}
if(propertySet) {
*propertySet = (it->second)->getPropHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << *propertySet;
# endif
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatOK) << std::endl;
# endif
return kOfxStatOK;
}
SetDescriptor *setDescriptor = dynamic_cast<SetDescriptor*>(baseSet);
if(setDescriptor){
const std::map<std::string,Descriptor*>& params = setDescriptor->getParams();
std::map<std::string,Descriptor*>::const_iterator it = params.find(name);
if(it==params.end()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' '<< StatStr(kOfxStatErrUnknown) << std::endl;
# endif
return kOfxStatErrUnknown;
}
if (param) {
*param = (it->second)->getHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << *param;
# endif
}
if(propertySet) {
*propertySet = (it->second)->getPropHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << *propertySet;
# endif
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatOK) << std::endl;
# endif
return kOfxStatOK;
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
static OfxStatus paramSetGetPropertySet(OfxParamSetHandle paramSet,
OfxPropertySetHandle *propHandle)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramSetGetPropertySet - " << paramSet << ' ' << propHandle << " ...";
# endif
BaseSet *baseSet = reinterpret_cast<BaseSet*>(paramSet);
if (baseSet) {
if (propHandle) {
*propHandle = baseSet->getParamSetProps().getHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << *propHandle;
# endif
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatOK) << std::endl;
# endif
return kOfxStatOK;
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
static OfxStatus paramGetPropertySet(OfxParamHandle param,
OfxPropertySetHandle *propHandle)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetPropertySet - " << param << ' ' << propHandle << " ...";
# endif
Param::Instance *paramInstance = reinterpret_cast<Param::Instance*>(param);
if(paramInstance && paramInstance->verifyMagic()){
if (propHandle) {
*propHandle = paramInstance->getPropHandle();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << *propHandle;
# endif
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatOK) << std::endl;
# endif
return kOfxStatOK;
} else {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
}
static OfxStatus paramGetValue(OfxParamHandle paramHandle,
...)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetValue - " << paramHandle << " ...";
# endif
Instance *paramInstance = reinterpret_cast<Instance*>(paramHandle);
if(!paramInstance || !paramInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
va_list ap;
va_start(ap,paramHandle);
OfxStatus stat = kOfxStatErrUnsupported;
try {
stat = paramInstance->getV(ap);
}
catch(...) {}
va_end(ap);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramGetValueAtTime(OfxParamHandle paramHandle,
OfxTime time,
...)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetValueAtTime - " << paramHandle << ' ' << time << " ...";
# endif
Instance *paramInstance = reinterpret_cast<Instance*>(paramHandle);
if(!paramInstance || !paramInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
va_list ap;
va_start(ap, time);
OfxStatus stat = kOfxStatErrUnsupported;
try {
stat = paramInstance->getV(time, ap);
}
catch(...) {}
va_end(ap);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramGetDerivative(OfxParamHandle paramHandle,
OfxTime time,
...)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetDerivative - " << paramHandle << ' ' << time << " ...";
# endif
Instance *paramInstance = reinterpret_cast<Instance*>(paramHandle);
if(!paramInstance || !paramInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
va_list ap;
va_start(ap, time);
OfxStatus stat = kOfxStatErrUnsupported;
try {
stat = paramInstance->deriveV(time, ap);
}
catch(...) {}
va_end(ap);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramGetIntegral(OfxParamHandle paramHandle,
OfxTime time1, OfxTime time2,
...)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetIntegral - " << paramHandle << ' ' << time1 << ' ' << time2 << " ...";
# endif
Instance *paramInstance = reinterpret_cast<Instance*>(paramHandle);
if(!paramInstance || !paramInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
va_list ap;
va_start(ap, time2);
OfxStatus stat = kOfxStatErrUnsupported;
try {
stat = paramInstance->integrateV(time1, time2, ap);
}
catch(...) {}
va_end(ap);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramSetValue(OfxParamHandle paramHandle,
...)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramSetValue - " << paramHandle << ' ';
# endif
Instance *paramInstance = reinterpret_cast<Instance*>(paramHandle);
if(!paramInstance || !paramInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << " ... " << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
va_list ap;
va_start(ap, paramHandle);
OfxStatus stat = kOfxStatErrUnsupported;
try {
stat = paramInstance->setV(ap);
}
catch(...) {}
va_end(ap);
if (stat == kOfxStatOK) {
paramInstance->getParamSetInstance()->paramChangedByPlugin(paramInstance);
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << " ... " << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramSetValueAtTime(OfxParamHandle paramHandle,
OfxTime time, ...)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramSetValueAtTime - " << paramHandle << ' ' << time << ' ';
# endif
Instance *paramInstance = reinterpret_cast<Instance*>(paramHandle);
if(!paramInstance || !paramInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << " ... " << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
va_list ap;
va_start(ap, time);
OfxStatus stat = kOfxStatErrUnsupported;
try {
stat = paramInstance->setV(time, ap);
}
catch(...) {}
va_end(ap);
if (stat == kOfxStatOK) {
paramInstance->getParamSetInstance()->paramChangedByPlugin(paramInstance);
}
# ifdef OFX_DEBUG_PARAMETERS
std::cout << " ... " << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramGetNumKeys(OfxParamHandle paramHandle,
unsigned int *numberOfKeys)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetNumKeys - " << paramHandle << " ...";
# endif
Param::Instance *pInstance = reinterpret_cast<Param::Instance*>(paramHandle);
if (!pInstance || !pInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
KeyframeParam *paramInstance = dynamic_cast<KeyframeParam*>(pInstance);
if(!paramInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = paramInstance->getNumKeys(*numberOfKeys);
# ifdef OFX_DEBUG_PARAMETERS
if (stat == kOfxStatOK) {
std::cout << ' ' << *numberOfKeys;
}
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramGetKeyTime(OfxParamHandle paramHandle,
unsigned int nthKey,
OfxTime *time)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetKeyTime - " << paramHandle << " ...";
# endif
Param::Instance *pInstance = reinterpret_cast<Param::Instance*>(paramHandle);
if (!pInstance || !pInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
KeyframeParam *paramInstance = dynamic_cast<KeyframeParam*>(pInstance);
if(!paramInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = paramInstance->getKeyTime(nthKey,*time);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramGetKeyIndex(OfxParamHandle paramHandle,
OfxTime time,
int direction,
int *index)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramGetKeyIndex - " << paramHandle << " ...";
# endif
Param::Instance *pInstance = reinterpret_cast<Param::Instance*>(paramHandle);
if (!pInstance || !pInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
KeyframeParam *paramInstance = dynamic_cast<KeyframeParam*>(pInstance);
if(!paramInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = paramInstance->getKeyIndex(time,direction,*index);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramDeleteKey(OfxParamHandle paramHandle,
OfxTime time)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramDeleteKey - " << paramHandle << " ...";
# endif
Param::Instance *pInstance = reinterpret_cast<Param::Instance*>(paramHandle);
if (!pInstance || !pInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
KeyframeParam *paramInstance = dynamic_cast<KeyframeParam*>(pInstance);
if(!paramInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = paramInstance->deleteKey(time);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramDeleteAllKeys(OfxParamHandle paramHandle)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramDeleteAllKeys - " << paramHandle << " ...";
# endif
Param::Instance *pInstance = reinterpret_cast<Param::Instance*>(paramHandle);
if (!pInstance || !pInstance->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
KeyframeParam *paramInstance = dynamic_cast<KeyframeParam*>(pInstance);
if(!paramInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = paramInstance->deleteAllKeys();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramCopy(OfxParamHandle paramTo,
OfxParamHandle paramFrom,
OfxTime dstOffset, const OfxRangeD *frameRange)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramCopy - " << paramTo << " ...";
# endif
Instance *paramInstanceTo = reinterpret_cast<Instance*>(paramTo);
Instance *paramInstanceFrom = reinterpret_cast<Instance*>(paramFrom);
if(!paramInstanceTo || !paramInstanceTo->verifyMagic() ||
!paramInstanceFrom || !paramInstanceFrom->verifyMagic()) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = paramInstanceTo->copyFrom(*paramInstanceFrom,dstOffset,frameRange);
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramEditBegin(OfxParamSetHandle paramSet, const char *name)
{
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramEditBegin - " << paramSet << ' ' << name << " ...";
# endif
SetInstance *setInstance = reinterpret_cast<SetInstance*>(paramSet);
if(!setInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = setInstance->editBegin(std::string(name));
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static OfxStatus paramEditEnd(OfxParamSetHandle paramSet) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << "OFX: paramEditEnd - " << paramSet << " ...";
# endif
SetInstance *setInstance = reinterpret_cast<SetInstance*>(paramSet);
if(!setInstance) {
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(kOfxStatErrBadHandle) << std::endl;
# endif
return kOfxStatErrBadHandle;
}
OfxStatus stat = setInstance->editEnd();
# ifdef OFX_DEBUG_PARAMETERS
std::cout << ' ' << StatStr(stat) << std::endl;
# endif
return stat;
}
static const OfxParameterSuiteV1 gParamSuiteV1 = {
paramDefine,
paramGetHandle,
paramSetGetPropertySet,
paramGetPropertySet,
paramGetValue,
paramGetValueAtTime,
paramGetDerivative,
paramGetIntegral,
paramSetValue,
paramSetValueAtTime,
paramGetNumKeys,
paramGetKeyTime,
paramGetKeyIndex,
paramDeleteKey,
paramDeleteAllKeys,
paramCopy,
paramEditBegin,
paramEditEnd
};
const void *GetSuite(int version) {
if(version ==1)
return &gParamSuiteV1;
return NULL;
}
}
}
}