Torque2D Reference

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

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

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ConsoleObject Class Reference

`#include <consoleObject.h>`

Inheritance diagram for ConsoleObject:

## Public Member Functions
const AbstractClassRep::Field * | findField (StringTableEntry fieldName) const
| Get a reference to a field by name. More...
virtual AbstractClassRep * | getClassRep () const
| Gets the ClassRep. More...
bool | setField (const char *fieldName, const char *value)
| Set the value of a field. More...
virtual | ~ConsoleObject ()

## Static Public Member Functions
static const char * | lookupClassName (const U32 in_classTag)
| Get the classname from a class tag. More...
static void | initPersistFields ()
static void | consoleInit ()

## Protected Member Functions
| ConsoleObject ()
| ConsoleObject (const ConsoleObject &)

## Object Creation
static ConsoleObject * | create (const char *in_pClassName)
static ConsoleObject * | create (const U32 groupId, const U32 typeId, const U32 in_classId)

## Fields
static void | addGroup (const char *in_pGroupname, const char *in_pGroupDocs=NULL)
static void | endGroup (const char *in_pGroupname)
static void | addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void | addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::WriteDataNotify in_writeDataFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void | addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, const char *in_pFieldDocs)
static void | addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::WriteDataNotify in_writeDataFn, const char *in_pFieldDocs)
static void | addFieldV (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, ConsoleTypeValidator *v, const char *in_pFieldDocs=NULL)
static void | addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void | addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, AbstractClassRep::WriteDataNotify in_writeDataFn=&defaultProtectedWriteFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void | addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, const char *in_pFieldDocs=NULL)
static void | addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, AbstractClassRep::WriteDataNotify in_writeDataFn=&defaultProtectedWriteFn, const char *in_pFieldDocs=NULL)
static void | addDepricatedField (const char *fieldName)
static bool | removeField (const char *in_pFieldname)

## Field List
const AbstractClassRep::FieldList & | getFieldList () const
| Get a list of all the fields. This information cannot be modified. More...
AbstractClassRep::FieldList & | getModifiableFieldList ()
bool & | getDynamicGroupExpand ()

## ConsoleObject Implementation
These functions are implemented in every subclass of ConsoleObject by an IMPLEMENT_CONOBJECT or IMPLEMENT_CO_* macro.
S32 | getClassId (U32 netClassGroup) const
const char * | getClassName () const
static AbstractClassRep * | getStaticClassRep ()
| Get the abstract class information for this class. More...
static AbstractClassRep * | getParentStaticClassRep ()
| Get the abstract class information for this class's superclass. More...

## Detailed Description

Interface class to the console.

# The Basics

Any object which you want to work with the console system should derive from this, and access functionality through the static interface.

This class is always used with the DECLARE_CONOBJECT and IMPLEMENT_* macros.

// A very basic example object. It will do nothing!
class TorqueObject : public ConsoleObject {
// Must provide a Parent typedef so the console system knows what we inherit from.
typedef ConsoleObject Parent;
// This does a lot of menial declaration for you.
DECLARE_CONOBJECT(TorqueObject);
// This is for us to register our fields in.
static void initPersistFields();
// A sample field.
S8 mSample;
}
// And the accordant implementation...
IMPLEMENT_CONOBJECT(TorqueObject);
void TorqueObject::initPersistFields()
{
// If you want to inherit any fields from the parent (you do), do this:
Parent::initPersistFields();
// Pass the field, the type, the offset, and a usage string.
addField("sample", TypeS8, Offset(mSample, TorqueObject), "A test field.");
}

That's all you need to do to get a class registered with the console system. At this point, you can instantiate it via script, tie methods to it using ConsoleMethod, register fields, and so forth. You can also register any global variables related to the class by creating a consoleInit() method.

You will need to use different IMPLEMENT_ macros in different cases; for instance, if you are making a NetObject (for ghosting), a DataBlock, or a NetEvent.

