HyperspaceExplorer 0.7.1
|
Abstract base class for all Dialogs which allow entering a custom function. More...
#include <PluginCreator.h>
Classes | |
class | LoadFunctionHelper |
Class template with a static function to simulate a function template. More... | |
Public Member Functions | |
virtual | ~PluginCreator () |
Empty destructor. | |
QString | libraryName () |
Get the name of the selected dynamic library containing a function. | |
Protected Member Functions | |
bool | loadFunction (const QString &, QDialog *) |
Display and load the selected DLL into current address space. | |
bool | checkValidity (const QString &, const QString &, QDialog *) |
Called when the user clicks the OK button in the Function Dialog. | |
bool | compile (QString) |
Compile the C++ source code written by writeSource() | |
bool | link (QString) |
link the object file generated by compile() into a dynamic library. | |
Private Member Functions | |
virtual bool | loadFunction ()=0 |
Display and load the selected DLL into current address space. | |
virtual bool | functionPresent (const QString &)=0 |
Loads the dynamic library given by libName, if it exists and can be loaded. | |
virtual void | writeSource ()=0 |
Write a C++ source file containing the given function. | |
Private Attributes | |
QString | LibraryName |
Filename of the DLL to be loaded. |
Abstract base class for all Dialogs which allow entering a custom function.
The user can enter a mathematical function in C++ syntax in almost symbolic notation and get the function compiled and loaded and displayed.
This class contains all the variables and functions common to the four different function types, the differences being encapsulated in a template class with auxiliary functions.
This class is abstract. The inheriting classes must implement the members loadFunction(), functionPresent() and writeSource().
bool UI::Dialogs::PluginCreator::checkValidity | ( | const QString & | type, |
const QString & | name, | ||
QDialog * | parent | ||
) | [protected] |
Called when the user clicks the OK button in the Function Dialog.
Checks whether all fields are filled in, whether the given function is valid C++ syntax, ie. whether it compiles, and whether the compiled code links into a dynamic library.
As a side effect, it generates this library.
Finally, it checks whether the library can be loaded. if so, it accepts the input.
Also, this function creates a directory structure "plugins/real" under the resource directory and changes the CWD to that folder for the duration of checkValidity ().
The name for this function is chosen rather unfortunately, i admit.
type | the plugin's function type: real, polar, surface or complex |
name | the name of the plugin |
parent | the QDialog calling this function |
References begin(), compile(), functionPresent(), Loki::SingletonHolder< T, CreationPolicy >::Instance(), LibraryName, link(), and writeSource().
bool UI::Dialogs::PluginCreator::compile | ( | QString | name | ) | [protected] |
Compile the C++ source code written by writeSource()
Display errors and warnings, if they come up.
Needs "Vector.H" in the current directory or in the C++ include path.
name | the name of the plugin |
References Loki::SingletonHolder< T, CreationPolicy >::Instance().
Referenced by checkValidity().
QString UI::Dialogs::PluginCreator::libraryName | ( | ) | [inline] |
Get the name of the selected dynamic library containing a function.
References LibraryName.
Referenced by CustomComplexFunction::CustomComplexFunction(), CustomFunction::CustomFunction(), CustomPolarFunction::CustomPolarFunction(), and CustomSurface::CustomSurface().
bool UI::Dialogs::PluginCreator::link | ( | QString | name | ) | [protected] |
link the object file generated by compile() into a dynamic library.
name | the name of the plugin |
Referenced by checkValidity().
bool UI::Dialogs::PluginCreator::loadFunction | ( | const QString & | type, |
QDialog * | parent | ||
) | [protected] |
Display and load the selected DLL into current address space.
Loads a dynamic library, which can be selected by the user on a QFileDialog.
Calls functionPresent() below. see there.
type | the plugin's function type: real, polar, surface or complex |
parent | the QDialog calling this function |
References begin(), functionPresent(), Loki::SingletonHolder< T, CreationPolicy >::Instance(), and LibraryName.