Skip to content

Commit 473aa34

Browse files
committed
Work on testProperties: now tests compliance for many propsets
Signed-off-by: Gary Oberbrunner <[email protected]>
1 parent aef99de commit 473aa34

File tree

9 files changed

+6007
-2187
lines changed

9 files changed

+6007
-2187
lines changed

Examples/TestProps/testProperties.cpp

Lines changed: 271 additions & 134 deletions
Large diffs are not rendered by default.

include/ofx-props.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ propertySets:
3434
- OfxImageEffectPropSupportedComponents
3535
- OfxImageEffectPropSupportedContexts
3636
- OfxImageEffectPropMultipleClipDepths
37-
- OfxImageEffectPropOpenCLSupported
37+
- OfxImageEffectPropOpenCLSupported | host_optional=true
3838
- OfxImageEffectPropSupportsMultipleClipPARs
3939
- OfxImageEffectPropSetableFrameRate
4040
- OfxImageEffectPropSetableFielding
@@ -43,36 +43,36 @@ propertySets:
4343
- OfxParamHostPropSupportsChoiceAnimation
4444
- OfxParamHostPropSupportsBooleanAnimation
4545
- OfxParamHostPropSupportsCustomAnimation
46-
- OfxParamHostPropSupportsStrChoice
47-
- OfxParamHostPropSupportsStrChoiceAnimation
46+
- OfxParamHostPropSupportsStrChoice | host_optional=true
47+
- OfxParamHostPropSupportsStrChoiceAnimation | host_optional=true
4848
- OfxParamHostPropMaxParameters
4949
- OfxParamHostPropMaxPages
5050
- OfxParamHostPropPageRowColumnCount
51-
- OfxPropHostOSHandle
52-
- OfxParamHostPropSupportsParametricAnimation
53-
- OfxImageEffectInstancePropSequentialRender
51+
- OfxPropHostOSHandle | host_optional=true
52+
- OfxParamHostPropSupportsParametricAnimation | host_optional=true
53+
- OfxImageEffectInstancePropSequentialRender | host_optional=true
5454
- OfxImageEffectPropOpenGLRenderSupported
55-
- OfxImageEffectPropRenderQualityDraft
56-
- OfxImageEffectHostPropNativeOrigin
57-
- OfxImageEffectPropColourManagementAvailableConfigs
58-
- OfxImageEffectPropColourManagementStyle
55+
- OfxImageEffectPropRenderQualityDraft | host_optional=true
56+
- OfxImageEffectHostPropNativeOrigin | host_optional=true
57+
- OfxImageEffectPropColourManagementAvailableConfigs | host_optional=true
58+
- OfxImageEffectPropColourManagementStyle | host_optional=true
5959
EffectDescriptor:
6060
write: plugin
6161
props:
6262
- OfxPropType
6363
- OfxPropLabel
6464
- OfxPropShortLabel
6565
- OfxPropLongLabel
66-
- OfxPropVersion
67-
- OfxPropVersionLabel
68-
- OfxPropPluginDescription
66+
- OfxPropVersion | host_optional=true
67+
- OfxPropVersionLabel | host_optional=true
68+
- OfxPropPluginDescription | host_optional=true
6969
- OfxImageEffectPropSupportedContexts
7070
- OfxImageEffectPluginPropGrouping
7171
- OfxImageEffectPluginPropSingleInstance
7272
- OfxImageEffectPluginRenderThreadSafety
7373
- OfxImageEffectPluginPropHostFrameThreading
7474
- OfxImageEffectPluginPropOverlayInteractV1
75-
- OfxImageEffectPropOpenCLSupported
75+
- OfxImageEffectPropOpenCLSupported | host_optional=true
7676
- OfxImageEffectPropSupportsMultiResolution
7777
- OfxImageEffectPropSupportsTiles
7878
- OfxImageEffectPropTemporalClipAccess
@@ -84,11 +84,11 @@ propertySets:
8484
- OfxImageEffectPropClipPreferencesSlaveParam
8585
- OfxImageEffectPropOpenGLRenderSupported
8686
- OfxPluginPropFilePath | write=host
87-
- OfxOpenGLPropPixelDepth
87+
- OfxOpenGLPropPixelDepth | host_optional=true
8888
- OfxImageEffectPluginPropOverlayInteractV2
89-
- OfxImageEffectPropColourManagementAvailableConfigs
90-
- OfxImageEffectPropColourManagementStyle
91-
- OfxImageEffectPropNoSpatialAwareness
89+
- OfxImageEffectPropColourManagementAvailableConfigs | host_optional=true
90+
- OfxImageEffectPropColourManagementStyle | host_optional=true
91+
- OfxImageEffectPropNoSpatialAwareness | host_optional=true
9292
EffectInstance:
9393
write: host
9494
props:
@@ -735,9 +735,8 @@ properties:
735735
type: bool
736736
dimension: 1
737737
OfxPluginPropFilePath:
738-
type: enum
738+
type: string
739739
dimension: 1
740-
values: ['false', 'true', 'needed']
741740
OfxImageEffectPropOpenGLRenderSupported:
742741
type: enum
743742
dimension: 1

