Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mcMathCore Class Reference

#include <MathCore.h>

Collaboration diagram for mcMathCore:

Collaboration graph
[legend]
List of all members.

Detailed Description

The mcMathCore class: this static class contains global variables, functions and defines used by almost all MathCore classes.

This class has the following roles:

Definition at line 82 of file MathCore.h.

GENERAL SECTION

Defines functions and values for general purposes.

void SyntaxError (wxString str)
 Call this function with a description of the error to notify the user about a syntax error; this function will return immediately and the caller should continue data processing as if nothing happened.
bool isGUIEnabled () const
 Returns TRUE if mcElementGUI are being allocated when new elements are created: that is, GUI classes of MathCore are being used.
bool isMathEnabled () const
 Like isGUIEnabled() but for math section.
bool isIOEnabled () const
 Like isGUIEnabled() but for input/output section.
static void Setup (bool bIO=TRUE, bool bMath=TRUE, bool bGUI=TRUE)
 Builds all the objects with a constructor (here declared as pointers) using the default values; initializes the specified subsystems; prepares everything to work.
static void Cleanup ()
 Deallocates MathCore stuff.

MATH SECTION

Holds the array of solvers.

mcRealValue GetStepThreshold () const
 Returns the step threshold.
void SetStepThreshold (const mcRealValue &n)
 Changes the step threshold.
static void LoadDefaultSolvers ()
 Loads the default mcSolvers in the array.
static mcSolverArray arrSolvers
 The main mcSolver array.

KEYS SECTION

The virtual keycodes customizable and non-customizable used for editing.

bool MatchEditKeys (const mcKey &ke)
 Returns TRUE if the given keypress matches one of the following combinations: m_pgui_EditExpKey, m_pgui_EditSubscriptKey, m_pDeleteKey, m_pCancelKey->.
mcKeym_pEditExpKey
 Edits/inserts the exponent.
mcKeym_pEditSubscriptKey
 Edits/inserts the subscript.
mcKeym_pDeleteKey
 Deletes the char at the left of the cursor.
mcKeym_pCancelKey
 Deletes the char at the right of the cursor.
mcKeym_pNewLineKey
 Creates a new line (see mcText).

DEBUG SECTION

General debug variables and functions used by MathCore.

int m_nMaxSharing
 The maximum number of elements which shared the same data in the current session (works as COW performance meter).
int m_nIndentationStep
 Indentation step for debug output only.
static void(* OnError )(const wxString &) = NULL
 The function called by mcMathCore::Get()->SyntaxError() with the description of the error.

Public Member Functions

 mcMathCore ()
 Main constructor: inits all the variables contained in this class.
virtual ~mcMathCore ()
 The Destructor: frees all the memory allocated by this object.

Static Public Member Functions

static mcMathCoreGet ()
 Returns the global instance of mcMathCore.
static void Set (mcMathCore *)
 math_Replaces the current instance of mcMathCore class with the given one.
static bool isOk ()
 Returns TRUE if the mcMathCore global instance is ready to work.

Protected Member Functions

void Init (bool bIO=TRUE, bool bMath=TRUE, bool bGUI=TRUE)
void SetupGUI (void(*OnError)(const wxString &)=NULL)
void SetupIO ()
void SetupMath ()
void CleanupGUI ()
void CleanupIO ()
void CleanupMath ()

Protected Attributes

bool m_bGUIEnabled
 TRUE if the GUI section of the library is enabled.
bool m_bIOEnabled
 TRUE if the IO section of the library is enabled.
bool m_bMathEnabled
 TRUE if the MATH section of the library is enabled.
mcRealValue m_fStepThreshold
 The current step threshold.

Static Protected Attributes

static mcMathCoreg_pTheInstance = NULL
 The global instance of the class shared everywhere in programs which use this library.


Constructor & Destructor Documentation

mcMathCore::mcMathCore  ) 
 

Main constructor: inits all the variables contained in this class.

Definition at line 84 of file MathCore.cpp.

References m_bGUIEnabled, m_bIOEnabled, m_bMathEnabled, m_nIndentationStep, and m_nMaxSharing.

