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

mcSymbol Class Reference

#include <Symbol.h>

Inheritance diagram for mcSymbol:

Inheritance graph
[legend]
Collaboration diagram for mcSymbol:

Collaboration graph
[legend]
List of all members.

Detailed Description

Allows the user to input characters as well as digits.

In MathCore a symbol can be a parameter, a constant, or an unknown. Users can type any char they want, but if it is not registered in MathCore parameters, constants or unknowns lists, the symbol will be drawn with a different color, to underline that it is not recognized by MathCore.

Definition at line 450 of file Symbol.h.

Static mcSymbol functions and arrays

The global arrays containing the registered parameters, constants and unknowns and some related utility functions.

static void InitSymbols ()
 Inits the symbol arrays.
static void CleanupSymbols ()
 Cleanups the symbol arrays.
static mcSymbolArraymath_FindSymbol (long flags, const wxString &name, wxFontEncoding enc=wxFONTENCODING_DEFAULT, const mcRealValue &value=0.0, const wxString &subscript=wxEmptyString, const wxString &inlined=wxEmptyString, int occ=0, int *entry=NULL, int skipArr=-1)
 Checks if a character is a symbol already registered.
static mcSymbolArraymath_FindSymbol (long flags, const mcSymbolProperties &symtofind, int occurrence=0, int *entry=NULL, int skipArr=-1)
static void CheckArray (mcSymbolArray *)
 Checks the given symbol array, resolving errors.
static void CheckSymbols ()
 Checks the 4 symbol arrays for invalid data; it automatically deletes errors; this function is not very efficient.
static bool LoadSymbols (const wxXml2Node &main, bool removeprevious=TRUE)
 Parses the given XML tree and loads the symbols stored inside.
static void LoadDefaultSymbols (bool removeprevious=TRUE)
 Loads some default parameters, constants, unknowns: pigreco, the 'e' (base of the natural logarithms), Euler's gamma....
static mcSymbolArray arrParameters
 List of registered parameters.
static mcSymbolArray arrConstants
 List of registered constants.
static mcSymbolArray arrUnknowns
 List of registered unknowns.
static mcSymbolArray arrUnregistered
 List of unregistered symbols, currently present in the math data.

Public Member Functions

 mcSymbol (const mcSymbolProperties *sym)
mcSymbol operator^ (const mcPolynomial &m) const
mcSymboloperator^= (const mcPolynomial &m)
virtual void data_Update ()
 data_Updates this symbol, trying to search the
bool data_isValidContainerFor (mcElementType t) const
 Returns TRUE if this element can safely contain the given element type.
mcWRAPPER void data_LinkWith (mcSymbolProperties *prop)
mcWRAPPER void data_Unlink ()
mcWRAPPER bool data_isLinked () const
mcWRAPPER bool data_isLinkedWith (const mcSymbolProperties *p) const
mcWRAPPER wxString data_GetSubscript () const
mcWRAPPER wxString data_GetSymbol () const
mcWRAPPER const mcSymbolPropertiesdata_GetConstProperties () const
 Returns the properties of this symbol.
mcWRAPPER mcSymbolPropertiesdata_GetProperties ()

Private Member Functions

 mcDEFINE_MAIN_CLASS (Symbol, mcExpElement)


Constructor & Destructor Documentation

mcSymbol::mcSymbol const mcSymbolProperties sym  )  [inline]
 

Definition at line 456 of file Symbol.h.

References mcObject::data_SetRefData().


Member Function Documentation

void mcSymbol::CheckArray mcSymbolArray  )  [static]
 

Checks the given symbol array, resolving errors.

Definition at line 133 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, arrUnregistered, mcSymbolProperties::data_Check(), mcSymbolArray::data_GetSymbol(), mcAbstractArray::data_RemoveAt(), and SEARCH_DUPLICATE_IN.

Referenced by CheckSymbols().

void mcSymbol::CheckSymbols  )  [static]
 

Checks the 4 symbol arrays for invalid data; it automatically deletes errors; this function is not very efficient.

Definition at line 155 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, arrUnregistered, and CheckArray().

Referenced by LoadDefaultSymbols().

void mcSymbol::CleanupSymbols  )  [static]
 

Cleanups the symbol arrays.