See also
  AbstractClassRep for gory implementation details.

## Constructor & Destructor Documentation

ConsoleObject | ( |  | ) |
| inline protected

Deprecated:
  This is disallowed.

ConsoleObject | ( | const ConsoleObject & |  | ) |
| protected

Deprecated:
  This is disallowed.

~ConsoleObject | ( |  | ) |
| virtual

## Member Function Documentation

void addDepricatedField | ( | const char * | fieldName | ) |
| static protected

Add a deprecated field.

A deprecated field will always be undefined, even if you assign a value to it. This is useful when you need to make sure that a field is not being used anymore.

void addField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | const U32 | in_elementCount = `1`,
|  | EnumTable * | in_table = `NULL`,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a complex field.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_elementCount | Number of elements in this field. Arrays of elements are assumed to be contiguous in memory.
  in_table | An EnumTable, if this is an enumerated field.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | AbstractClassRep::WriteDataNotify | in_writeDataFn,
|  | const U32 | in_elementCount = `1`,
|  | EnumTable * | in_table = `NULL`,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a complex field with a write notify.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_writeDataFn | This method will return whether the field should be written or not.
  in_elementCount | Number of elements in this field. Arrays of elements are assumed to be contiguous in memory.
  in_table | An EnumTable, if this is an enumerated field.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | const char * | in_pFieldDocs
| ) |  |
| static protected

Register a simple field.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | AbstractClassRep::WriteDataNotify | in_writeDataFn,
|  | const char * | in_pFieldDocs
| ) |  |
| static protected

Register a simple field with a write notify.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_writeDataFn | This method will return whether the field should be written or not.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addFieldV | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | ConsoleTypeValidator * | v,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a validated field.

A validated field is just like a normal field except that you can't have it be an array, and that you give it a pointer to a ConsoleTypeValidator subclass, which is then used to validate any value placed in it. Invalid values are ignored and an error is printed to the console.

See also
  addField
  typeValidators.h

void addGroup | ( | const char * | in_pGroupname,
|  | const char * | in_pGroupDocs = `NULL`
| ) |  |
| static protected

Mark the beginning of a group of fields.

This is used in the consoleDoc system.

See also
  console_autodoc

void addProtectedField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | AbstractClassRep::SetDataNotify | in_setDataFn,
|  | AbstractClassRep::GetDataNotify | in_getDataFn = `&defaultProtectedGetFn`,
|  | const U32 | in_elementCount = `1`,
|  | EnumTable * | in_table = `NULL`,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a complex protected field.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_setDataFn | When this field gets set, it will call the callback provided.

See also
  console_protected

Parameters

  in_getDataFn | When this field is accessed for it's data, it will return the value of this function
  in_elementCount | Number of elements in this field. Arrays of elements are assumed to be contiguous in memory.
  in_table | An EnumTable, if this is an enumerated field.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addProtectedField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | AbstractClassRep::SetDataNotify | in_setDataFn,
|  | AbstractClassRep::GetDataNotify | in_getDataFn = `&defaultProtectedGetFn`,
|  | AbstractClassRep::WriteDataNotify | in_writeDataFn = `&defaultProtectedWriteFn`,
|  | const U32 | in_elementCount = `1`,
|  | EnumTable * | in_table = `NULL`,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a complex protected field.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_setDataFn | When this field gets set, it will call the callback provided.

See also
  console_protected

Parameters

  in_getDataFn | When this field is accessed for it's data, it will return the value of this function
  in_writeDataFn | This method will return whether the field should be written or not.
  in_elementCount | Number of elements in this field. Arrays of elements are assumed to be contiguous in memory.
  in_table | An EnumTable, if this is an enumerated field.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addProtectedField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | AbstractClassRep::SetDataNotify | in_setDataFn,
