#pragma once
#include "Common.h"
/*
* Class CFunction - Type for a single function (builtin or defined)
*/
class CFunction
{
private:
// Name of a function
string m_Name;
// Is this a builtin function?
bool m_Builtin;
// For defined functions, store the expression to be
// evaluated at runtime
string m_Expression;
// For builtins, provide a coderef
float (*m_Coderef)(float Value);
// Symbol used for parameter
CSymbol *m_Symbol;
public:
CFunction(void);
CFunction(string Name, float (*coderef)(float));
CFunction(string Name, string Expression);
~CFunction(void);
// Set the name of a function
void SetName(string Name);
// Get the name of the current function
string GetName(void);
// Set the builtin flag to either true or false
void SetBuiltin(bool Value);
// Returns true if the function is a builtin
bool GetBuiltin(void);
// Set the expression to run when the function is called
void SetExpression(string Expression);
// Get the runtime expression of the function
string GetExpression(void);
// Set the coderef for a builtin function
void SetCoderef(float (*coderef)(float));
// Execute the builtin function by coderef
float ExecuteBuiltin(float Value);
// Set the symbol used as a parameter
void SetSymbol(CSymbol * Symbol);
// Get the symbol used for the function parameter
CSymbol * GetSymbol(void);
};