Definition at line 193 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, arrUnregistered, and mcAbstractArray::data_Clear().

Referenced by mcMathCore::CleanupMath().

mcWRAPPER const mcSymbolProperties* mcSymbol::data_GetConstProperties  )  const [inline]
 

Returns the properties of this symbol.

Definition at line 626 of file Symbol.h.

References mcWRAPPER.

Referenced by mcSymbolHelpers::math_CompareThisOnly().

mcWRAPPER mcSymbolProperties* mcSymbol::data_GetProperties  )  [inline]
 

Definition at line 629 of file Symbol.h.

References mcWRAPPER.

Referenced by mcElementArrayHelpers::math_GetWrappedSymbol().

mcWRAPPER wxString mcSymbol::data_GetSubscript  )  const [inline]
 

Definition at line 590 of file Symbol.h.

References mcSymbolArray::data_GetSubscript(), and mcWRAPPER.

mcWRAPPER wxString mcSymbol::data_GetSymbol  )  const [inline]
 

Definition at line 592 of file Symbol.h.

References mcSymbolArray::data_GetSymbol(), and mcWRAPPER.

Referenced by mcSymbolHelpers::math_isListedBeforeOf().

mcWRAPPER bool mcSymbol::data_isLinked  )  const [inline]
 

Definition at line 585 of file Symbol.h.

References mcWRAPPER.

mcWRAPPER bool mcSymbol::data_isLinkedWith const mcSymbolProperties p  )  const [inline]
 

Definition at line 587 of file Symbol.h.

References mcWRAPPER.

Referenced by mcMonomialHelpers::math_GetMaxDegreeFor().

bool mcSymbol::data_isValidContainerFor mcElementType  t  )  const [inline, virtual]
 

Returns TRUE if this element can safely contain the given element type.

Without this function a lot of errors could be undetectable:

        mcPolynomial pol; // creates a new polynomial
        mcElement e(pol); // references it
        [...]    // the programmers forgots what "e" references
        mcFraction f(e);  // mcFraction wraps a mcPolynomialHelpers class !
        f.data_GetNum();  // CRASH

This function must be overridden by mcElement-derived classes in order to provide a list of the mcElementType it can safely contain.

Reimplemented from mcExpElement.

Definition at line 576 of file Symbol.h.

References mcET_SYMBOL.

mcWRAPPER void mcSymbol::data_LinkWith mcSymbolProperties prop  )  [inline]
 

Definition at line 581 of file Symbol.h.

References mcWRAPPER.

Referenced by mcElementHelpers::math_EvaluateAt(), and mcElementHelpers::math_GetSymbolList().

mcWRAPPER void mcSymbol::data_Unlink  )  [inline]
 

Definition at line 583 of file Symbol.h.

References mcWRAPPER.

virtual void mcSymbol::data_Update  )  [inline, virtual]
 

data_Updates this symbol, trying to search the

Reimplemented from mcElement.

Definition at line 571 of file Symbol.h.

References mcElement::data_Update().

void mcSymbol::InitSymbols  )  [static]
 

Inits the symbol arrays.

This function must be called before using any of the following function.

Definition at line 167 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, arrUnregistered, and mcSymbolArray::data_LinkWithArray().

Referenced by mcMathCore::SetupMath().

void mcSymbol::LoadDefaultSymbols bool  removeprevious = TRUE  )  [static]
 

Loads some default parameters, constants, unknowns: pigreco, the 'e' (base of the natural logarithms), Euler's gamma....

overwriting (if removeprevious == TRUE) eventually present symbols with the same names.

Definition at line 257 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, CheckSymbols(), and mcSymbolArray::data_AddSymbol().

bool mcSymbol::LoadSymbols const wxXml2Node &  main,
bool  removeprevious = TRUE
[static]
 

Parses the given XML tree and loads the symbols stored inside.

If removeprevious == TRUE and other symbols with the same names are found, then they are removed. The only tags contained in the given node (which must be a wxXML_ELEMENT_NODE) must be:

<constant> that has the following accepted properties: name = the name of the constant (must be non-empty) greek = 1 if the constant is a greek character; 0 otherwise subscript = the subscript of the constant (can be empty) inlinedoutput = the inlined representation of this constant (used when exporting as inlined expression) value = the numeric value of the constant

