Game Develop Core: gd::EventsCodeGenerationContext Class Reference

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- Class List
- Class Index
- Class Hierarchy

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Public Member Functions | Friends | List of all members
gd::EventsCodeGenerationContext Class Reference

Used to manage the context when generating code for events. More...

`#include <EventsCodeGenerationContext.h>`

## Public Member Functions

| EventsCodeGenerationContext (unsigned int *maxDepthLevel_=NULL)
void | InheritsFrom (const EventsCodeGenerationContext &parent)
size_t | GetContextDepth () const
| Returns the depth of the inheritance of the context. More...
const EventsCodeGenerationContext * | GetParentContext () const
| Get the parent context, if any. More...
void | SetCurrentObject (const std::string &objectName)
void | SetNoCurrentObject ()
const std::string & | GetCurrentObject () const
void | ObjectsListNeeded (const std::string &objectName)
| Call this when an instruction in the event need an object list. More...
void | EmptyObjectsListNeeded (const std::string &objectName)
bool | ObjectAlreadyDeclared (const std::string &objectName) const
void | SetObjectDeclared (const std::string &objectName)
| Consider that objectName is now declared in the context.
std::set< std::string > | GetAllObjectsToBeDeclared () const
const std::set< std::string > & | GetObjectsListsToBeDeclared () const
const std::set< std::string > & | GetObjectsListsToBeDeclaredEmpty () const
const std::set< std::string > & | GetObjectsListsAlreadyDeclared () const
unsigned int | GetLastDepthObjectListWasNeeded (const std::string &objectName) const
| Get the depth of the context that was in effect when objectName was needed. More...
void | EnterCustomCondition ()
| Called when a custom condition code is generated.
void | LeaveCustomCondition ()
| Called when a custom condition code generation is over.
size_t | GetCurrentConditionDepth () const
| Get the current condition depth : The depth is increased each time a custom condition code is generated, and decreased when the condition generation is done. More...

## Friends

class | EventsCodeGenerator

## Detailed Description

Used to manage the context when generating code for events.

The context refers to :

- The objects lists being available.
- The "current object", i.e the object being used by an action or a condition.
- If conditions are being generated, the context keeps track of the depth of the conditions ( see GetCurrentConditionDepth )
- You can also get the context depth of the last use of an object list.

## Constructor & Destructor Documentation

gd::EventsCodeGenerationContext::EventsCodeGenerationContext | ( | unsigned int * | maxDepthLevel_ = `NULL`) |  |

inline

Default constructor. You may want to call InheritsFrom just after.

Parameters

  maxDepthLevel | Optional pointer to an unsigned integer that will be updated to contain the maximal scope depth reached.

## Member Function Documentation

void gd::EventsCodeGenerationContext::EmptyObjectsListNeeded | ( | const std::string & | objectName) |  |

Call this when an instruction in the event need an object list. An empty event list will be declared, without filling it with objects from the scene. If there is already an object list with this name, no new list will be declared again.

std::set< std::string > gd::EventsCodeGenerationContext::GetAllObjectsToBeDeclared | ( | ) |  | const

Return all the objects lists which will be declared by the current context ( the non empty as well as the empty objects lists )

size_t gd::EventsCodeGenerationContext::GetContextDepth | ( | ) |  | const

inline

Returns the depth of the inheritance of the context.

A context created from scratch will returns 0, and a context inheriting from a context with depth n will returns n+1.

size_t gd::EventsCodeGenerationContext::GetCurrentConditionDepth | ( | ) |  | const

inline

Get the current condition depth : The depth is increased each time a custom condition code is generated, and decreased when the condition generation is done.

This can be useful to generate sub conditions booleans with a different name than the parent's conditions.

const std::string& gd::EventsCodeGenerationContext::GetCurrentObject | ( | ) |  | const

inline

Get the object being handled by the instruction

unsigned int gd::EventsCodeGenerationContext::GetLastDepthObjectListWasNeeded | ( | const std::string & | objectName) |  | const

Get the depth of the context that was in effect when objectName was needed.

If objectName is needed in this context, it will return the depth of this context.

const std::set<std::string>& gd::EventsCodeGenerationContext::GetObjectsListsAlreadyDeclared | ( | ) |  | const

inline

Return the objects lists which are already declared and can be used in the current context without declaration.

const std::set<std::string>& gd::EventsCodeGenerationContext::GetObjectsListsToBeDeclared | ( | ) |  | const

inline

Return the objects lists which will be declared by the current context

const std::set<std::string>& gd::EventsCodeGenerationContext::GetObjectsListsToBeDeclaredEmpty | ( | ) |  | const

inline

Return the objects lists which will be declared, but no filled, by the current context

const EventsCodeGenerationContext* gd::EventsCodeGenerationContext::GetParentContext | ( | ) |  | const

inline

Get the parent context, if any.

Returns
  A pointer to the parent context, or NULL if the context has no parent.

void gd::EventsCodeGenerationContext::InheritsFrom | ( | const EventsCodeGenerationContext & | parent) |  |

Call this method to make an EventsCodeGenerationContext as a "child" of another one. The child will then for example not declare again objects already declared by its parent.

bool gd::EventsCodeGenerationContext::ObjectAlreadyDeclared | ( | const std::string & | objectName) |  | const

inline

Return true if an object list has already been declared ( or is going to be declared ).

void gd::EventsCodeGenerationContext::ObjectsListNeeded | ( | const std::string & | objectName) |  |

Call this when an instruction in the event need an object list.

The list will be filled with objects from the scene if it is the first time it is requested, unless there is already an object list with this name ( i.e. ObjectAlreadyDeclared(objectName) returns true ).

void gd::EventsCodeGenerationContext::SetCurrentObject | ( | const std::string & | objectName) |  |

inline

Mark the object has being the object being handled by the instruction

void gd::EventsCodeGenerationContext::SetNoCurrentObject | ( | ) |  |

inline

Set that no particular object is being handled by an instruction

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

- EventsCodeGenerationContext.h
- EventsCodeGenerationContext.cpp