diff --git a/app/pluginSupport/OlivePlugin.cpp b/app/pluginSupport/OlivePlugin.cpp index b0360367a..8395979f4 100644 --- a/app/pluginSupport/OlivePlugin.cpp +++ b/app/pluginSupport/OlivePlugin.cpp @@ -24,20 +24,192 @@ olive::plugin::OlivePlugin::~OlivePlugin() free(p); } } -void olive::plugin::OlivePlugin::setProp(QString key, int index, Value val) +OfxStatus olive::plugin::OlivePlugin::getProp(QString key, int index, + char **str) { - props[key][index]=std::move(val); -} - -OfxStatus olive::plugin::OlivePlugin::getProp(QString key, int index, Value &val) -{ - if (props.contains(key)) { - if (props[key].contains(index)) { - val = props[key][index]; + *str=nullptr; + if (stringProps.contains(key)) { + if (stringProps[key].count()>index) { + *str=stringProps[key][index]; return kOfxStatOK; } return kOfxStatErrBadIndex; } return kOfxStatErrUnknown; } +OfxStatus olive::plugin::OlivePlugin::getPropN(QString key, + char ***str) +{ + *str=nullptr; + if (stringProps.contains(key)) { + *str=stringProps[key].data(); + return kOfxStatOK; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::getProp(QString key, int index, + void **str) +{ + *str=nullptr; + if (pointerProps.contains(key)) { + if (pointerProps[key].count()>index) { + *str=pointerProps[key][index]; + return kOfxStatOK; + } + return kOfxStatErrBadIndex; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::getPropN(QString key, + void ***p) +{ + *p=nullptr; + if (pointerProps.contains(key)) { + *p=pointerProps[key].data(); + return kOfxStatOK; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::getProp(QString key, int index, + int* p) +{ + *p=0; + if (intProps.contains(key)) { + if (intProps[key].count()>index) { + *p=intProps[key][index]; + return kOfxStatOK; + } + return kOfxStatErrBadIndex; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::getPropN(QString key, + int **p) +{ + *p=nullptr; + if (intProps.contains(key)) { + *p=intProps[key].data(); + return kOfxStatOK; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::getProp(QString key, int index, + double* p) +{ + *p=0; + if (doubleProps.contains(key)) { + if (doubleProps[key].count()>index) { + *p=doubleProps[key][index]; + return kOfxStatOK; + } + return kOfxStatErrBadIndex; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::getPropN(QString key, + double **p) +{ + *p=nullptr; + if (doubleProps.contains(key)) { + *p=doubleProps[key].data(); + return kOfxStatOK; + } + return kOfxStatErrUnknown; +} +OfxStatus olive::plugin::OlivePlugin::setProp(QString key, int index, char *str) +{ + char *p=(char*)calloc(strlen(str)+1,sizeof(char)); + strcpy(p,str); + if (stringProps.contains(key)) { + if (stringProps[key].count()>index) { + stringProps[key].insert(index, p); + return kOfxStatOK; + } + stringProps[key].emplace_back(p); + return kOfxStatOK; + } + QVector vec; + vec.emplace_back(str); + stringProps[key]=vec; + return kOfxStatOK; +} +OfxStatus olive::plugin::OlivePlugin::setPropN(QString key, int count, char **strs) +{ + QVector vector; + for (int i=0;iindex) { + pointerProps[key].insert(index, p); + return kOfxStatOK; + } + pointerProps[key].emplace_back(p); + return kOfxStatOK; + } + QVector vec; + vec.emplace_back(p); + pointerProps[key]=vec; + return kOfxStatOK; +} +OfxStatus olive::plugin::OlivePlugin::setPropN(QString key,int count, void **ps) +{ + QVector vector; + vector.reserve(count); + memcpy(vector.data(), ps, sizeof(void *)*count); + pointerProps[key]=vector; + return kOfxStatOK; +} +OfxStatus olive::plugin::OlivePlugin::setProp(QString key, int index, int p) +{ + if (intProps.contains(key)) { + if (intProps[key].count()>index) { + intProps[key].insert(index, p); + return kOfxStatOK; + } + intProps[key].emplace_back(p); + return kOfxStatOK; + } + QVector vec; + vec.emplace_back(p); + intProps[key]=vec; + return kOfxStatOK; +} +OfxStatus olive::plugin::OlivePlugin::setPropN(QString key,int count, int *ps) +{ + QVector vector; + vector.reserve(count); + memcpy(vector.data(), ps, sizeof(int)*count); + intProps[key]=vector; + return kOfxStatOK; +} +OfxStatus olive::plugin::OlivePlugin::setProp(QString key, int index, double p) +{ + if (doubleProps.contains(key)) { + if (doubleProps[key].count()>index) { + doubleProps[key].insert(index, p); + return kOfxStatOK; + } + doubleProps[key].emplace_back(p); + return kOfxStatOK; + } + QVector vec; + vec.emplace_back(p); + doubleProps[key]=vec; + return kOfxStatOK; +} +OfxStatus olive::plugin::OlivePlugin::setPropN(QString key,int count, double *ps) +{ + QVector vector; + vector.reserve(count); + memcpy(vector.data(), ps, sizeof(doubleProps)*count); + doubleProps[key]=vector; + return kOfxStatOK; +} diff --git a/app/pluginSupport/OlivePlugin.h b/app/pluginSupport/OlivePlugin.h index 1a3f7de6c..6ccc9f4dd 100644 --- a/app/pluginSupport/OlivePlugin.h +++ b/app/pluginSupport/OlivePlugin.h @@ -18,12 +18,15 @@ #ifndef OLIVE_PLUGIN_H #define OLIVE_PLUGIN_H +#include "OlivePlugin.h" #include "ofxCore.h" - +#include #include #include #include +#include #include +#include namespace olive { namespace plugin @@ -32,257 +35,6 @@ class Value; enum class Type { FLOAT, STRING, INT, POINTER, ARRAY, NONE }; -class Array { -private: - Type type; - int strSize=0; - char** strings; - QVector pointers; - QVector ints; - QVector floats; -public: - Array() - { - type=Type::NONE; - } - Array(const int *data, size_t size) - { - this->type=Type::INT; - ints.reserve(size); - std::copy(data, data+size, ints.data()); - } - Array(const double *data, size_t size) - { - this->type=Type::FLOAT; - floats.reserve(size); - std::copy(data, data+size, floats.data()); - } - Array(void * const* data, size_t size) - { - this->type=Type::POINTER; - pointers.reserve(size); - std::copy(data, data+size, pointers.data()); - } - Array(const char * const *data, size_t size) - { - strings=(char**)malloc(sizeof(char *)*size); - for (int i=0;itype=Type::INT; - ints.clear(); - ints.reserve(size); - std::copy(data, data+size, ints.data()); - } - void setArray(double *data, size_t size) - { - this->type=Type::FLOAT; - floats.clear(); - floats.reserve(size); - std::copy(data, data+size, floats.data()); - } - void setArray(void *const*data, size_t size) - { - this->type=Type::POINTER; - pointers.reserve(size); - pointers.clear(); - std::copy(data, data+size, pointers.data()); - } - void setArray(const char * const *data, size_t size) - { - for (int i=0;istrSize;i++) { - free(strings[i]); - } - free(strings); - strings=nullptr; - strings=(char**)malloc(sizeof(char *)*size); - for (int i=0;i> props; + QMap> stringProps; + QMap> intProps; + QMap> doubleProps; + QMap> pointerProps; std::list mems; }; } diff --git a/app/pluginSupport/Property.cpp b/app/pluginSupport/Property.cpp index 68a1f8d5d..fad450e9e 100644 --- a/app/pluginSupport/Property.cpp +++ b/app/pluginSupport/Property.cpp @@ -18,17 +18,17 @@ #include "node/plugins/Plugin.h" #include +#include +#include OfxStatus propSetPointer(OfxPropertySetHandle properties, const char *property, int index, void *value) { - olive::plugin::Value val; if (properties->plugin) { if (index<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, value); - return kOfxStatOK; + return properties->plugin->setProp(property, index, value); } return kOfxStatErrBadHandle; } @@ -36,13 +36,11 @@ OfxStatus propSetPointer(OfxPropertySetHandle properties, OfxStatus propSetString(OfxPropertySetHandle properties, const char *property, int index, const char *value) { - olive::plugin::Value val; if (properties->plugin) { if (index<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, QString(value)); - return kOfxStatOK; + return properties->plugin->setProp(property, index, const_cast(value)); } return kOfxStatErrBadHandle; } @@ -50,13 +48,12 @@ OfxStatus propSetString(OfxPropertySetHandle properties, OfxStatus propSetDouble(OfxPropertySetHandle properties, const char *property, int index, double value) { - olive::plugin::Value val; + if (properties->plugin) { if (index<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, static_cast(value)); - return kOfxStatOK; + return properties->plugin->setProp(property, index, value); } return kOfxStatErrBadHandle; } @@ -64,29 +61,24 @@ OfxStatus propSetDouble(OfxPropertySetHandle properties, OfxStatus propSetInt(OfxPropertySetHandle properties, const char *property, int index, int value) { - olive::plugin::Value val; + if (properties->plugin) { if (index<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, value); - return kOfxStatOK; + return properties->plugin->setProp(property, index, value); } return kOfxStatErrBadHandle; } OfxStatus propSetPointerN(OfxPropertySetHandle properties, - const char *property, int index, int count, void * const*value) + const char *property, int count, void * const*value) { - olive::plugin::Value val; - olive::plugin::Array array(value,count); - val.setValue(array); if (properties->plugin) { - if (index<0) { + if (count<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, val); - return kOfxStatOK; + return properties->plugin->setPropN(property, count, const_cast(value)); } return kOfxStatErrBadHandle; } @@ -94,47 +86,132 @@ OfxStatus propSetPointerN(OfxPropertySetHandle properties, OfxStatus propSetStringN(OfxPropertySetHandle properties, const char *property, int index, int count,const char *const *value) { - olive::plugin::Value val; - olive::plugin::Array array(value,count); - val.setValue(array); if (properties->plugin) { - if (index<0) { + if (count<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, val); - return kOfxStatOK; + return properties->plugin->setPropN(property, count, const_cast(value)); } return kOfxStatErrBadHandle; } OfxStatus propSetDoubleN(OfxPropertySetHandle properties, - const char *property, int index, int count, const double* value) + const char *property,int count, const double* value) { - olive::plugin::Value val; - olive::plugin::Array array(value,count); - val.setValue(array); if (properties->plugin) { - if (index<0) { + if (count<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, val); - return kOfxStatOK; + return properties->plugin->setPropN(property, count, const_cast(value)); } return kOfxStatErrBadHandle; } OfxStatus propSetIntN(OfxPropertySetHandle properties, const char *property, - int index, int count, const int *value) + int count, const int *value) +{ + if (properties->plugin) { + if (count<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->setPropN(property, count, const_cast(value)); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propGetPointer(OfxPropertySetHandle properties, + const char *property, int index, void **value) { - olive::plugin::Value val; - olive::plugin::Array array(value, count); - val.setValue(array); if (properties->plugin) { if (index<0) { return kOfxStatErrBadIndex; } - properties->plugin->setProp(property, index, val); - return kOfxStatOK; + return properties->plugin->getProp(property, index, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propGetString(OfxPropertySetHandle properties, + const char *property, int index, char **value) +{ + std::any val; + if (properties->plugin) { + if (index<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getProp(property, index, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propGetDouble(OfxPropertySetHandle properties, + const char *property, int index, double *value) +{ + if (properties->plugin) { + if (index<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getProp(property, index, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propGetInt(OfxPropertySetHandle properties, const char *property, + int index, int *value) +{ + if (properties->plugin) { + if (index<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getProp(property, index, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propGetPointerN(OfxPropertySetHandle properties, + const char *property, int count, void ***value) +{ + if (properties->plugin) { + if (count<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getPropN(property, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propGetStringN(OfxPropertySetHandle properties, + const char *property, int count, char ***value) +{ + if (properties->plugin) { + if (count<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getPropN(property, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propSetDoubleN(OfxPropertySetHandle properties, + const char *property, int index, int count, double** value) +{ + if (properties->plugin) { + if (count<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getPropN(property, value); + } + return kOfxStatErrBadHandle; +} + +OfxStatus propSetIntN(OfxPropertySetHandle properties, const char *property, + int index, int count, int **value) +{ + if (properties->plugin) { + if (count<0) { + return kOfxStatErrBadIndex; + } + return properties->plugin->getPropN(property, value); } return kOfxStatErrBadHandle; }