<unknown> that accepts the same properties of <constant>, except for VALUE <param> that accepts the same properties of <constant>, except for VALUE

So, a valid example of an XML tree to parse would be:

<mysymbols> // the node to give to this fnc (name is not important) <param name=wxT("x") greek=wxT("0") subscript=wxT("0") inlinedoutput="a"/> <unknown name=wxT("x") greek=wxT("0") subscript=wxT("") inlinedoutput=""/> <constant name=wxT("p") greek=wxT("1") subscript=wxT("") inlinedoutput=wxT("PI") value="3.14159"/> </mysymbols>

Returns:
TRUE if the given tree was successfully loaded; FALSE otherwise.

Definition at line 201 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, and mcSymbolArray::data_AddSymbol().

mcSymbolArray * mcSymbol::math_FindSymbol long  flags,
const mcSymbolProperties symtofind,
int  occurrence = 0,
int *  entry = NULL,
int  skipArr = -1
[static]
 

Definition at line 114 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, arrUnregistered, mcSYM_CONSTANT, mcSYM_PARAMETER, mcSYM_UNKNOWN, mcSYM_UNREGISTERED, and SEARCH_IN_ARRAY2.

mcSymbolArray * mcSymbol::math_FindSymbol long  flags,
const wxString &  name,
wxFontEncoding  enc = wxFONTENCODING_DEFAULT,
const mcRealValue value = 0.0,
const wxString &  subscript = wxEmptyString,
const wxString &  inlined = wxEmptyString,
int  occ = 0,
int *  entry = NULL,
int  skipArr = -1
[static]
 

Checks if a character is a symbol already registered.

If it is, the function returns the identifier code (SYM_***) of the symbol representing the given char and fill the pointer with the entry of that symbol in the respective array; if the given char is not registered in any array, it returns SYM_NOTSET; you can also use the last two arguments to specify one entry of one array to skip.

Parameters:
c The character to test
entry A pointer to the variable where the geivn character is registered
skipArr The array of registered symbols to skip: use one of SYM_* flags
skipEntry The entry to skip in the array to skip
Returns:
A pointer to the array where the symbol has been found

Definition at line 84 of file Symbol.cpp.

References arrConstants, arrParameters, arrUnknowns, arrUnregistered, mcSYM_CONSTANT, mcSYM_PARAMETER, mcSYM_UNKNOWN, mcSYM_UNREGISTERED, and SEARCH_IN_ARRAY.

Referenced by mcSymbolHelpers::data_SetSymbol(), mcSymbolHelpers::data_Update(), and mcSymbolHelpers::io_ImportBaseInlinedExpr().

mcSymbol::mcDEFINE_MAIN_CLASS Symbol  ,
mcExpElement 
[private]
 

mcSymbol mcSymbol::operator^ const mcPolynomial m  )  const [inline]
 

Reimplemented from mcElement.

Definition at line 459 of file Symbol.h.

References mcElement::math_RaiseTo().

mcSymbol& mcSymbol::operator^= const mcPolynomial m  )  [inline]
 

Reimplemented from mcElement.

Definition at line 461 of file Symbol.h.


Member Data Documentation

mcSymbolArray mcSymbol::arrConstants [static]
 

List of registered constants.

Referenced by CheckArray(), CheckSymbols(), CleanupSymbols(), InitSymbols(), LoadDefaultSymbols(), LoadSymbols(), and math_FindSymbol().

mcSymbolArray mcSymbol::arrParameters [static]
 

List of registered parameters.

Referenced by CheckArray(), CheckSymbols(), CleanupSymbols(), InitSymbols(), LoadDefaultSymbols(), LoadSymbols(), and math_FindSymbol().

mcSymbolArray mcSymbol::arrUnknowns [static]
 

List of registered unknowns.

Referenced by CheckArray(), CheckSymbols(), CleanupSymbols(), InitSymbols(), LoadDefaultSymbols(), LoadSymbols(), and math_FindSymbol().

mcSymbolArray mcSymbol::arrUnregistered [static]
 

List of unregistered symbols, currently present in the math data.

Referenced by CheckArray(), CheckSymbols(), CleanupSymbols(), InitSymbols(), and math_FindSymbol().


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

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

[ Top ]