Referenced by Setup().

mcMathCore::~mcMathCore  )  [virtual]
 

The Destructor: frees all the memory allocated by this object.

Definition at line 93 of file MathCore.cpp.

References CleanupGUI(), CleanupIO(), CleanupMath(), isGUIEnabled(), isIOEnabled(), isMathEnabled(), and mcSAFE_DELETE.


Member Function Documentation

void mcMathCore::Cleanup  )  [static]
 

Deallocates MathCore stuff.

Definition at line 146 of file MathCore.cpp.

References g_pTheInstance, and mcSAFE_DELETE.

void mcMathCore::CleanupGUI  )  [protected]
 

Definition at line 311 of file MathCore.cpp.

References mcElementHelpers::gui_DeleteDefaultStyles(), mcMathMngHelpers::gui_DeleteStyles(), m_bGUIEnabled, m_pCancelKey, m_pDeleteKey, m_pEditExpKey, m_pEditSubscriptKey, m_pNewLineKey, and mcSAFE_DELETE.

Referenced by ~mcMathCore().

void mcMathCore::CleanupIO  )  [protected]
 

Definition at line 166 of file MathCore.cpp.

References m_bIOEnabled.

Referenced by ~mcMathCore().

void mcMathCore::CleanupMath  )  [protected]
 

Definition at line 235 of file MathCore.cpp.

References arrSolvers, mcElementHelpers::Cleanup(), mcValue::Cleanup(), mcSymbol::CleanupSymbols(), mcAbstractArray::data_Clear(), m_bMathEnabled, and mcSAFE_DELETE.

Referenced by ~mcMathCore().

mcMathCore * mcMathCore::Get  )  [static]
 

Returns the global instance of mcMathCore.

This is the way all MathCore functions access the mcMathCore instance; of course, it should be also the way the user of the library access mcMathCore... just write

     mcMathCore::Get()->Setup();
     ... the code which uses the MathCore library ...
     mcMathCore::Get()->Cleanup();

Definition at line 105 of file MathCore.cpp.

References g_pTheInstance, and mcASSERT.

Referenced by mcPolynomialHelpers::gui_BackInput(), mcMonomialHelpers::gui_BackInput(), mcSymbolHelpers::gui_BaseInput(), mcNumberHelpers::gui_BaseInput(), mcFunctionHelpers::gui_BaseInput(), mcExpContainerHelpers::gui_BaseInput(), mcElementArrayHelpers::gui_DrawSelection(), mcExpElementHelpers::gui_EditExpSub(), mcTextHelpers::gui_Input(), mcMathMngHelpers::gui_Input(), mcEmptyBoxHelpers::gui_Input(), mcElementArrayHelpers::gui_Input(), mcDecorationHelpers::gui_Input(), mcNumberHelpers::gui_isBaseEndKey(), mcFractionHelpers::gui_isEndKey(), mcMonomialHelpers::gui_Replace(), and mcElement::~mcElement().

mcRealValue mcMathCore::GetStepThreshold  )  const [inline]
 

Returns the step threshold.

Definition at line 207 of file MathCore.h.

References m_fStepThreshold.

void mcMathCore::Init bool  bIO = TRUE,
bool  bMath = TRUE,
bool  bGUI = TRUE
[protected]
 

Definition at line 132 of file MathCore.cpp.

References mcElementHelpers::Init(), SetupGUI(), SetupIO(), and SetupMath().

Referenced by Setup().

bool mcMathCore::isGUIEnabled  )  const
 

Returns TRUE if mcElementGUI are being allocated when new elements are created: that is, GUI classes of MathCore are being used.

Definition at line 354 of file MathCore.cpp.

References m_bGUIEnabled.

Referenced by ~mcMathCore().

bool mcMathCore::isIOEnabled  )  const
 

Like isGUIEnabled() but for input/output section.

Definition at line 360 of file MathCore.cpp.

References m_bIOEnabled.

Referenced by ~mcMathCore().

bool mcMathCore::isMathEnabled  )  const
 

