MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParameterController.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  ParameterController.h A Panel that controls a Parameter
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
27 #ifndef PARAMETERCONTROLLER_H
28 #define PARAMETERCONTROLLER_H
29 
30 #include "Panel.h"
31 #include "Parameter.h"
32 
33 namespace MFM
34 {
39  template <class CC>
40  class ParameterController : public Panel
41  {
42  protected:
43  typedef typename CC::ATOM_TYPE T;
44  Parameter<CC> * m_parameter;
45  T * m_patom;
46  bool m_bigText;
47 
48  public:
49 
51  m_parameter(0),
52  m_bigText(false)
53  { }
54 
55  void SetBigText(bool value)
56  {
57  m_bigText = value;
58  }
59 
60  virtual ~ParameterController()
61  { }
62 
63  virtual void SetParameter(ElementParameter<CC>* pb)
64  {
65  SetParameter(pb, &pb->GetAtom());
66  }
67 
68  void SetParameter(Parameter<CC>* pb, T * patom)
69  {
70  if (!pb && !patom)
71  {
72  m_parameter = 0;
73  m_patom = 0;
74  return;
75  }
76 
77  if (!pb || !patom)
78  {
79  FAIL(ILLEGAL_ARGUMENT);
80  }
81  m_parameter = pb;
82  m_patom = patom;
83  Init();
84  }
85 
86  virtual void Init() = 0;
87 
88  Parameter<CC> * GetParameter()
89  {
90  return m_parameter;
91  }
92 
93  const Parameter<CC> * GetParameter() const
94  {
95  return m_parameter;
96  }
97  };
98 }
99 
100 #endif /* PARAMETERCONTROLLER_H */
Definition: Panel.h:115
Definition: Parameter.h:43
Definition: ParameterController.h:40
Definition: Parameter.h:51