openfx-cpp/include/openfx/ofxLog.h

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ class Logger {
5454
*/
5555
static void setLogHandler(LogHandler handler);
5656

57+
/**
58+
* @brief Set a context string (e.g., plugin name) to prepend to all log messages
59+
*
60+
* @param context The context string (typically plugin name)
61+
*/
62+
static void setContext(const std::string& context);
63+
64+
/**
65+
* @brief Get the current context string
66+
*
67+
* @return The current context string
68+
*/
69+
static std::string getContext();
70+
5771
/**
5872
* @brief Log an informational message
5973
*
@@ -146,6 +160,7 @@ class Logger {
146160
// Static member variables (inline in C++17)
147161
static inline LogHandler g_logHandler = defaultLogHandler;
148162
static inline std::mutex g_logMutex;
163+
static inline std::string g_context;
149164
};
150165

151166
// Inline implementations for non-template methods
@@ -160,6 +175,16 @@ inline void Logger::setLogHandler(LogHandler handler) {
160175
}
161176
}
162177

178+
inline void Logger::setContext(const std::string& context) {
179+
std::lock_guard<std::mutex> lock(g_logMutex);
180+
g_context = context;
181+
}
182+
183+
inline std::string Logger::getContext() {
184+
std::lock_guard<std::mutex> lock(g_logMutex);
185+
return g_context;
186+
}
187+
163188
inline void Logger::info(const std::string& message) { log(Level::Info, message); }
164189

165190
inline void Logger::warn(const std::string& message) { log(Level::Warning, message); }
@@ -170,7 +195,14 @@ inline void Logger::log(Level level, const std::string& message) {
170195
auto timestamp = std::chrono::system_clock::now();
171196

172197
std::lock_guard<std::mutex> lock(g_logMutex);
173-
g_logHandler(level, timestamp, message);
198+
199+
// Prepend context if set
200+
std::string finalMessage = message;
201+
if (!g_context.empty()) {
202+
finalMessage = "[" + g_context + "] " + message;
203+
}
204+
205+
g_logHandler(level, timestamp, finalMessage);
174206
}
175207

176208
inline void Logger::defaultLogHandler(Level level, std::chrono::system_clock::time_point timestamp,
@@ -186,9 +218,6 @@ inline void Logger::defaultLogHandler(Level level, std::chrono::system_clock::ti
186218
localtime_r(&time, &local_time);
187219
#endif
188220

189-
// Stream to write log message
190-
std::ostream& os = (level == Level::Error) ? std::cerr : std::cout;
191-
192221
// Level prefix
193222
const char* levelStr = "";
194223
switch (level) {
@@ -203,8 +232,9 @@ inline void Logger::defaultLogHandler(Level level, std::chrono::system_clock::ti
203232
break;
204233
}
205234

206-
// Write formatted log message
207-
os << "[" << std::put_time(&local_time, "%Y-%m-%d %H:%M:%S") << "][" << levelStr << "] " << message
235+
// Write formatted log message to stdout (not stderr)
236+
// In plugin contexts, stderr may not be captured by host applications
237+
std::cout << "[" << std::put_time(&local_time, "%Y-%m-%d %H:%M:%S") << "][" << levelStr << "] " << message
208238
<< std::endl;
209239
}
210240

0 commit comments

Comments
 (0)