plugin.h 6.27 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

#include "types.h"
Sylvain Thery's avatar
Sylvain Thery committed
10
#include "schnapps.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
11

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

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

namespace SCHNApps
{

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

	friend class SCHNApps;

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

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

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

	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
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

//	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
68 69 70 71
	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
72
	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
73
	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
74 75


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

Sylvain Thery's avatar
Sylvain Thery committed
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 154
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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
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
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
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
188 189 190 191 192 193 194
} // namespace SCHNApps

} // namespace CGoGN

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

#endif