STFishFinder API  API version 0.0.0, Documentation version 3 -PRELIMINARY-
STFF-Utility.h
Go to the documentation of this file.
1 ///
2 /// @file STFF-Utility.h
3 ///
4 /// Header file containing declarations for free functions in the STFF::
5 /// namespace that perform
6 /// - @link conversion_functions units conversions @endlink, and
7 /// - @link validation_functions validation @endlink of enumerations
8 /// defined in STFF-Types.h.
9 ///
10 /// @copyright
11 /// Copyright (c) 2012-2015 Sifferman Technology, LLC. All rights reserved.
12 ///
13 
14 #ifndef STFF_Utility_h_
15 #define STFF_Utility_h_
16 
17 
18 namespace STFF {
19 
20  ////////////////////////////////////////////////////////////////////////////
21  //
22  // NON-MEMBER FUNCTIONS
23  //
24  ////////////////////////////////////////////////////////////////////////////
25 
26  ////////////////////////////////////////////////////////////////////////////
27  /// @defgroup stff_non_member_functions Non-Member Functions
28  ///
29  /// Free functions within the STFF namespace that are not members of any class.
30  ///
31  /// @see stff_member_functions
32  ////////////////////////////////////////////////////////////////////////////
33 
34 
35  ////////////////////////////////////
36  // CONVERSION FUNCTIONS
37  ////////////////////////////////////
38 
39  ////////////////////////////////////////////////////////////////////////////
40  /// @defgroup conversion_functions Conversion Functions
41  /// @ingroup stff_non_member_functions
42  ///
43  /// These functions provide a convenient facility for converting data
44  /// values from one set of units to another.
45  /// For example, the STFF::ConvertSpeed function
46  /// will convert a speed in knots into its equivalent in miles per hour
47  /// or kilometers per hour.
48  ///
49  /// These are non-member functions that reside in the STFF namespace.
50  ////////////////////////////////////////////////////////////////////////////
51 
52  ////////////////////////////////////////////////////////////////////////////
53  /// @fn ConvertDepth (FF_DepthUnits_t, FF_DepthUnits_t, double, double*)
54  ///
55  /// Convert a depth value from one set of units (feet, meters, or fathoms)
56  /// to another.
57  ///
58  /// @note If the input value is in a fraction of the @p fromUnits
59  /// parameter (e.g. hundredths of a foot), then the output
60  /// value will be in the same fraction of the @p toUnits
61  /// parameter (e.g. hundredths of a meter).
62  ///
63  /// @param[in] fromUnits
64  /// Units corresponding to the @p input parameter
65  ///
66  /// @param[in] toUnits
67  /// Units corresponding to the @p pOutput parameter
68  ///
69  /// @param[in] input
70  /// The value to be converted
71  ///
72  /// @param[out] pOutput
73  /// Pointer to the location where the converted value will
74  /// be stored
75  ///
76  /// @retval ::FF_ERR_NO_ERROR
77  /// if the conversion succeeded
78  ///
79  /// @retval ::FF_ERR_ARGUMENT_OUT_OF_RANGE
80  /// if @p fromUnits, @p toUnits, or @p input contain
81  /// illegal values
82  ///
83  /// @retval ::FF_ERR_INVALID_POINTER
84  /// if @p pOutput is a null pointer
85  ///
86  /// @see ::FF_DepthUnits_t
87  ///
88  /// @ingroup conversion_functions
89  ///
91  FF_DepthUnits_t toUnits,
92  double input,
93  double *pOutput);
94 
95 
96  ////////////////////////////////////////////////////////////////////////////
97  /// @fn ConvertSpeed (FF_SpeedUnits_t, FF_SpeedUnits_t, double, double*)
98  ///
99  /// Convert a speed value from one set of units (knots, miles per hour,
100  /// or kilometers per hour) to another.
101  ///
102  /// Note that if the input value is in a fraction of the @p fromUnits
103  /// parameter (e.g. hundredths of a knot), then the output value will be
104  /// in the same fraction of the @p toUnits parameter (e.g. hundredths of a
105  /// mph).
106  ///
107  /// @param[in] fromUnits
108  /// Units corresponding to the @p input parameter
109  ///
110  /// @param[in] toUnits
111  /// Units corresponding to the @p pOutput parameter
112  ///
113  /// @param[in] input
114  /// The value to be converted
115  ///
116  /// @param[out] pOutput
117  /// Pointer to the location where the converted
118  /// value will be stored
119  ///
120  /// @retval ::FF_ERR_NO_ERROR
121  /// if the conversion succeeded
122  ///
123  /// @retval ::FF_ERR_ARGUMENT_OUT_OF_RANGE
124  /// if @p fromUnits, @p toUnits, or @p input contain
125  /// illegal values
126  ///
127  /// @retval ::FF_ERR_INVALID_POINTER
128  /// if @p pOutput is a null pointer
129  ///
130  /// @see ::FF_SpeedUnits_t
131  ///
132  /// @ingroup conversion_functions
133  ///
135  FF_SpeedUnits_t toUnits,
136  double input,
137  double *pOutput);
138 
139 
140  ////////////////////////////////////////////////////////////////////////////
141  /// @fn ConvertTemperature (FF_TemperatureUnits_t, FF_TemperatureUnits_t, double, double*)
142  ///
143  /// Convert a temperature value from one set of units (degrees Celsius or
144  /// degrees Fahrenheit) to the other.
145  ///
146  /// Note that if the input value is in a fraction of the @p fromUnits
147  /// parameter (e.g. hundredths of a degree C), then the output value will be
148  /// in the same fraction of the @p toUnits parameter (e.g. hundredths of a
149  /// degree F).
150  ///
151  /// @param[in] fromUnits
152  /// Units corresponding to the @p input parameter
153  ///
154  /// @param[in] toUnits
155  /// Units corresponding to the @p pOutput parameter
156  ///
157  /// @param[in] input
158  /// The value to be converted
159  ///
160  /// @param[out] pOutput
161  /// Pointer to the location where the converted
162  /// value will be stored
163  ///
164  /// @retval ::FF_ERR_NO_ERROR
165  /// if the conversion succeeded
166  ///
167  /// @retval ::FF_ERR_ARGUMENT_OUT_OF_RANGE
168  /// if @p fromUnits, @p toUnits, or @p input contain
169  /// illegal values
170  ///
171  /// @retval ::FF_ERR_INVALID_POINTER
172  /// if @p pOutput is a null pointer
173  ///
174  /// @see ::FF_TemperatureUnits_t
175  ///
176  /// @ingroup conversion_functions
177  ///
179  FF_TemperatureUnits_t toUnits,
180  double input,
181  double *pOutput);
182 
183 
184  ////////////////////////////////////
185  // VALIDATION FUNCTIONS
186  ////////////////////////////////////
187 
188  ////////////////////////////////////////////////////////////////////////////
189  /// @defgroup validation_functions Validation Functions
190  /// @ingroup stff_non_member_functions
191  ///
192  /// Functions that provide a quick test to verify that an enumeration value
193  /// falls within the range of valid values for the given type. These are
194  /// overloaded functions, all having the same name @e valid, but each with
195  /// a distinct argument list.
196  ///
197  /// These are non-member functions that reside in the STFF namespace.
198  ////////////////////////////////////////////////////////////////////////////
199 
200 
201  ////////////////////////////////////////////////////////////////////////////
202  /// @fn valid (FF_Frequency_t frequency)
203  ///
204  /// Test that a value is valid for a variable of type ::FF_Frequency_t.
205  ///
206  /// @param[in] frequency
207  /// the value to be tested
208  ///
209  /// @retval true
210  /// if the value of the @p frequency parameter is valid
211  /// for a variable of type ::FF_Frequency_t
212  ///
213  /// @retval false
214  /// otherwise
215  ///
216  /// @remark This is an overloaded function that differs from other
217  /// valid() functions in the argument(s) it accepts.
218  ///
219  /// @see ::FF_Frequency_t
220  ///
221  /// @ingroup validation_functions
222  ///
223  inline bool valid (FF_Frequency_t frequency)
224  {
225  return (frequency > FF_INVALID_FREQUENCY &&
226  frequency < FF_TOTAL_FREQUENCIES);
227  }
228 
229 
230  ////////////////////////////////////////////////////////////////////////////
231  /// @fn valid (FF_DepthUnits_t units)
232  ///
233  /// Test that a value is valid for a variable of type ::FF_DepthUnits_t.
234  ///
235  /// @param[in] units
236  /// the value to be tested
237  ///
238  /// @retval true
239  /// if the value of the @p units parameter is valid
240  /// for a variable of type ::FF_DepthUnits_t
241  //
242  /// @retval false
243  /// otherwise
244  ///
245  /// @remark This is an overloaded function that differs from other
246  /// valid() functions in the argument(s) it accepts.
247  ///
248  /// @see ::FF_DepthUnits_t
249  ///
250  /// @ingroup validation_functions
251  ///
252  inline bool valid (FF_DepthUnits_t units)
253  {
254  return (units > FF_INVALID_DEPTH_UNITS &&
255  units < FF_TOTAL_DEPTH_UNITS);
256  }
257 
258 
259  ////////////////////////////////////////////////////////////////////////////
260  /// @fn valid (FF_SpeedUnits_t units)
261  ///
262  /// Test that a value is valid for a variable of type ::FF_SpeedUnits_t.
263  ///
264  /// @param[in] units
265  /// the value to be tested
266  ///
267  /// @retval true
268  /// if the value of the @p units parameter is valid
269  /// for a variable of type ::FF_SpeedUnits_t
270  ///
271  /// @retval false
272  /// otherwise
273  ///
274  /// @remark This is an overloaded function that differs from other
275  /// valid() functions in the argument(s) it accepts.
276  ///
277  /// @see ::FF_SpeedUnits_t
278  ///
279  /// @ingroup validation_functions
280  ///
281  inline bool valid (FF_SpeedUnits_t units)
282  {
283  return (units > FF_INVALID_SPEED_UNITS &&
284  units < FF_TOTAL_SPEED_UNITS);
285  }
286 
287 
288  ////////////////////////////////////////////////////////////////////////////
289  /// @fn valid (FF_TemperatureUnits_t units)
290  ///
291  /// Test that a value is valid for a variable of type
292  /// ::FF_TemperatureUnits_t.
293  ///
294  /// @param[in] units
295  /// the value to be tested
296  ///
297  /// @retval true
298  /// if the value of the @p units parameter is valid
299  /// for a variable of type ::FF_TemperatureUnits_t
300  ///
301  /// @retval false
302  /// otherwise
303  ///
304  /// @remark This is an overloaded function that differs from other
305  /// valid() functions in the argument(s) it accepts.
306  ///
307  /// @see ::FF_TemperatureUnits_t
308  ///
309  /// @ingroup validation_functions
310  ///
311  inline bool valid (FF_TemperatureUnits_t units)
312  {
313  return (units > FF_INVALID_TEMPERATURE_UNITS &&
314  units < FF_TOTAL_TEMPERATURE_UNITS);
315  }
316 
317 
318  ////////////////////////////////////////////////////////////////////////////
319  /// @fn valid (FF_SettingType_t settingType)
320  ///
321  /// Test that a value is valid for a variable of type ::FF_SettingType_t.
322  ///
323  /// @param[in] settingType
324  /// the value to be tested
325  ///
326  /// @retval true
327  /// if the value of the @p settingType parameter is valid
328  /// for a variable of type ::FF_SettingType_t
329  ///
330  /// @retval false
331  /// otherwise
332  ///
333  /// @remark This is an overloaded function that differs from other
334  /// valid() functions in the argument(s) it accepts.
335  ///
336  /// @see ::FF_SettingType_t
337  ///
338  /// @ingroup validation_functions
339  ///
340  inline bool valid (FF_SettingType_t settingType)
341  {
342  return (settingType > FF_INVALID_SETTING_TYPE &&
343  settingType < FF_TOTAL_SETTING_TYPES);
344  }
345 
346 
347  ////////////////////////////////////////////////////////////////////////////
348  /// @fn valid (FF_DataType_t dataType)
349  ///
350  /// Test that a value is valid for a variable of type ::FF_DataType_t.
351  ///
352  /// @param[in] dataType
353  /// the value to be tested
354  ///
355  /// @retval true
356  /// if the value of the @p dataType parameter is valid
357  /// for a variable of type ::FF_DataType_t
358  ///
359  /// @retval false
360  /// otherwise
361  ///
362  /// @remark This is an overloaded function that differs from other
363  /// valid() functions in the argument(s) it accepts.
364  ///
365  /// @see ::FF_DataType_t
366  ///
367  /// @ingroup validation_functions
368  ///
369  inline bool valid (FF_DataType_t dataType)
370  {
371  return (dataType > FF_INVALID_DATA_TYPE &&
372  dataType < FF_TOTAL_DATA_TYPES);
373  }
374 
375 
376  ////////////////////////////////////////////////////////////////////////////
377  /// @fn valid (FF_ControlCommand_t controlCommand)
378  ///
379  /// Test that a value is valid for a variable of type
380  /// ::FF_ControlCommand_t.
381  ///
382  /// @param[in] controlCommand
383  /// the value to be tested
384  ///
385  /// @retval true
386  /// if the value of the @p controlCommand parameter is valid
387  /// for a variable of type ::FF_ControlCommand_t
388  ///
389  /// @retval false
390  /// otherwise
391  ///
392  /// @remark This is an overloaded function that differs from other
393  /// valid() functions in the argument(s) it accepts.
394  ///
395  /// @see ::FF_ControlCommand_t
396  ///
397  /// @ingroup validation_functions
398  ///
399  inline bool valid (FF_ControlCommand_t controlCommand)
400  {
401  return (controlCommand > FF_INVALID_CONTROL_COMMAND &&
402  controlCommand < FF_TOTAL_CONTROL_COMMANDS);
403  }
404 
405 
406  ////////////////////////////////////////////////////////////////////////////
407  /// @fn valid (FF_FrequencyMode_t frequencyMode)
408  ///
409  /// Test that a value is valid for a variable of type ::FF_FrequencyMode_t.
410  ///
411  /// @param[in] frequencyMode
412  /// the value to be tested
413  ///
414  /// @retval true
415  /// if the value of the @p frequencyMode parameter is valid
416  /// for a variable of type ::FF_FrequencyMode_t
417  ///
418  /// @retval false
419  /// otherwise
420  ///
421  /// @remark This is an overloaded function that differs from other
422  /// valid() functions in the argument(s) it accepts.
423  ///
424  /// @see ::FF_FrequencyMode_t
425  ///
426  /// @ingroup validation_functions
427  ///
428  inline bool valid (FF_FrequencyMode_t frequencyMode)
429  {
430  return (frequencyMode > FF_INVALID_FREQUENCY_MODE &&
431  frequencyMode < FF_TOTAL_FREQUENCY_MODES);
432  }
433 
434 
435  ////////////////////////////////////////////////////////////////////////////
436  /// @fn valid (FF_AutoRangeSetting_t autoRangeSetting)
437  ///
438  /// Test that a value is valid for a variable of type
439  /// ::FF_AutoRangeSetting_t.
440  ///
441  /// @param[in] autoRangeSetting
442  /// the value to be tested
443  ///
444  /// @retval true
445  /// if the value of the @p autoRangeSetting parameter is valid
446  /// for a variable of type ::FF_AutoRangeSetting_t
447  ///
448  /// @retval false
449  /// otherwise
450  ///
451  /// @remark This is an overloaded function that differs from other
452  /// valid() functions in the argument(s) it accepts.
453  ///
454  /// @see ::FF_AutoRangeSetting_t
455  ///
456  /// @ingroup validation_functions
457  ///
458  inline bool valid (FF_AutoRangeSetting_t autoRangeSetting)
459  {
460  return (autoRangeSetting > FF_INVALID_AUTO_RANGE_SETTING &&
461  autoRangeSetting < FF_TOTAL_AUTO_RANGE_SETTINGS);
462  }
463 
464 
465  ////////////////////////////////////////////////////////////////////////////
466  /// @fn valid (FF_AutoGainSetting_t autoGainSetting)
467  ///
468  /// Test that a value is valid for a variable of type
469  /// ::FF_AutoGainSetting_t.
470  ///
471  /// @param[in] autoGainSetting
472  /// the value to be tested
473  ///
474  /// @retval true
475  /// if the value of the @p autoGainSetting parameter is valid
476  /// for a variable of type ::FF_AutoGainSetting_t
477  ///
478  /// @retval false
479  /// otherwise
480  ///
481  /// @remark This is an overloaded function that differs from other
482  /// valid() functions in the argument(s) it accepts.
483  ///
484  /// @see ::FF_AutoGainSetting_t
485  ///
486  /// @ingroup validation_functions
487  ///
488  inline bool valid (FF_AutoGainSetting_t autoGainSetting)
489  {
490  return (autoGainSetting > FF_INVALID_AUTO_GAIN_SETTING &&
491  autoGainSetting < FF_TOTAL_AUTO_GAIN_SETTINGS);
492  }
493 
494 
495  ////////////////////////////////////////////////////////////////////////////
496  /// @fn valid (FF_DepthAlarmType_t depthAlarmType)
497  ///
498  /// Test that a value is valid for a variable of type
499  /// ::FF_DepthAlarmType_t.
500  ///
501  /// @param[in] depthAlarmType
502  /// the value to be tested
503  ///
504  /// @retval true
505  /// if the value of the @p depthAlarmType parameter is valid
506  /// for a variable of type ::FF_DepthAlarmType_t
507  ///
508  /// @retval false
509  /// otherwise
510  ///
511  /// @remark This is an overloaded function that differs from other
512  /// valid() functions in the argument(s) it accepts.
513  ///
514  /// @see ::FF_DepthAlarmType_t
515  ///
516  /// @ingroup validation_functions
517  ///
518  inline bool valid (FF_DepthAlarmType_t depthAlarmType)
519  {
520  return (depthAlarmType > FF_INVALID_DEPTH_ALARM_TYPE &&
521  depthAlarmType < FF_TOTAL_DEPTH_ALARM_TYPES);
522  }
523 
524 
525  ////////////////////////////////////////////////////////////////////////////
526  /// @fn valid (FF_DepthAlarmState_t depthAlarmState)
527  ///
528  /// Test that a value is valid for a variable of type
529  /// ::FF_DepthAlarmState_t.
530  ///
531  /// @param[in] depthAlarmState
532  /// the value to be tested
533  ///
534  /// @retval true
535  /// if the value of the @p depthAlarmState parameter is valid
536  /// for a variable of type ::FF_DepthAlarmState_t
537  ///
538  /// @retval false
539  /// otherwise
540  ///
541  /// @remark This is an overloaded function that differs from other
542  /// valid() functions in the argument(s) it accepts.
543  ///
544  /// @see ::FF_DepthAlarmState_t
545  ///
546  /// @ingroup validation_functions
547  ///
548  inline bool valid (FF_DepthAlarmState_t depthAlarmState)
549  {
550  return (depthAlarmState > FF_INVALID_DEPTH_ALARM_STATE &&
551  depthAlarmState < FF_TOTAL_DEPTH_ALARM_STATES);
552  }
553 
554 
555  ////////////////////////////////////////////////////////////////////////////
556  /// @fn valid (FF_FishAlarmSetting_t fishAlarmSetting)
557  ///
558  /// Test that a value is valid for a variable of type
559  /// ::FF_FishAlarmSetting_t.
560  ///
561  /// @param[in] fishAlarmSetting
562  /// the value to be tested
563  ///
564  /// @retval true
565  /// if the value of the @p fishAlarmSetting parameter is valid
566  /// for a variable of type ::FF_FishAlarmSetting_t
567  ///
568  /// @retval false
569  /// otherwise
570  ///
571  /// @remark This is an overloaded function that differs from other
572  /// valid() functions in the argument(s) it accepts.
573  ///
574  /// @see ::FF_FishAlarmSetting_t
575  ///
576  /// @ingroup validation_functions
577  ///
578  inline bool valid (FF_FishAlarmSetting_t fishAlarmSetting)
579  {
580  return (fishAlarmSetting > FF_INVALID_FISH_ALARM_SETTING &&
581  fishAlarmSetting < FF_TOTAL_FISH_ALARM_SETTINGS);
582  }
583 
584 
585  ////////////////////////////////////////////////////////////////////////////
586  /// @fn valid (FF_ApiStatus_t apiStatus)
587  ///
588  /// Test that a value is valid for a variable of type ::FF_ApiStatus_t.
589  ///
590  /// @param[in] apiStatus
591  /// the value to be tested
592  ///
593  /// @retval true
594  /// if the value of the @p apiStatus parameter is valid
595  /// for a variable of type ::FF_ApiStatus_t
596  ///
597  /// @retval false
598  /// otherwise
599  ///
600  /// @remark This is an overloaded function that differs from other
601  /// valid() functions in the argument(s) it accepts.
602  ///
603  /// @see ::FF_ApiStatus_t
604  ///
605  /// @ingroup validation_functions
606  ///
607  inline bool valid (FF_ApiStatus_t apiStatus)
608  {
609  return (apiStatus > FF_INVALID_API_STATUS &&
610  apiStatus < FF_TOTAL_API_STATUSES);
611  }
612 
613 } // namespace STFF
614 
615 #endif // defined (STFF_Utility_h_)
FF_DepthUnits_t
Depth Units selection.
Definition: STFF-Types.h:96
FF_DepthAlarmState_t
Depth Alarm State options.
Definition: STFF-Types.h:444
FF_SpeedUnits_t
Speed Units selection.
Definition: STFF-Types.h:117
bool valid(FF_Frequency_t frequency)
Test that a value is valid for a variable of type FF_Frequency_t.
Definition: STFF-Utility.h:223
FF_ApiStatus_t
API Status selection.
Definition: STFF-Types.h:484
FF_DepthAlarmType_t
Depth Alarm Type selection.
Definition: STFF-Types.h:423
FF_Error_t
Error codes.
Definition: STFF-Types.h:50
This is the namespace containing the platform-independent STFishFinder API.
FF_TemperatureUnits_t
Temperature Units selection.
Definition: STFF-Types.h:138
FF_Error_t ConvertTemperature(FF_TemperatureUnits_t fromUnits, FF_TemperatureUnits_t toUnits, double input, double *pOutput)
Convert a temperature value from one set of units (degrees Celsius or degrees Fahrenheit) to the othe...
FF_AutoGainSetting_t
Auto Gain setting options.
Definition: STFF-Types.h:380
FF_ControlCommand_t
Control Command options.
Definition: STFF-Types.h:257
FF_FrequencyMode_t
Sonar Frequency Mode options.
Definition: STFF-Types.h:314
FF_DataType_t
Data Type options.
Definition: STFF-Types.h:210
FF_Error_t ConvertSpeed(FF_SpeedUnits_t fromUnits, FF_SpeedUnits_t toUnits, double input, double *pOutput)
Convert a speed value from one set of units (knots, miles per hour, or kilometers per hour) to anothe...
FF_SettingType_t
Setting Type options.
Definition: STFF-Types.h:158
FF_Error_t ConvertDepth(FF_DepthUnits_t fromUnits, FF_DepthUnits_t toUnits, double input, double *pOutput)
Convert a depth value from one set of units (feet, meters, or fathoms) to another.
Invalid frequency or frequency not specified.
Definition: STFF-Types.h:78
FF_Frequency_t
Sonar Frequency options.
Definition: STFF-Types.h:77
FF_AutoRangeSetting_t
Auto Range setting options.
Definition: STFF-Types.h:359