HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_Range.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PRM_Range.h (Parameter Library)
7  *
8  * COMMENTS:
9  * This parameter is used to set upper and lower limits on
10  * parameters. For simplicity only floating point numbers are
11  * used. These limits are not actually enforced by the parmeter
12  * library. But maybe they should. Discuss.
13  */
14 
15 
16 #ifndef __PRM_RANGE__
17 #define __PRM_RANGE__
18 
19 #include "PRM_API.h"
20 #include <SYS/SYS_Types.h>
21 
23 {
24  PRM_RANGE_FREE = 0x0, // ie range is ignored.
25  PRM_RANGE_UI = 0x1, // For some UI (sliders, etc) only
26  PRM_RANGE_PRM = 0x2, // Strictly enforced by PRM, too
28 };
29 
31 {
32 public:
33  PRM_Range(PRM_RangeFlag theminflag = PRM_RANGE_UI, fpreal themin = 0,
34  PRM_RangeFlag themaxflag = PRM_RANGE_UI, fpreal themax = 1)
35  {
36  myMinFlag = theminflag;
37  myMin = themin;
38  myMaxFlag = themaxflag;
39  myMax = themax;
40  }
41 
42  bool hasParmMin() const
43  {
44  return ((myMinFlag & PRM_RANGE_PRM) != 0);
45  }
46  bool hasParmMax() const
47  {
48  return ((myMaxFlag & PRM_RANGE_PRM) != 0);
49  }
50 
52  {
53  if (myMinFlag != PRM_RANGE_FREE)
54  return myMin;
55  return -SYS_FPREAL_MAX;
56  }
58  {
59  if (myMaxFlag != PRM_RANGE_FREE)
60  return myMax;
61  return SYS_FPREAL_MAX;
62  }
63 
64  bool hasUIMin() const
65  {
66  return ((myMinFlag & PRM_RANGE_UI) != 0);
67  }
68  bool hasUIMax() const
69  {
70  return ((myMaxFlag & PRM_RANGE_UI) != 0);
71  }
72 
73  fpreal getUIMin() const { return getParmMin(); }
74  fpreal getUIMax() const { return getParmMax(); }
75 
76 private:
77  PRM_RangeFlag myMinFlag;
78  PRM_RangeFlag myMaxFlag;
79  fpreal myMin;
80  fpreal myMax;
81 };
82 
83 #endif
PRM_Range(PRM_RangeFlag theminflag=PRM_RANGE_UI, fpreal themin=0, PRM_RangeFlag themaxflag=PRM_RANGE_UI, fpreal themax=1)
Definition: PRM_Range.h:33
bool hasUIMax() const
Definition: PRM_Range.h:68
fpreal getParmMin() const
Definition: PRM_Range.h:51
fpreal getParmMax() const
Definition: PRM_Range.h:57
bool hasParmMax() const
Definition: PRM_Range.h:46
PRM_RangeFlag
Definition: PRM_Range.h:22
fpreal getUIMin() const
Definition: PRM_Range.h:73
fpreal getUIMax() const
Definition: PRM_Range.h:74
#define SYS_FPREAL_MAX
Definition: SYS_Types.h:279
double fpreal
Definition: SYS_Types.h:270
#define PRM_API
Definition: PRM_API.h:10
bool hasParmMin() const
Definition: PRM_Range.h:42
bool hasUIMin() const
Definition: PRM_Range.h:64