|  | AbstractClassRep::GetDataNotify | in_getDataFn = `&defaultProtectedGetFn`,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a simple protected field.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_setDataFn | When this field gets set, it will call the callback provided.

See also
  console_protected

Parameters

  in_getDataFn | When this field is accessed for it's data, it will return the value of this function
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void addProtectedField | ( | const char * | in_pFieldname,
|  | const U32 | in_fieldType,
|  | const dsize_t | in_fieldOffset,
|  | AbstractClassRep::SetDataNotify | in_setDataFn,
|  | AbstractClassRep::GetDataNotify | in_getDataFn = `&defaultProtectedGetFn`,
|  | AbstractClassRep::WriteDataNotify | in_writeDataFn = `&defaultProtectedWriteFn`,
|  | const char * | in_pFieldDocs = `NULL`
| ) |  |
| static protected

Register a simple protected field.

Parameters

  in_pFieldname | Name of the field.
  in_fieldType | Type of the field.

See also
  ConsoleDynamicTypes

Parameters

  in_fieldOffset | Offset to the field from the start of the class; calculated using the Offset() macro.
  in_setDataFn | When this field gets set, it will call the callback provided.

See also
  console_protected

Parameters

  in_getDataFn | When this field is accessed for it's data, it will return the value of this function
  in_writeDataFn | This method will return whether the field should be written or not.
  in_pFieldDocs | Usage string for this field.

See also
  console_autodoc

void consoleInit | ( |  | ) |
| static

Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.

Deprecated:
  You should use ConsoleMethod and ConsoleFunction, not this, to register methods or commands.
  See also
    console

ConsoleObject * create | ( | const char * | in_pClassName | ) |
| inline static

ConsoleObject * create | ( | const U32 | groupId,
|  | const U32 | typeId,
|  | const U32 | in_classId
| ) |  |
| inline static

void endGroup | ( | const char * | in_pGroupname | ) |
| static protected

Mark the end of a group of fields.

This is used in the consoleDoc system.

See also
  console_autodoc

const AbstractClassRep::Field * findField | ( | StringTableEntry | fieldName | ) | const
| inline

Get a reference to a field by name.

S32 getClassId | ( | U32 | netClassGroup | ) | const
| inline

Get our network-layer class id.

Parameters

  netClassGroup | The net class for which we want our ID.

See also

const char * getClassName | ( |  | ) | const
| inline

Get our compiler and platform independent class name.

Note
  This name can be used to instantiate another instance using create()

AbstractClassRep * getClassRep | ( |  | ) | const
| virtual

Gets the ClassRep.

bool & getDynamicGroupExpand | ( |  | ) |
| inline

Get a handle to a boolean telling us if we expanded the dynamic group.

See also
  GuiInspector::Inspect()

const AbstractClassRep::FieldList & getFieldList | ( |  | ) | const
| inline

Get a list of all the fields. This information cannot be modified.

AbstractClassRep::FieldList & getModifiableFieldList | ( |  | ) |
| inline

Get a list of all the fields, set up so we can modify them.

Note
  This is a bad trick to pull if you aren't very careful, since you can blast field data!

static AbstractClassRep* getParentStaticClassRep | ( |  | ) |
| inline static

Get the abstract class information for this class's superclass.

static AbstractClassRep* getStaticClassRep | ( |  | ) |
| inline static

Get the abstract class information for this class.

void initPersistFields | ( |  | ) |
| static

Register dynamic fields in a subclass of ConsoleObject.

See also
  addField(), addFieldV(), addDepricatedField(), addGroup(), endGroup()

static const char* lookupClassName | ( | const U32 | in_classTag | ) |
| static

Get the classname from a class tag.

bool removeField | ( | const char * | in_pFieldname | ) |
| static protected

Remove a field.

Sometimes, you just have to remove a field!

Returns
  True on success.

bool setField | ( | const char * | fieldName,
|  | const char * | value
| ) |  |
| inline

Set the value of a field.

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

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