plugin.h 6.25 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
#ifndef _PLUGIN_H_
#define _PLUGIN_H_

#include <QtPlugin>
#include <QAction>
Sylvain Thery's avatar
Sylvain Thery committed
6
7
#include <GL/glew.h>

Pierre Kraemer's avatar
Pierre Kraemer committed
8
9
10

#include "types.h"

Thery Sylvain's avatar
Thery Sylvain committed
11
#include "dll.h"
Sylvain Thery's avatar
Sylvain Thery committed
12

Pierre Kraemer's avatar
Pierre Kraemer committed
13
14
15
16
17
18
namespace CGoGN
{

namespace SCHNApps
{

Sylvain Thery's avatar
Sylvain Thery committed
19
class SCHNAPPS_API Plugin : public QObject
Pierre Kraemer's avatar
Pierre Kraemer committed
20
21
22
23
24
25
{
	Q_OBJECT

	friend class SCHNApps;

public:
26
27
	Plugin();
	virtual ~Plugin();
Pierre Kraemer's avatar
Pierre Kraemer committed
28
29

public slots:
30
31
32
	QString getName();
	QString getFilePath();
	SCHNApps* getSCHNApps();
Pierre Kraemer's avatar
Pierre Kraemer committed
33
34

private:
35
36
37
	void setName(const QString& name);
	void setFilePath(const QString& f);
	void setSCHNApps(SCHNApps* s);
Pierre Kraemer's avatar
Pierre Kraemer committed
38
39
40
41
42
43
44
45

	virtual bool enable() = 0;
	virtual void disable() = 0;

protected:
	QString m_name;
	QString m_filePath;
	SCHNApps* m_schnapps;
Sylvain Thery's avatar
Sylvain Thery committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

//	void pythonRecording(const QString& slotName, const QString& returned = "",  const QString& param1 = "", const QString& param2 = "", const QString& param3 = "", const QString& param4 = "");

	//template <typename T1, typename T2, typename T3, typename T4>
	//inline void pythonRecording(QString slotName, QString returned = "", T1 param1 = "", T2 param2 = "", T3 param3 = "", T4 param4 = "");

	template <typename T1>
	inline void pythonRecording(QString slotName, QString returned, T1 param1);

	template <typename T1, typename T2>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2);

	template <typename T1, typename T2, typename T3>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3);

	template <typename T1, typename T2, typename T3, typename T4>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4);

	template <typename T1, typename T2, typename T3, typename T4, typename T5>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5);

Sylvain Thery's avatar
Sylvain Thery committed
67
68
69
70
	template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6);


Sylvain Thery's avatar
Sylvain Thery committed
71
	template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
Sylvain Thery's avatar
Sylvain Thery committed
72
	inline void pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7, T8 param8, T9 param9, T10 param10, T11 param11);
Sylvain Thery's avatar
Sylvain Thery committed
73
74


Pierre Kraemer's avatar
Pierre Kraemer committed
75
76
};

Sylvain Thery's avatar
Sylvain Thery committed
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
template <typename T>
inline T pyR_stringify(T v)
{
	return v;
}

template <>
inline QString pyR_stringify(QString v)
{
	return "\"" + v + "\"";
}



template <typename T1>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ");" << endl;
	}
}

template <typename T1, typename T2>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ");" << endl;
	}
}

template <typename T1, typename T2, typename T3>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", " << pyR_stringify(param3) << ");" << endl;
	}
}


template <typename T1, typename T2, typename T3, typename T4>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", " << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ");" << endl;
	}
}

template <typename T1, typename T2, typename T3, typename T4, typename T5>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", ";
		*rec << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ", " << pyR_stringify(param5) << ");" << endl;
	}
}


Sylvain Thery's avatar
Sylvain Thery committed
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", ";
		*rec << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ", " << pyR_stringify(param5) << ", " << pyR_stringify(param6)  << ");" << endl;
	}
}



Sylvain Thery's avatar
Sylvain Thery committed
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
void Plugin::pythonRecording(QString slotName, QString returned, T1 param1, T2 param2, T3 param3, T4 param4, T5 param5, T6 param6, T7 param7, T8 param8, T9 param9, T10 param10, T11 param11)
{
	QTextStream* rec = m_schnapps->pythonStreamRecorder();
	if (rec)
	{
		if (!returned.isEmpty())
			*rec << returned << " = ";
		*rec << this->getName() << "." << slotName << "(" << pyR_stringify(param1) << ", " << pyR_stringify(param2) << ", ";
		*rec << pyR_stringify(param3) << ", " << pyR_stringify(param4) << ", " << pyR_stringify(param5) << ", ";
		*rec << pyR_stringify(param6) << ", " << pyR_stringify(param7) << ", " << pyR_stringify(param8) << ", ";
		*rec << pyR_stringify(param9) << ", " << pyR_stringify(param10) << ", " << pyR_stringify(param11) << ");" << endl;
	}
}
	



Pierre Kraemer's avatar
Pierre Kraemer committed
187
188
189
190
191
192
193
} // namespace SCHNApps

} // namespace CGoGN

Q_DECLARE_INTERFACE(CGoGN::SCHNApps::Plugin, "CGoGN.SCHNapps.Plugin")

#endif