Torque2D Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Attributes | List of all members
ConsoleConstructor Class Reference

`#include <console.h>`

## Public Attributes
S32 | mina
| Minimum/maximum number of arguments for the function. More...
S32 | maxa
const char * | usage
| Usage string. More...
const char * | funcName
| Function name. More...
const char * | className
| Class name. More...

## Entry Type Fields
One of these is set based on the type of entry we want inserted in the console. Console Auto-Documentation
StringCallback | sc
| A function/method that returns a string. More...
IntCallback | ic
| A function/method that returns an int. More...
FloatCallback | fc
| A function/method that returns a float. More...
VoidCallback | vc
| A function/method that returns nothing. More...
BoolCallback | bc
| A function/method that returns a bool. More...
bool | group
| Indicates that this is a group marker. More...
bool | overload
| Indicates that this is an overload marker. More...
bool | ns

## ConsoleConstructer Innards
The ConsoleConstructor class is used as the backend for the ConsoleFunction() and ConsoleMethod() macros. The way it works takes advantage of several properties of C++. The ConsoleFunction()/ConsoleMethod() macros wrap the declaration of a ConsoleConstructor. // The definition of a ConsoleFunction using the macro ConsoleFunction(ExpandPath, const char*, 2, 2, "(string filePath)") { argc; char* ret = Con::getReturnBuffer( 1024 ); Con::expandPath(ret, 1024, argv[1]); return ret; } // Resulting code static const char* cExpandPath(SimObject *, S32, const char **argv); static ConsoleConstructor gExpandPathobj(NULL,"ExpandPath", cExpandPath, "(string filePath)", 2, 2); static const char* cExpandPath(SimObject *, S32 argc, const char **argv) { argc; char* ret = Con::getReturnBuffer( 1024 ); Con::expandPath(ret, 1024, argv[1]); return ret; } // A similar thing happens when you do a ConsoleMethod. As you can see, several global items are defined when you use the ConsoleFunction method. The macro constructs the name of these items from the parameters you passed it. Your implementation of the console function is is placed in a function with a name based on the actual name of the console funnction. In addition, a ConsoleConstructor is declared. Because it is defined as a global, the constructor for the ConsoleConstructor is called before execution of main() is started. The constructor is called once for each global ConsoleConstructor variable, in the order in which they were defined (this property only holds true within file scope). We have ConsoleConstructor create a linked list at constructor time, by storing a static pointer to the head of the list, and keeping a pointer to the next item in each instance of ConsoleConstructor. init() is a helper function in this process, automatically filling in commonly used fields and updating first and next as needed. In this way, a list of items to add to the console is assemble in memory, ready for use, before we start execution of the program proper. In Con::init(), ConsoleConstructor::setup() is called to process this prepared list. Each item in the list is iterated over, and the appropriate Con namespace functions (usually Con::addCommand) are invoked to register the ConsoleFunctions and ConsoleMethods in the appropriate namespaces. See also Namespace Con
ConsoleConstructor * | next
static ConsoleConstructor * | first = NULL
void | init (const char *cName, const char *fName, const char *usg, S32 minArgs, S32 maxArgs)
static void | setup ()

## Basic Console Constructors
| ConsoleConstructor (const char *className, const char *funcName, StringCallback sfunc, const char *usage, S32 minArgs, S32 maxArgs)
| ConsoleConstructor (const char *className, const char *funcName, IntCallback ifunc, const char *usage, S32 minArgs, S32 maxArgs)
| ConsoleConstructor (const char *className, const char *funcName, FloatCallback ffunc, const char *usage, S32 minArgs, S32 maxArgs)
| ConsoleConstructor (const char *className, const char *funcName, VoidCallback vfunc, const char *usage, S32 minArgs, S32 maxArgs)
| ConsoleConstructor (const char *className, const char *funcName, BoolCallback bfunc, const char *usage, S32 minArgs, S32 maxArgs)

## Magic Console Constructors
These perform various pieces of "magic" related to consoleDoc functionality. Console Auto-Documentation
| ConsoleConstructor (const char *className, const char *groupName, const char *usage)
| ConsoleConstructor (const char *className, const char *usage)
| Indicates a namespace usage string. More...

## Detailed Description

This is the backend for the ConsoleMethod()/ConsoleFunction() macros.

See the group ConsoleConstructor Innards for specifics on how this works.

See also
  Console Auto-Documentation

## Constructor & Destructor Documentation

ConsoleConstructor | ( | const char * | className,
|  | const char * | funcName,
|  | StringCallback | sfunc,
|  | const char * | usage,
|  | S32 | minArgs,
|  | S32 | maxArgs
| ) |  |

ConsoleConstructor | ( | const char * | className,
|  | const char * | funcName,
|  | IntCallback | ifunc,
|  | const char * | usage,
|  | S32 | minArgs,
|  | S32 | maxArgs
| ) |  |

ConsoleConstructor | ( | const char * | className,
|  | const char * | funcName,
|  | FloatCallback | ffunc,
|  | const char * | usage,
|  | S32 | minArgs,
|  | S32 | maxArgs
| ) |  |

ConsoleConstructor | ( | const char * | className,
|  | const char * | funcName,
|  | VoidCallback | vfunc,
|  | const char * | usage,
|  | S32 | minArgs,
|  | S32 | maxArgs
| ) |  |

ConsoleConstructor | ( | const char * | className,
|  | const char * | funcName,
|  | BoolCallback | bfunc,
|  | const char * | usage,
|  | S32 | minArgs,
|  | S32 | maxArgs
| ) |  |

ConsoleConstructor | ( | const char * | className,
|  | const char * | groupName,
|  | const char * | usage
| ) |  |

Indicates a group marker. (A doxygen illusion)

See also
  Con::markCommandGroup Console Auto-Documentation

ConsoleConstructor | ( | const char * | className,
|  | const char * | usage
| ) |  |

Indicates a namespace usage string.

## Member Function Documentation

void init | ( | const char * | cName,
|  | const char * | fName,
|  | const char * | usg,
|  | S32 | minArgs,
|  | S32 | maxArgs
| ) |  |

void setup | ( |  | ) |
| static

## Member Data Documentation

BoolCallback bc

A function/method that returns a bool.

const char* className

Class name.

FloatCallback fc

A function/method that returns a float.

ConsoleConstructor * first = NULL
| static

const char* funcName

Function name.

bool group

Indicates that this is a group marker.

IntCallback ic

A function/method that returns an int.

S32 maxa

S32 mina

Minimum/maximum number of arguments for the function.

ConsoleConstructor* next

bool ns

Indicates that this is a namespace marker.

Deprecated:
  Unused.

bool overload

Indicates that this is an overload marker.

StringCallback sc

A function/method that returns a string.

const char* usage

Usage string.

VoidCallback vc

A function/method that returns nothing.

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

- console/console.h
- console/console.cc