Like isGUIEnabled() but for math section.

Definition at line 357 of file MathCore.cpp.

References m_bMathEnabled.

Referenced by ~mcMathCore().

static bool mcMathCore::isOk  )  [inline, static]
 

Returns TRUE if the mcMathCore global instance is ready to work.

Definition at line 144 of file MathCore.h.

References g_pTheInstance.

void mcMathCore::LoadDefaultSolvers  )  [static]
 

Loads the default mcSolvers in the array.

Definition at line 392 of file MathCore.cpp.

References mcSAFE_ADD.

bool mcMathCore::MatchEditKeys const mcKey ke  ) 
 

Returns TRUE if the given keypress matches one of the following combinations: m_pgui_EditExpKey, m_pgui_EditSubscriptKey, m_pDeleteKey, m_pCancelKey->.

Definition at line 363 of file MathCore.cpp.

References m_pCancelKey, m_pDeleteKey, m_pEditExpKey, m_pEditSubscriptKey, and mcKey::MatchKey().

Referenced by mcNumberHelpers::gui_isBaseEndKey().

void mcMathCore::Set mcMathCore  )  [static]
 

math_Replaces the current instance of mcMathCore class with the given one.

This function should be used only in the case that, for some special reasons, the user wants to create a class derived from mcMathCore and he wants to use it instead of the base class.

Definition at line 113 of file MathCore.cpp.

References g_pTheInstance.

void mcMathCore::SetStepThreshold const mcRealValue n  )  [inline]
 

Changes the step threshold.

Definition at line 210 of file MathCore.h.

References m_fStepThreshold.

void mcMathCore::Setup bool  bIO = TRUE,
bool  bMath = TRUE,
bool  bGUI = TRUE
[static]
 

Builds all the objects with a constructor (here declared as pointers) using the default values; initializes the specified subsystems; prepares everything to work.

Definition at line 120 of file MathCore.cpp.

References g_pTheInstance, Init(), and mcMathCore().

void mcMathCore::SetupGUI void(*)(const wxString &)  OnError = NULL  )  [protected]
 

Definition at line 271 of file MathCore.cpp.

References mcElementHelpers::gui_InitDefaultStyles(), mcMathMngHelpers::gui_InitStyles(), m_bGUIEnabled, m_pCancelKey, m_pDeleteKey, m_pEditExpKey, m_pEditSubscriptKey, m_pNewLineKey, mcASSERT, and OnError.

Referenced by Init().

void mcMathCore::SetupIO  )  [protected]
 

Definition at line 158 of file MathCore.cpp.

References m_bIOEnabled.

Referenced by Init().

void mcMathCore::SetupMath  )  [protected]
 

Definition at line 174 of file MathCore.cpp.

References mcElement::data_Check(), mcValue::Init(), mcSymbol::InitSymbols(), m_bMathEnabled, m_fStepThreshold, mcElementArray::math_WrapNumber(), mcElementArray::math_WrapSimple(), and mcDEFAULT_STEP_THRESHOLD.

Referenced by Init().

void mcMathCore::SyntaxError wxString  str  ) 
 

Call this function with a description of the error to notify the user about a syntax error; this function will return immediately and the caller should continue data processing as if nothing happened.

Parameters:
str The description of the error

Definition at line 371 of file MathCore.cpp.

References OnError.

Referenced by mcPolynomialHelpers::gui_BackInput(), mcMonomialHelpers::gui_BackInput(), mcSymbolHelpers::gui_BaseInput(), mcNumberHelpers::gui_BaseInput(), mcFunctionHelpers::gui_BaseInput(), mcExpContainerHelpers::gui_BaseInput(), mcExpElementHelpers::gui_EditExpSub(), mcTextHelpers::gui_Input(), mcMathMngHelpers::gui_Input(), mcEmptyBoxHelpers::gui_Input(), mcElementArrayHelpers::gui_Input(), and mcMonomialHelpers::gui_Replace().


Member Data Documentation

mcSolverArray mcMathCore::arrSolvers [static]
 

The main mcSolver array.

Definition at line 69 of file MathCore.cpp.

