HyperspaceExplorer 0.7.1
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
UI::Dialogs::PluginCreator Class Reference

Abstract base class for all Dialogs which allow entering a custom function. More...

#include <PluginCreator.h>

Inheritance diagram for UI::Dialogs::PluginCreator:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

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().

Todo:
set the function name to symbolic() in the descendants' constructors
Author:
Helge Preuss <lene.preuss@gmail.com>

Member Function Documentation

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.

Parameters:
typethe plugin's function type: real, polar, surface or complex
namethe name of the plugin
parentthe QDialog calling this function
Returns:
success

References begin(), compile(), functionPresent(), Loki::SingletonHolder< T, CreationPolicy >::Instance(), LibraryName, link(), and writeSource().

Here is the call graph for this function:

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.

Todo:
Might tweak the compilation flags a little, or make them variable
Parameters:
namethe name of the plugin
Returns:
success

References Loki::SingletonHolder< T, CreationPolicy >::Instance().

Referenced by checkValidity().

Here is the call graph for this function:

Here is the caller graph for this function:

QString UI::Dialogs::PluginCreator::libraryName ( ) [inline]

Get the name of the selected dynamic library containing a function.

Returns:
the name of the selected DLL

References LibraryName.

Referenced by CustomComplexFunction::CustomComplexFunction(), CustomFunction::CustomFunction(), CustomPolarFunction::CustomPolarFunction(), and CustomSurface::CustomSurface().

Here is the caller graph for this function:

bool UI::Dialogs::PluginCreator::link ( QString  name) [protected]

link the object file generated by compile() into a dynamic library.

Parameters:
namethe name of the plugin
Returns:
success

Referenced by checkValidity().

Here is the caller graph for this function:

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.

Parameters:
typethe plugin's function type: real, polar, surface or complex
parentthe QDialog calling this function
Returns:
success

References begin(), functionPresent(), Loki::SingletonHolder< T, CreationPolicy >::Instance(), and LibraryName.

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:19 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo