File: query_templates.h

package info (click to toggle)
mixviews 1.20-10.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,928 kB
  • ctags: 5,960
  • sloc: cpp: 32,879; ansic: 2,110; makefile: 445; sh: 17
file content (107 lines) | stat: -rw-r--r-- 2,178 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// query_templates.h

#ifndef QUERY_TEMPLATES_H
#define QUERY_TEMPLATES_H

#include "localdefs.h"
#include "queryvalue.h"
#include "settergetter.h"

template <class Type>
class Query : public QueryNumber {
	typedef QueryNumber Super;
public:
	Query(const char *lbl, SetterGetter<Type>* sg,
	      const Range& range, boolean displayRange)
		: QueryNumber(lbl, &CharCheck::numsOnly),
		setterGetter(sg), bounds(range),
		displayBounds(displayRange) {}
	virtual ~Query();
	redefined const char* get() const;
	redefined QueryType type();
	redefined const Range& range() { return bounds; }
protected:
	redefined boolean checkAndSet(const char *);
protected:
	SetterGetter<Type>* setterGetter;
	const Range bounds;
	boolean displayBounds;
};

template <class Type>
inline QueryValue*
createQuery(
		const char* label,
		Type* ptr,
		const Range& range,
		boolean displayRange
           ) {
	return new Query<Type>(
			label,
			createSetterGetter(ptr),
			range,
			displayRange);
}

#ifndef __GNUG__

template <class Status, class Type>
inline QueryValue* createQuery(
				const char* label,
				Status (*setter)(Type),
				Type (*getter)(),
				const Range &range,
				boolean displayRange
                    ) {
	return new Query<Type>(
			label,
			createSetterGetter(setter, getter),
			range,
			displayRange);
}


template <class Object, class Status, class Type>
inline QueryValue* createQuery(
				const char* label,
				Object* o,
				Status (Object::*setter)(Type),
				Type (Object::*getter)() const,
				const Range &range,
				boolean displayRange
                    ) {
	return new Query<Type>(
			label,
			createSetterGetter(o, setter, getter),
			range,
			displayRange);
}

template <class Object, class Type>
inline QueryValue* createVoidQuery(
				const char* label,
				Object* o,
				void (Object::*setter)(Type),
				Type (Object::*getter)() const,
				const Range &range,
				boolean displayRange
                    ) {
	return new Query<Type>(
			label,
			new MethodVoidSetterGetter<Object, Type>(
					o,
					setter,
					getter
			),
			range,
			displayRange);
}

#endif /* __GNUG__ */

#ifdef __GNUG__
#include "query_templates.C"
#endif

#endif