GL Studio SCECpp Runtime Library
gls_odometer.h
Go to the documentation of this file.
1 #ifndef _GLS_ODOMETER_H
2 #define _GLS_ODOMETER_H
3 
4 /*! \file gls_odometer.h
5 
6 \brief This header defines the GlsOdometer class
7  in the GL Studio DO-178B Runtime Library.
8 
9 \par Copyright Information
10 Copyright (C) 1999-2012 The DiSTI Corporation<br>
11 Orlando, FL USA<br>
12 All rights reserved.<br>
13 
14  This file is copyrighted software and contains proprietary trade secrets of
15 DiSTI, and embodies substantial creative efforts as well as confidential
16 information, ideas, and expressions.
17 
18  Permission to use, and copy this software and its documentation for any
19 purpose is hereby granted per the Distribution Agreement and/or the Licensing
20 Agreement signed with DiSTI. This permission is granted provided that:
21  1. The above copyright notice appears in all copies.
22  2. That both the copyright notice and this permission notice appear in
23  the supporting documentation.
24  3. That the names DiSTI and GL Studio not be used in advertising or
25  publicity pertaining to distribution of the software without specific,
26  written prior permission of DiSTI.
27 
28  Permission to modify the software is granted, but not the right to
29 distribute the source code whether modified, or non-modified. Modifying the
30 software might invalidate the DO-178B certification package.
31 
32  Permission to distribute binaries produced by compiling source code, or
33 modified source code is granted, provided you:
34  1. Provide your name and address as the primary contact for the support
35  of your modified version.
36  2. Retain our contact information in regard to use of the base software.
37 
38  DiSTI does not provide warranty for this software or guarantee that it
39 satisfies any specification or requirement unless otherwise stated in a
40 specific contractual arrangement between the customer and DiSTI.
41 
42 */
43 
44 #include "gls_include.h"
45 #include "gls_group.h"
46 #include "gls_class_invariant.h"
47 
48 /** This class facilitates building rolling odometer displays.
49  * \invariant base class invariant holds, _baseSystem > 0u, _minValue <= _maxValue,
50  * _rolloverThreshold > 0.0f,
51  * GlsOdometerBehaviorIsValid( _behavior ), GlsOdometerGeometryTypeIsValid( _geometryType )
52  * GlsFloatIsValid( _degreesPerDigit ), GlsFloatIsValid( _textureScale ),
53  * _magnitude > 0.0, ( _minValue <= _value ) && ( _value <= _maxValue ),
54  * ( ( ( 0u == _objects.GetSize() ) && ( GLS_NULL == _textureOffsetY ) ) ||
55  * ( ( _objects.GetSize() > 0u ) && ( GLS_NULL != _textureOffsetY ) ) ),
56  * _textureOffsetY array contains valid floating point values
57  */
58 class GlsOdometer : public GlsGroup
59 {
60 public:
62 
63  /** odometer behvior mode */
64  enum Behavior
65  {
66  BEHAVIOR_ANALOG, /**< analog odometer */
67  BEHAVIOR_DIGITAL, /**< digital odometer */
68 
69  #if defined( GLS_DEBUG )
70  BEHAVIOR_INVALID /**< invalid behavior ( GLS_DEBUG only ) */
71  #endif // GLS_DEBUG
72  };
73 
74  /** odometer geometry types */
76  {
77  GEOMETRY_TYPE_2D, /**< two dimensional geometry */
78  GEOMETRY_TYPE_3D, /**< three dimensional geometry */
79 
80  #if defined( GLS_DEBUG )
81  GEOMETRY_TYPE_INVALID /**< invalid geometry type */
82  #endif // GLS_DEBUG
83  };
84 
85  /** intialization parameters for a GlsOdometer */
87  {
88  GlsGroup::InitParameters groupInitParameters; /**< base class init parameters */
89 
90  const GlsUInt32 baseSystem; /**< base of number system for display values ( >0 ) */
91  const GlsFloat32 minValue; /**< minimum display value for odometer ( minValue <= maxValue ) */
92  const GlsFloat32 maxValue; /**< maximum display value for odometer ( maxValue >= minValue ) */
93  const GlsFloat32 initialValue; /**< initial display value for odometer
94  * ( minValue <= initialValue <= maxValue ) */
95  const GlsUInt32 orderOfMagnitude; /**< order of magnitude of odometer digits */
96  const GlsFloat32 rolloverThreshold; /**< threshold determining when digit rollover occurs ( >0.0f ) */
97  const Behavior behavior; /**< odometer behavior */
98  const GeometryType geometryType; /**< odometer geometry type */
99  const GlsFloat32 degreesPerDigit; /**< rotation in degrees for one digit when in 3D geometry mode */
100  const GlsFloat32 textureScale; /**< amount to slide texture when in 2D geometry mode */
101 
102  /** create a copy of the init parameters with the object array init
103  * objects array replaced with the given array of objects
104  * \param newObjects new array of ojects
105  * \return copy of given init parameters with object array init objects array replaced
106  * \pre newObjects != GLS_NULL,
107  * newObjects array has initParameters.groupInitParameters.objectArrayInitParameters.numObjects elements
108  * \post none
109  */
110  InitParameters CopyWithObjectsArray( GlsDisplayObject* const *newObjects ) const;
111 
112  #if defined( GLS_DEBUG )
113  /** Determine if the initialization parameters are valid ( GLS_DEBUG only )
114  * \return GLS_TRUE if valid else GLS_FALSE
115  * \pre none
116  * \post none
117  */
118  GlsBool IsValid( void ) const;
119  #endif // GLS_DEBUG
120  };
121 
122  /** Constructor - create an instance
123  * \param initParameters initialization parameters
124  * \param eventDispatcher event dispatcher for this object else GLS_NULL
125  * \pre initParameters.IsValid()
126  * \post instance created
127  */
128  GlsOdometer( InitParameters &initParameters, GlsEventDispatcher* const eventDispatcher );
129 
130  /** Set the current display value for the odometer
131  * \param value new display value
132  * \pre _minValue <= value <= _maxValue
133  * \post odometer has new display value
134  */
135  void SetValue( const GlsFloat32 value );
136 
137 protected:
138  /** Update the odometer digits to display the current value
139  * \pre none
140  * \post current value is reflected in the odometer digits
141  */
142  void UpdateDigits( void );
143 
144  const GlsUInt32 _baseSystem; /**< base of number system for display ( >0 ) */
145  const GlsFloat32 _minValue; /**< minimum display value for odometer ( minValue <= maxValue ) */
146  const GlsFloat32 _maxValue; /**< maximum display value for odometer ( maxValue >= minValue ) */
147  const GlsFloat32 _rolloverThreshold; /**< threshold determining when digit rollover occurs ( >0.0f ) */
148  const Behavior _behavior; /**< odometer behavior mode */
149  const GeometryType _geometryType; /**< odometer geometry type */
150  const GlsFloat32 _degreesPerDigit; /**< rotation in degrees for one digit when in 3D geometry mode */
151  const GlsFloat32 _textureScale; /**< amount to slide texture when in 2D geometry mode */
152 
153  const GlsFloat64 _magnitude; /**< magnitude of most significant digit on odometer */
154  const GlsFloat64 _lastMagnitude; /**< magnitude of last (least significant) digit in odometer */
155  GlsFloat32 _value; /**< current display value for odometer
156  * ( minValue <= initialValue <= maxValue ) */
157  GlsFloat32* const _textureOffsetY; /**< array of y texture offsets for each digit in odometer else GLS_NULL
158  * if no digits */
159 
160  /** Destructor - shall never be called
161  * \pre none
162  * \post none
163  */
164  virtual ~GlsOdometer();
165 
166 private:
167  typedef GlsGroup _BaseClass; /**< base class alias */
168 
169  // Disable implicit generated Members
170  GlsOdometer& operator=( const GlsOdometer &rhs );
171  GlsOdometer( const GlsOdometer &src );
172 };
173 
174 #if defined( GLS_DEBUG )
175 #pragma BullseyeCoverage save off
176 /** Determine if the given odometer behavior is valid ( GLS_DEBUG only )
177  * \param behavior odometer behavior in question
178  * \return GLS_TRUE if valid else GLS_FALSE
179  * \pre none
180  * \post none
181  */
182 inline GlsBool GlsOdometerBehaviorIsValid( const GlsOdometer::Behavior behavior )
183 {
184  return( ( GlsOdometer::BEHAVIOR_ANALOG == behavior ) ||
185  ( GlsOdometer::BEHAVIOR_DIGITAL == behavior ) );
186 }
187 #pragma BullseyeCoverage restore
188 #endif // GLS_DEBUG
189 
190 #if defined( GLS_DEBUG )
191 #pragma BullseyeCoverage save off
192 /** Determine if the given odometer geometry type is valid ( GLS_DEBUG only )
193  * \param geometryType odometer geometry type in question
194  * \return GLS_TRUE if valid else GLS_FALSE
195  * \pre none
196  * \post none
197  */
198 inline GlsBool GlsOdometerGeometryTypeIsValid( const GlsOdometer::GeometryType geometryType )
199 {
200  return( ( GlsOdometer::GEOMETRY_TYPE_2D == geometryType ) ||
201  ( GlsOdometer::GEOMETRY_TYPE_3D == geometryType ) );
202 }
203 #pragma BullseyeCoverage restore
204 #endif // GLS_DEBUG
205 
206 #endif // _GLS_ODOMETER_H
const GlsUInt32 baseSystem
Definition: gls_odometer.h:90
const GlsFloat32 _minValue
Definition: gls_odometer.h:145
Definition: gls_event.h:304
GlsFloat32 *const _textureOffsetY
Definition: gls_odometer.h:157
virtual ~GlsOdometer()
const GlsUInt32 _baseSystem
Definition: gls_odometer.h:144
const GeometryType geometryType
Definition: gls_odometer.h:98
Definition: gls_odometer.h:86
const GlsFloat32 initialValue
Definition: gls_odometer.h:93
const GlsUInt32 orderOfMagnitude
Definition: gls_odometer.h:95
const GlsFloat32 rolloverThreshold
Definition: gls_odometer.h:96
This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in the GL Stu...
const GlsFloat64 _magnitude
Definition: gls_odometer.h:153
void SetValue(const GlsFloat32 value)
GeometryType
Definition: gls_odometer.h:75
GlsFloat32 _value
Definition: gls_odometer.h:155
const GlsFloat32 _degreesPerDigit
Definition: gls_odometer.h:150
Definition: gls_odometer.h:67
Definition: gls_group.h:58
Definition: gls_odometer.h:66
unsigned int GlsUInt32
Definition: gls_types.h:73
const GlsFloat32 maxValue
Definition: gls_odometer.h:92
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
GlsOdometer(InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
Definition: gls_odometer.h:78
float GlsFloat32
Definition: gls_types.h:78
const GlsFloat32 _maxValue
Definition: gls_odometer.h:146
Definition: gls_group.h:52
void UpdateDigits(void)
Behavior
Definition: gls_odometer.h:64
#define GLS_CLASS_INVARIANT_DECLARATION(ClassName)
Definition: gls_class_invariant.h:80
Definition: gls_odometer.h:58
Definition: gls_odometer.h:77
const GeometryType _geometryType
Definition: gls_odometer.h:149
bool GlsBool
Definition: gls_types.h:96
GlsGroup::InitParameters groupInitParameters
Definition: gls_odometer.h:88
InitParameters CopyWithObjectsArray(GlsDisplayObject *const *newObjects) const
const Behavior _behavior
Definition: gls_odometer.h:148
const GlsFloat64 _lastMagnitude
Definition: gls_odometer.h:154
const GlsFloat32 _rolloverThreshold
Definition: gls_odometer.h:147
const GlsFloat32 _textureScale
Definition: gls_odometer.h:151
const Behavior behavior
Definition: gls_odometer.h:97
const GlsFloat32 degreesPerDigit
Definition: gls_odometer.h:99
const GlsFloat32 minValue
Definition: gls_odometer.h:91
const GlsFloat32 textureScale
Definition: gls_odometer.h:100
double GlsFloat64
Definition: gls_types.h:87
This header defines the GlsGroup class in the GL Studio DO-178B Runtime Library.
Definition: gls_display_object.h:64