Gocator Development Kit
 All Classes Files Functions Variables Typedefs Friends Modules Pages
GdkTool.h
Go to the documentation of this file.
1 /**
2  * @file GdkTool.h
3  * @brief Declares the GdkTool class.
4  *
5  * Copyright (C) 2015-2022 by LMI Technologies Inc. All rights reserved.
6  */
7 #ifndef GDK_TOOL_H
8 #define GDK_TOOL_H
9 
10 #include <Gdk/GdkDef.h>
11 #include <Gdk/Tools/GdkToolInfo.h>
12 #include <Gdk/Config/GdkToolCfg.h>
13 #include <Gdk/Tools/GdkToolInput.h>
20 
21 typedef struct GdkToolEnv
22 {
23  GdkSensorInfo sensorInfo;
24  kBool isEmulator; // DEPRECATED. Internal only -- do not use.
25  kBool isAccelerated; // DEPRECATED. Internal only -- do not use.
26 } GdkToolEnv;
27 
28 /**
29 * Base class for a tool implementation.
30 *
31 * @class GdkTool
32 * @extends kObject
33 * @ingroup Gdk-Tools
34 */
35 typedef kObject GdkTool;
36 
37 /**
38 * Returns the tool configuration.
39 *
40 * @public @memberof GdkTool
41 * @param tool Tool object.
42 * @return Current configuration object.
43 */
44 GdkFx(GdkToolCfg) GdkTool_Config(GdkTool tool);
45 
46 /**
47 * Returns the message processing memory allocator. Use this allocator to
48 * allocate objects used while processing scan data messages
49 * (ie. objects created within the VProcess() function).
50 * In cases where lots of memory need to be allocated/deallocated, the message
51 * allocator returned by this function can give better performance compared
52 * to using other allocators.
53 *
54 * @public @memberof GdkTool
55 * @param tool Tool object.
56 * @return Message processor allocator.
57 */
59 
60 /**
61 * Returns the sensor information.
62 *
63 * @public @memberof GdkTool
64 * @param tool Tool object.
65 * @return Current sensor info.
66 */
68 
69 /**
70 * Returns the index for the named input.
71 *
72 * @public @memberof GdkTool
73 * @param tool Tool object.
74 * @param name String name of input data set.
75 * @return Index of input data with matching name;
76 * index 0 is reserved for the primary data inputs, including BOTTOM/RIGHT.
77 * (see #GDK_DATA_PRIMARY_INPUT_INDEX).
78 * If available, index >= #GDK_DATA_SECONDARY_INPUT_START_INDEX is reserved for the secondary input data (eg. parameters, features etc).
79 */
80 GdkFx(kSize) GdkTool_InputDataIndex(GdkTool tool, const kChar* name);
81 
82 /**
83 * Find the index of a measurement by its type name.
84 *
85 * If there are multiple measurements of the same type, only the index of
86 * first instance will be returned. A full list of measurements can be found
87 * in the tool config (see GdkTool_Config).
88 *
89 * @public @memberof GdkTool
90 * @param tool Tool object.
91 * @param typeName Type name of the measurement.
92 * @return Index of measurement. kSIZE_NULL if not found.
93 */
94 GdkFx(kSize) GdkTool_MeasurementIndexByType(GdkTool tool, const kChar* typeName);
95 
96 /**
97 * Find the index of a feature by its type name.
98 *
99 * If there are multiple features of the same type, only the index of
100 * first instance will be returned. A full list of features can be found
101 * in the tool config. See GdkTool_Config.
102 *
103 * The type name of the feature should not be confused with its data type.
104 * See GdkToolInfo_AddFeature.
105 *
106 * @public @memberof GdkTool
107 * @param tool Tool object.
108 * @param typeName Type name of the feature.
109 * @return Index of feature. kSIZE_NULL if not found.
110 */
111 GdkFx(kSize) GdkTool_FeatureIndexByType(GdkTool tool, const kChar* typeName);
112 
113 /**
114 * Find the index of a tool data output by its type name.
115 *
116 * If there are multiple tool data outputs of the same type, only the index of
117 * first instance will be returned. A full list of tool data outputs can be found
118 * in the tool config. See GdkTool_Config.
119 *
120 * The type name of the tool data output should not be confused with its data type.
121 * See GdkToolInfo_AddToolDataOutput.
122 *
123 * @public @memberof GdkTool
124 * @param tool Tool object.
125 * @param typeName Type name of the tool data output.
126 * @return Index of tool data output. kSIZE_NULL if not found.
127 */
128 GdkFx(kSize) GdkTool_DataOutputIndexByType(GdkTool tool, const kChar* typeName);
129 
130 /**
131 * Applies the currently available anchoring parameters to a profile region.
132 *
133 * @public @memberof GdkTool
134 * @param tool Tool object.
135 * @param original Pointer to original region.
136 * @param anchored Pointer to receive the anchor-adjusted region.
137 * @return Operation status.
138 */
139 GdkFx(kStatus) GdkTool_AnchorProfileRegion(GdkTool tool, const GdkRegionXZ64f* original, GdkRegionXZ64f* anchored);
140 
141 /**
142 * Applies the currently available anchoring parameters to a surface region.
143 *
144 * @public @memberof GdkTool
145 * @param tool Tool object.
146 * @param original Pointer to original region.
147 * @param anchored Pointer to receive the anchor-adjusted region.
148 * @return Operation status.
149 */
150 GdkFx(kStatus) GdkTool_AnchorSurfaceRegion(GdkTool tool, const GdkRegion3d64f* original, GdkRegion3d64f* anchored);
151 
152 /**
153 * Applies the currently available anchoring parameters to a point set region.
154 *
155 * @public @memberof GdkTool
156 * @param tool Tool object.
157 * @param original Pointer to original list of kPoint3d64f points.
158 * @param anchored Pointer to receive the anchor-adjusted list of points.
159 * @return Operation status.
160 */
161 GdkFx(kStatus) GdkTool_AnchorPointSetRegion(GdkTool tool, const kArrayList* original, kArrayList* anchored);
162 
163 /**
164 * Set up the tool instance in preparation for sensor scanning.
165 *
166 * @public @memberof GdkTool
167 * @param tool Tool object.
168 * @param sensorInfo Sensor info specific for this tool instance.
169 * @param toolCfg Tool configuration data for this instance.
170 * @return Operation status.
171 */
172 GdkFx(kStatus) GdkTool_SetupForScanning(GdkTool tool, GdkSensorInfo sensorInfo, GdkToolCfg toolCfg);
173 
174 /**
175 * Determines whether or not this tools should show up in the list of tools.
176 *
177 * This function can be used to alter the availability of the sensor based
178 * on specific user needs.
179 *
180 * @public @memberof GdkTool
181 * @param env Tool environment.
182 * @return Operation status.
183 */
184 GdkFx(kBool) GdkTool_VIsVisible(const GdkToolEnv* env);
185 
186 /**
187 * Initializes newly added tool instance's configuration data.
188 *
189 * @public @memberof GdkTool
190 * @param tool GDK tool instance
191 * @param toolConfig Configuration object.
192 * @return Operation status.
193 */
195 
196 /**
197 * Initializes newly added tool intance's measurement configuration data.
198 *
199 * @public @memberof GdkTool
200 * @param tool GDK tool instance
201 * @param measurementConfig Measurement configuration object (to be updated).
202 * @return Operation status.
203 */
205 
206 /**
207 * Initializes newly added tool instance's feature configuration data.
208 *
209 * @public @memberof GdkTool
210 * @param tool GDK tool instance
211 * @param featureConfig Feature configuration object (to be updated).
212 * @return Operation status.
213 */
215 
216 /**
217 * Initializes newly added tool instance's data output configuration data.
218 *
219 * @public @memberof GdkTool
220 * @param tool GDK tool instance
221 * @param toolDataOutputConfig Data output configuration object (to be updated).
222 * @return Operation status.
223 */
225 
226 /**
227 * Update the tool instance's configuration due to configuration file changes.
228 *
229 * The framework calls this function after the configuration has changed. The
230 * tool implementation has the opportunity to update configuration attributes
231 * that may need to be dynamically updated. For example the implementation
232 * may use the value of a parameter to update the min and max constraints of
233 * another parameter.
234 * This function can be called for configuration changes not related to the tool instance.
235 *
236 * @public @memberof GdkTool
237 * @param tool GDK tool instance
238 * @param toolConfig Tool configuration object.
239 * @return Operation status.
240 */
242 
243 /**
244 * Calculates the tool instance's region for a given data output.
245 *
246 * Override this function to implement customized calculation of data regions for specific
247 * outputs. If this function is unimplemented, or does not alter the input region, a default
248 * region is used by the framework.
249 * This function can be called for configuration changes not related to the tool instance.
250 *
251 * @public @memberof GdkTool
252 * @param tool GDK tool instance
253 * @param outputConfig Data output configuration object.
254 * @param region Pointer to receive new region. The value is initialized to the default region.
255 * @return Operation status.
256 */
257 GdkFx(kStatus) GdkTool_VCalcDataOutputRegionInstanced(GdkTool tool, GdkToolDataOutputCfg outputConfig, GdkRegion3d64f* region);
258 
259 
260 /**
261 * Called by the framework before data collection starts.
262 *
263 * @public @memberof GdkTool
264 * @param tool Tool object.
265 * @return Operation status.
266 */
267 GdkFx(kStatus) GdkTool_VStart(GdkTool tool);
268 
269 /**
270 * Called by the framework before data collection stop.
271 *
272 * @public @memberof GdkTool
273 * @param tool Tool object.
274 * @return Operation status.
275 */
276 GdkFx(kStatus) GdkTool_VStop(GdkTool tool);
277 
278 /**
279 * Process an incoming frame.
280 *
281 * The tool implementation should process the incoming data and send out results
282 * within this function.
283 *
284 * @public @memberof GdkTool
285 * @param tool Tool object.
286 * @param input Collection of inputs.
287 * @param output Collection of outputs.
288 * @return Operation status.
289 */
290 GdkFx(kStatus) GdkTool_VProcess(GdkTool tool, GdkToolInput input, GdkToolOutput output);
291 
292 
293 //// Deprecated API functions
294 
295 /**
296 * [Deprecated] Use GdkTool_InputDataIndex() instead.
297 *
298 * Returns the index for the named feature.
299 *
300 * @deprecated
301 * @public @memberof GdkTool
302 * @param tool Tool object.
303 * @param name String name of feature.
304 * @return Index of feature with matching name.
305 */
306 GdkFx(kSize) GdkTool_InputFeatureIndex(GdkTool tool, const kChar* name);
307 
308 /**
309 * [Deprecated] Use GdkTool_VNewToolConfigInstanced() instead.
310 *
311 * Initializes newly added tool configuration.
312 *
313 * @deprecated
314 * @public @memberof GdkTool
315 * @param env Tool environment.
316 * @param toolConfig Configuration object.
317 * @return Operation status.
318 */
319 GdkFx(kStatus) GdkTool_VNewToolConfig(const GdkToolEnv* env, GdkToolCfg toolConfig);
320 
321 /**
322 * [Deprecated] Use GdkTool_VNewMeasurementConfigInstanced() instead.
323 *
324 * Initializes newly added tool measurement configuration.
325 *
326 * @deprecated
327 * @public @memberof GdkTool
328 * @param env Tool environment.
329 * @param toolConfig Parent tool configuration.
330 * @param measurementConfig Measurement configuration object (to be updated).
331 * @return Operation status.
332 */
333 GdkFx(kStatus) GdkTool_VNewMeasurementConfig(const GdkToolEnv* env, GdkToolCfg toolConfig, GdkMeasurementCfg measurementConfig);
334 
335 /**
336 * [Deprecated] Use GdkTool_VNewFeatureConfigInstanced() instead.
337 *
338 * Initializes newly added tool feature configuration.
339 *
340 * @deprecated
341 * @public @memberof GdkTool
342 * @param env Tool environment.
343 * @param toolConfig Parent tool configuration.
344 * @param featureConfig Feature configuration object (to be updated).
345 * @return Operation status.
346 */
347 GdkFx(kStatus) GdkTool_VNewFeatureConfig(const GdkToolEnv* env, GdkToolCfg toolConfig, GdkFeatureCfg featureConfig);
348 
349 /**
350 * [Deprecated] Use GdkTool_VNewToolDataOutputConfigInstanced() instead.
351 *
352 * Initializes newly added tool data output configuration.
353 *
354 * @deprecated
355 * @public @memberof GdkTool
356 * @param env Tool environment.
357 * @param toolConfig Parent tool configuration.
358 * @param toolDataOutputConfig Data output configuration object (to be updated).
359 * @return Operation status.
360 */
361 GdkFx(kStatus) GdkTool_VNewToolDataOutputConfig(const GdkToolEnv* env, GdkToolCfg toolConfig, GdkToolDataOutputCfg toolDataOutputConfig);
362 
363 /**
364 * [Deprecated] Use GdkTool_VUpdateConfigInstanced() instead.
365 *
366 * Update the configuration due to parameter changes.
367 *
368 * The framework calls this function after the configuration has changed. The
369 * tool implementation has the opportunity to update configuration attributes
370 * that may need to be dynamically updated. For example the implementation
371 * may use the value of a parameter to update the min and max constraints of
372 * another parameter.
373 * This function can be called for configuration changes not related to the tool type.
374 *
375 * @deprecated
376 * @public @memberof GdkTool
377 * @param env Tool environment.
378 * @param toolConfig Tool configuration object.
379 * @return Operation status.
380 */
381 GdkFx(kStatus) GdkTool_VUpdateConfig(const GdkToolEnv* env, GdkToolCfg toolConfig);
382 
383 /**
384 * [Deprecated] Use GdkTool_VCalcDataOutputRegionInstanced() instead.
385 *
386 * Calculates the region for a given data output.
387 *
388 * Override this function to implement customized calculation of data regions for specific
389 * outputs. If this function is unimplemented, or does not alter the input region, a default
390 * region is used by the framework.
391 * This function can be called for configuration changes not related to the tool type.
392 *
393 * @deprecated
394 * @public @memberof GdkTool
395 * @param env Tool environment.
396 * @param toolConfig Tool configuration object.
397 * @param outputConfig Data output configuration object.
398 * @param region Pointer to receive new region. The value is initialized to the default region.
399 * @return Operation status.
400 */
401 GdkFx(kStatus) GdkTool_VCalcDataOutputRegion(const GdkToolEnv* env, GdkToolCfg toolConfig, GdkToolDataOutputCfg outputConfig, GdkRegion3d64f* region);
402 
403 #include <Gdk/Tools/GdkTool.x.h>
404 
405 #endif
Represents configuration for a tool data output.
Essential Gdk declarations.
Represents configuration for a feature.
Declares the GdkToolOutput class.
kSize GdkTool_InputFeatureIndex(GdkTool tool, const kChar *name)
[Deprecated] Use GdkTool_InputDataIndex() instead.
Represents configuration for a measurement.
kStatus GdkTool_VNewFeatureConfig(const GdkToolEnv *env, GdkToolCfg toolConfig, GdkFeatureCfg featureConfig)
[Deprecated] Use GdkTool_VNewFeatureConfigInstanced() instead.
kStatus GdkTool_VProcess(GdkTool tool, GdkToolInput input, GdkToolOutput output)
Process an incoming frame.
kStatus GdkTool_AnchorProfileRegion(GdkTool tool, const GdkRegionXZ64f *original, GdkRegionXZ64f *anchored)
Applies the currently available anchoring parameters to a profile region.
kStatus GdkTool_VNewMeasurementConfigInstanced(GdkTool tool, GdkMeasurementCfg measurementConfig)
Initializes newly added tool intance's measurement configuration data.
kStatus GdkTool_AnchorSurfaceRegion(GdkTool tool, const GdkRegion3d64f *original, GdkRegion3d64f *anchored)
Applies the currently available anchoring parameters to a surface region.
kStatus GdkTool_VNewMeasurementConfig(const GdkToolEnv *env, GdkToolCfg toolConfig, GdkMeasurementCfg measurementConfig)
[Deprecated] Use GdkTool_VNewMeasurementConfigInstanced() instead.
kStatus GdkTool_AnchorPointSetRegion(GdkTool tool, const kArrayList *original, kArrayList *anchored)
Applies the currently available anchoring parameters to a point set region.
kStatus GdkTool_SetupForScanning(GdkTool tool, GdkSensorInfo sensorInfo, GdkToolCfg toolCfg)
Set up the tool instance in preparation for sensor scanning.
kStatus GdkTool_VCalcDataOutputRegionInstanced(GdkTool tool, GdkToolDataOutputCfg outputConfig, GdkRegion3d64f *region)
Calculates the tool instance's region for a given data output.
kSize GdkTool_InputDataIndex(GdkTool tool, const kChar *name)
Returns the index for the named input.
Declares the GdkSensorInfo class.
kStatus GdkTool_VUpdateConfigInstanced(GdkTool tool, GdkToolCfg toolConfig)
Update the tool instance's configuration due to configuration file changes.
GdkSensorInfo GdkTool_SensorInfo(GdkTool tool)
Returns the sensor information.
kStatus GdkTool_VNewToolConfig(const GdkToolEnv *env, GdkToolCfg toolConfig)
[Deprecated] Use GdkTool_VNewToolConfigInstanced() instead.
kAlloc GdkTool_MessageAlloc(GdkTool tool)
Returns the message processing memory allocator.
Describes the sensor system environment.
GdkToolCfg GdkTool_Config(GdkTool tool)
Returns the tool configuration.
kStatus GdkTool_VStop(GdkTool tool)
Called by the framework before data collection stop.
kStatus GdkTool_VCalcDataOutputRegion(const GdkToolEnv *env, GdkToolCfg toolConfig, GdkToolDataOutputCfg outputConfig, GdkRegion3d64f *region)
[Deprecated] Use GdkTool_VCalcDataOutputRegionInstanced() instead.
kStatus GdkTool_VNewToolDataOutputConfigInstanced(GdkTool tool, GdkToolDataOutputCfg toolDataOutputConfig)
Initializes newly added tool instance's data output configuration data.
kSize GdkTool_DataOutputIndexByType(GdkTool tool, const kChar *typeName)
Find the index of a tool data output by its type name.
kStatus GdkTool_VUpdateConfig(const GdkToolEnv *env, GdkToolCfg toolConfig)
[Deprecated] Use GdkTool_VUpdateConfigInstanced() instead.
kStatus GdkTool_VNewToolDataOutputConfig(const GdkToolEnv *env, GdkToolCfg toolConfig, GdkToolDataOutputCfg toolDataOutputConfig)
[Deprecated] Use GdkTool_VNewToolDataOutputConfigInstanced() instead.
kSize GdkTool_MeasurementIndexByType(GdkTool tool, const kChar *typeName)
Find the index of a measurement by its type name.
kStatus GdkTool_VStart(GdkTool tool)
Called by the framework before data collection starts.
Represents the configuration instance for a tool.
Represents a tool input collection.
kStatus GdkTool_VNewToolConfigInstanced(GdkTool tool, GdkToolCfg toolConfig)
Initializes newly added tool instance's configuration data.
kStatus GdkTool_VNewFeatureConfigInstanced(GdkTool tool, GdkFeatureCfg featureConfig)
Initializes newly added tool instance's feature configuration data.
Declares the GdkToolInfo class.
kSize GdkTool_FeatureIndexByType(GdkTool tool, const kChar *typeName)
Find the index of a feature by its type name.
Declares the GdkToolInput and related classes.
Base class for a tool implementation.
Declares the GdkToolCfg class.
Represents a tool output collection.
kBool GdkTool_VIsVisible(const GdkToolEnv *env)
Determines whether or not this tools should show up in the list of tools.