OpendTect-6_4  6.4
userinputobj.h
Go to the documentation of this file.
1 #ifndef userinputobj_h
2 #define userinputobj_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Lammertink
9  Date: 21/2/2002
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "generalmod.h"
16 #include "datainpspec.h"
17 #include "convert.h"
18 #include "undefval.h"
19 
20 class CallBack;
21 class BufferStringSet;
22 class uiString;
23 
24 
26 {
27 public:
28 
30  virtual ~UserInputObj() {}
31 
32  virtual const char* text() const = 0;
33  virtual int getIntValue() const = 0;
34  virtual double getDValue() const = 0;
35  virtual float getFValue() const = 0;
36  virtual bool getBoolValue() const = 0;
37 
38  virtual void setText(const char*) = 0;
39  virtual void setValue(const char* s);
40  virtual void setValue(int) = 0;
41  virtual void setValue(double) = 0;
42  virtual void setValue(float) = 0;
43  virtual void setValue(bool) = 0;
44 
45  virtual void setReadOnly( bool = true ) = 0;
46  virtual bool isReadOnly() const = 0;
47 
48  virtual void setEmpty() = 0;
49  virtual void addItem(const uiString&);
50 
53  bool notifyValueChanging( const CallBack& cb );
54 
57  bool notifyValueChanged( const CallBack& cb );
58 
60  bool notifyUpdateRequested( const CallBack& cb );
61 
63  bool update( const DataInpSpec& s );
64 
65  virtual void setToolTip(const uiString&) = 0;
66 
67 protected:
68 
70  virtual bool notifyValueChanging_(const CallBack&) =0;
72  virtual bool notifyValueChanged_(const CallBack&) =0;
73  virtual bool notifyUpdateRequested_(const CallBack&) =0;
74  virtual bool update_( const DataInpSpec&) =0;
75 
76 public:
77  /*mDeprecated*/ double getdValue() const { return getDValue(); }
78  /*mDeprecated*/ float getfValue() const { return getFValue(); }
79 };
80 
81 
82 template<class T>
84 {
85 public:
86 
87  virtual const char* text() const
88  { return Conv::to<const char*>( getvalue_() ); }
89  virtual int getIntValue() const
90  { return Conv::to<int>( getvalue_() ); }
91  virtual double getDValue() const
92  { return Conv::to<double>( getvalue_() );}
93  virtual float getFValue() const
94  { return Conv::to<float>( getvalue_() ); }
95  virtual bool getBoolValue() const
96  { return Conv::to<bool>( getvalue_() ); }
97 
98  virtual void setText( const char* s )
99  { setvalue_( Conv::to<T>(s) ); }
100  virtual void setValue( const char* s )
101  { setText( s ); }
102  virtual void setValue( int i )
103  { setvalue_( Conv::to<T>(i) ); }
104  virtual void setValue( double d )
105  { setvalue_( Conv::to<T>(d) ); }
106  virtual void setValue( float f )
107  { setvalue_( Conv::to<T>(f) ); }
108  virtual void setValue( bool b )
109  { setvalue_( Conv::to<T>(b) ); }
110 
111  void setEmpty()
112  { setvalue_(mUdf(T)); }
113 
114 protected:
115  // return true if implemented.
116  virtual bool setEmpty_() { return false; }
117 
118  virtual void setvalue_( T v ) = 0;
119  virtual T getvalue_() const = 0;
120 
121 };
122 
123 #endif
#define mExpClass(module)
Definition: commondefs.h:160
virtual void setText(const char *s)
Definition: userinputobj.h:98
virtual void setValue(double d)
Definition: userinputobj.h:104
virtual void setValue(int i)
Definition: userinputobj.h:102
virtual int getIntValue() const
Definition: userinputobj.h:89
virtual void setValue(bool b)
Definition: userinputobj.h:108
Definition: uistring.h:89
Set of BufferString objects.
Definition: bufstringset.h:28
UserInputObj()
Definition: userinputobj.h:29
virtual const char * text() const
Definition: userinputobj.h:87
double getdValue() const
Definition: userinputobj.h:77
Specification of input characteristics.
Definition: datainpspec.h:89
void setEmpty()
Definition: userinputobj.h:111
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
float getfValue() const
Definition: userinputobj.h:78
virtual double getDValue() const
Definition: userinputobj.h:91
virtual bool setEmpty_()
Definition: userinputobj.h:116
void setEmpty()
virtual void setValue(float f)
Definition: userinputobj.h:106
virtual ~UserInputObj()
Definition: userinputobj.h:30
virtual float getFValue() const
Definition: userinputobj.h:93
Definition: userinputobj.h:25
#define mClass(module)
Definition: commondefs.h:164
virtual void setValue(const char *s)
Definition: userinputobj.h:100
virtual bool getBoolValue() const
Definition: userinputobj.h:95
CallBacks object-oriented (object + method).
Definition: callback.h:57
Definition: userinputobj.h:83

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019