Transient Recorder Framework
TRConfigParam.h
Go to the documentation of this file.
1 /* This file is part of the Transient Recorder Framework.
2  * It is subject to the license terms in the LICENSE.txt file found in the
3  * top-level directory of this distribution and at
4  * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. No part
5  * of the Transient Recorder Framework, including this file, may be copied,
6  * modified, propagated, or distributed except according to the terms
7  * contained in the LICENSE.txt file.
8  */
9 
16 #ifndef TRANSREC_CONFIG_PARAM_H
17 #define TRANSREC_CONFIG_PARAM_H
18 
19 #include <epicsAssert.h>
20 
21 #include <asynPortDriver.h>
22 
23 #include "TRNonCopyable.h"
24 #include "TRConfigParamTraits.h"
25 
26 class TRBaseDriver;
27 
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 
35 class TRConfigParamBase
36 {
37  friend class TRBaseDriver;
38 
39 private:
40  virtual void setSnapshotToDesired () = 0;
41  virtual void setEffectiveToSnapshot () = 0;
42  virtual void setEffectiveToInvalid () = 0;
43 };
44 
45 #endif
46 
64 template <typename ValueType, typename EffectiveValueType = ValueType>
66  private TRConfigParamBase,
67  private TRNonCopyable
68 {
69  friend class TRBaseDriver;
70 
71  typedef TRConfigParamTraits<ValueType> Traits;
72  typedef TRConfigParamTraits<EffectiveValueType> EffectiveTraits;
73 
74 private:
75  bool m_initialized;
76  bool m_internal;
77  bool m_irrelevant;
78  int m_desired_param;
79  int m_effective_param;
80  ValueType m_snapshot_value;
81  EffectiveValueType m_invalid_value;
82  TRBaseDriver *m_driver;
83 
84 public:
93  inline TRConfigParam ()
94  : m_initialized(false)
95  {
96  }
97 
107  inline ValueType getSnapshot ()
108  {
109  assert(m_initialized);
110 
111  return m_snapshot_value;
112  }
113 
122  inline ValueType getSnapshotFast ()
123  {
124  return m_snapshot_value;
125  }
126 
137  inline void setIrrelevant ()
138  {
139  assert(m_initialized);
140 
141  m_irrelevant = true;
142  }
143 
161  inline void setSnapshot (ValueType value)
162  {
163  assert(m_initialized);
164 
165  m_snapshot_value = value;
166  }
167 
186  ValueType getDesired ();
187 
198  void setDesired (ValueType value);
199 
210  inline int desiredParamIndex ()
211  {
212  assert(m_initialized);
213 
214  return m_desired_param;
215  }
216 
217 private:
218  void init (TRBaseDriver *driver, char const *base_name, EffectiveValueType invalid_value, bool internal);
219  void setEffectiveParam (EffectiveValueType value);
220 
221 private:
222  // Implementations of TRConfigParamBase virtual functions
223  void setSnapshotToDesired ();
224  void setEffectiveToSnapshot ();
225  void setEffectiveToInvalid ();
226 };
227 
228 #endif
void setSnapshot(ValueType value)
Adjust the snapshot value for the current configuration.
Definition: TRConfigParam.h:161
void setIrrelevant()
Mark this parameter as irrelevant for the current configuration.
Definition: TRConfigParam.h:137
ValueType getSnapshotFast()
Like getSnapshot but does not have any asserts.
Definition: TRConfigParam.h:122
Central class of the Transient Recorder framework for transient recorders (digitizers).
Definition: TRBaseDriver.h:55
ValueType getSnapshot()
Return the current snapshot value of the parameter.
Definition: TRConfigParam.h:107
TRConfigParam()
Default constructor for configuration parameters.
Definition: TRConfigParam.h:93
Transient Recorder configuration parameter.
Definition: TRConfigParam.h:65
int desiredParamIndex()
Return the asyn parameter index of the desired-value parameter.
Definition: TRConfigParam.h:210