Referenced by CleanupMath().

mcMathCore * mcMathCore::g_pTheInstance = NULL [static, protected]
 

The global instance of the class shared everywhere in programs which use this library.

Definition at line 67 of file MathCore.cpp.

Referenced by Cleanup(), Get(), isOk(), Set(), and Setup().

bool mcMathCore::m_bGUIEnabled [protected]
 

TRUE if the GUI section of the library is enabled.

Definition at line 90 of file MathCore.h.

Referenced by CleanupGUI(), isGUIEnabled(), mcMathCore(), and SetupGUI().

bool mcMathCore::m_bIOEnabled [protected]
 

TRUE if the IO section of the library is enabled.

Definition at line 91 of file MathCore.h.

Referenced by CleanupIO(), isIOEnabled(), mcMathCore(), and SetupIO().

bool mcMathCore::m_bMathEnabled [protected]
 

TRUE if the MATH section of the library is enabled.

Definition at line 92 of file MathCore.h.

Referenced by CleanupMath(), isMathEnabled(), mcMathCore(), and SetupMath().

mcRealValue mcMathCore::m_fStepThreshold [protected]
 

The current step threshold.

This important value determines how many operations should be performed between two simplification/expansion/resolution (through the mcSolvers) steps. If this number is very high, then you'll see complex data solved in very few steps (the steps could then be quite difficult to check by hand...); if this number is very low, then you'll see a lot of steps even for simple data (all those steps could be quite boring...).

Definition at line 103 of file MathCore.h.

Referenced by GetStepThreshold(), SetStepThreshold(), and SetupMath().

int mcMathCore::m_nIndentationStep
 

Indentation step for debug output only.

Definition at line 263 of file MathCore.h.

Referenced by mcMathCore().

int mcMathCore::m_nMaxSharing
 

The maximum number of elements which shared the same data in the current session (works as COW performance meter).

Definition at line 260 of file MathCore.h.

Referenced by mcMathCore(), and mcElement::~mcElement().

mcKey* mcMathCore::m_pCancelKey
 

Deletes the char at the right of the cursor.

Definition at line 234 of file MathCore.h.

Referenced by CleanupGUI(), mcMonomialHelpers::gui_BackInput(), mcEmptyBoxHelpers::gui_Input(), mcDecorationHelpers::gui_Input(), mcFractionHelpers::gui_isEndKey(), MatchEditKeys(), and SetupGUI().

mcKey* mcMathCore::m_pDeleteKey
 

Deletes the char at the left of the cursor.

Definition at line 233 of file MathCore.h.

Referenced by CleanupGUI(), mcMonomialHelpers::gui_BackInput(), MatchEditKeys(), and SetupGUI().

mcKey* mcMathCore::m_pEditExpKey
 

Edits/inserts the exponent.

Pressing this key, if the current element allows it, an exponent is created and the cursor is moved there. The user should be able to insert any mathdata as exponent.

Definition at line 226 of file MathCore.h.

Referenced by CleanupGUI(), MatchEditKeys(), and SetupGUI().

mcKey* mcMathCore::m_pEditSubscriptKey
 

Edits/inserts the subscript.

The same as mcMathCore::m_pgui_EditExpKey, but this key creates a subscript and allows the user to edit it. Currently, only mcSymbols allow subscripts.

Definition at line 231 of file MathCore.h.

Referenced by CleanupGUI(), MatchEditKeys(), and SetupGUI().

mcKey* mcMathCore::m_pNewLineKey
 

Creates a new line (see mcText).

Definition at line 235 of file MathCore.h.

Referenced by CleanupGUI(), and SetupGUI().

void(* mcMathCore::OnError)(const wxString &) = NULL [static]
 

The function called by mcMathCore::Get()->SyntaxError() with the description of the error.

Definition at line 68 of file MathCore.cpp.

Referenced by SetupGUI(), and SyntaxError().


The documentation for this class was generated from the following files:

Documentation generated with Doxygen on Sun Feb 6 17:12:45 2005
Visit MathStudio home page for more info

[ Top ]