# NEDCppGenerator Class Reference
[Generating C++ code]

`#include <cppgenerator.h>`

List of all members.

## Detailed Description

NEDC functionality: generates C++ code from a NED object tree.

Assumes object tree has already passed all validation stages (DTD, basic, semantic).

Uses CppExpressionGenerator.

## Public Member Functions

| NEDCppGenerator (ostream &out, ostream &outh, NEDSymbolTable *symtab)
| ~NEDCppGenerator ()
void | setIndentSize (int indentsize)
void | generate (NEDElement *node)

## Protected Types

enum | { MODE_NORMAL, MODE_FINALLY }

## Protected Member Functions

const char * | increaseIndent (const char *indent)
const char * | decreaseIndent (const char *indent)
void | generateItem (NEDElement *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | generateChildren (NEDElement *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | generateChildrenWithTags (NEDElement *node, const char *tags, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | generateChildrenExceptTags (NEDElement *node, const char *tags, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
ExpressionNode * | findExpression (NEDElement *parent, const char *target)
ConstNode * | getConstantExpression (ExpressionNode *node)
void | writeProlog (ostream &out)
void | printTemporaryVariables (const char *indent)
void | beginConditionalBlock (NEDElement *node, const char *&indent, int mode, const char *)
void | endConditionalBlock (NEDElement *node, const char *&indent, int mode, const char *)
void | doNedFile (NedFileNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doNedFiles (NedFilesNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doImports (ImportNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doImport (ImportedFileNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doChannel (ChannelNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doChannelAttr (ChannelAttrNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doNetwork (NetworkNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSimple (SimpleModuleNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doModule (CompoundModuleNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doParams (ParamsNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doParam (ParamNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doGates (GatesNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doGate (GateNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doMachines (MachinesNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doMachine (MachineNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSubmodules (SubmodulesNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | resolveSubmoduleType (SubmoduleNode *node, const char *indent)
void | doSubmodule (SubmoduleNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSubmoduleFinally (SubmoduleNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSubstparams (SubstparamsNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSubstparam (SubstparamNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doGatesizes (GatesizesNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doGatesize (GatesizeNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSubstmachines (SubstmachinesNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doSubstmachine (SubstmachineNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doConnections (ConnectionsNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | resolveGate (const char *modname, ExpressionNode *modindex, const char *gatename, ExpressionNode *gateindex, bool isplusplus)
void | resolveConnectionAttributes (ConnectionNode *node, const char *indent, int mode)
void | doConnection (ConnectionNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doConnattr (ConnAttrNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doForloop (ForLoopNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doLoopvar (LoopVarNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doDisplayString (DisplayStringNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doExpression (ExpressionNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doCplusplus (CplusplusNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doStructDecl (StructDeclNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doClassDecl (ClassDeclNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doMessageDecl (MessageDeclNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doEnumDecl (EnumDeclNode *node, const char *indent, int mode=MODE_NORMAL, const char *arg=NULL)
void | doEnum (EnumNode *node, const char *indent, int mode, const char *)
void | doEnumFields (EnumFieldsNode *node, const char *indent, int mode, const char *)
void | doEnumField (EnumFieldNode *node, const char *indent, int mode, const char *)
void | doMessage (MessageNode *node, const char *, int, const char *)
void | doClass (ClassNode *node, const char *, int, const char *)
void | doStruct (StructNode *node, const char *, int, const char *)
void | prepareForCodeGeneration (NEDElement *node, ClassDesc &cld, FieldDesc *&fld, int &numfields)
void | generateClass (ClassDesc &cld, FieldDesc *&fld, int numfields)
void | generateStruct (ClassDesc &cld, FieldDesc *&fld, int numfields)
void | generateDescriptorClass (ClassDesc &cld, FieldDesc *&fld, int numfields)

## Protected Attributes

ostream & | out
ostream & | outh
bool | in_network
std::string | submodule_var
int | indentsize
CppExpressionGenerator | exprgen
NEDSymbolTable * | symboltable

## Member Enumeration Documentation

anonymous enum`[protected]`

Enumerator:

  MODE_NORMAL |
  MODE_FINALLY |

## Constructor & Destructor Documentation

NEDCppGenerator::NEDCppGenerator | ( | ostream & | out,
|  | ostream & | outh,
|  | NEDSymbolTable * | symtab
| ) |

| Constructor. It expects two streams on which it will write the generated code (stream for the C++ source code and stream for the C++ header), and the symbol table.

NEDCppGenerator::~NEDCppGenerator | ( |  | ) |

| Destructor.

## Member Function Documentation

void NEDCppGenerator::beginConditionalBlock | ( | NEDElement * | node,
|  | const char *& | indent,
|  | int | mode,
|  | const char * |
| ) | `[protected]`

const char* NEDCppGenerator::decreaseIndent | ( | const char * | indent | ) | `[protected]`

void NEDCppGenerator::doChannel | ( | ChannelNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doChannelAttr | ( | ChannelAttrNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doClass | ( | ClassNode * | node,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) | `[protected]`

void NEDCppGenerator::doClassDecl | ( | ClassDeclNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doConnattr | ( | ConnAttrNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doConnection | ( | ConnectionNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doConnections | ( | ConnectionsNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doCplusplus | ( | CplusplusNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doDisplayString | ( | DisplayStringNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doEnum | ( | EnumNode * | node,
|  | const char * | indent,
|  | int | mode,
|  | const char * |
| ) | `[protected]`

void NEDCppGenerator::doEnumDecl | ( | EnumDeclNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doEnumField | ( | EnumFieldNode * | node,
|  | const char * | indent,
|  | int | mode,
|  | const char * |
| ) | `[protected]`

void NEDCppGenerator::doEnumFields | ( | EnumFieldsNode * | node,
|  | const char * | indent,
|  | int | mode,
|  | const char * |
| ) | `[protected]`

void NEDCppGenerator::doExpression | ( | ExpressionNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doForloop | ( | ForLoopNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doGate | ( | GateNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doGates | ( | GatesNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doGatesize | ( | GatesizeNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doGatesizes | ( | GatesizesNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doImport | ( | ImportedFileNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doImports | ( | ImportNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doLoopvar | ( | LoopVarNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doMachine | ( | MachineNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doMachines | ( | MachinesNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doMessage | ( | MessageNode * | node,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) | `[protected]`

void NEDCppGenerator::doMessageDecl | ( | MessageDeclNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doModule | ( | CompoundModuleNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doNedFile | ( | NedFileNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doNedFiles | ( | NedFilesNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doNetwork | ( | NetworkNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doParam | ( | ParamNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doParams | ( | ParamsNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSimple | ( | SimpleModuleNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doStruct | ( | StructNode * | node,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) | `[protected]`

void NEDCppGenerator::doStructDecl | ( | StructDeclNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubmodule | ( | SubmoduleNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubmoduleFinally | ( | SubmoduleNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubmodules | ( | SubmodulesNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubstmachine | ( | SubstmachineNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubstmachines | ( | SubstmachinesNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubstparam | ( | SubstparamNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::doSubstparams | ( | SubstparamsNode * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::endConditionalBlock | ( | NEDElement * | node,
|  | const char *& | indent,
|  | int | mode,
|  | const char * |
| ) | `[protected]`

ExpressionNode* NEDCppGenerator::findExpression | ( | NEDElement * | parent,
|  | const char * | target
| ) | `[protected]`

void NEDCppGenerator::generate | ( | NEDElement * | node | ) |

| Generate C++ source code. Code will be written to the streams given to the constructor.

void NEDCppGenerator::generateChildren | ( | NEDElement * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::generateChildrenExceptTags | ( | NEDElement * | node,
|  | const char * | tags,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::generateChildrenWithTags | ( | NEDElement * | node,
|  | const char * | tags,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::generateClass | ( | ClassDesc & | cld,
|  | FieldDesc *& | fld,
|  | int | numfields
| ) | `[protected]`

void NEDCppGenerator::generateDescriptorClass | ( | ClassDesc & | cld,
|  | FieldDesc *& | fld,
|  | int | numfields
| ) | `[protected]`

void NEDCppGenerator::generateItem | ( | NEDElement * | node,
|  | const char * | indent,
|  | int | mode = `MODE_NORMAL`,
|  | const char * | arg = `NULL`
| ) | `[protected]`

void NEDCppGenerator::generateStruct | ( | ClassDesc & | cld,
|  | FieldDesc *& | fld,
|  | int | numfields
| ) | `[protected]`

ConstNode* NEDCppGenerator::getConstantExpression | ( | ExpressionNode * | node | ) | `[protected]`

const char* NEDCppGenerator::increaseIndent | ( | const char * | indent | ) | `[protected]`

void NEDCppGenerator::prepareForCodeGeneration | ( | NEDElement * | node,
|  | ClassDesc & | cld,
|  | FieldDesc *& | fld,
|  | int & | numfields
| ) | `[protected]`

void NEDCppGenerator::printTemporaryVariables | ( | const char * | indent | ) | `[protected]`

void NEDCppGenerator::resolveConnectionAttributes | ( | ConnectionNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void NEDCppGenerator::resolveGate | ( | const char * | modname,
|  | ExpressionNode * | modindex,
|  | const char * | gatename,
|  | ExpressionNode * | gateindex,
|  | bool | isplusplus
| ) | `[protected]`

void NEDCppGenerator::resolveSubmoduleType | ( | SubmoduleNode * | node,
|  | const char * | indent
| ) | `[protected]`

void NEDCppGenerator::setIndentSize | ( | int | indentsize | ) |

| Set indentation in generated C++ source. Default is 4 spaces.

void NEDCppGenerator::writeProlog | ( | ostream & | out | ) | `[protected]`

## Member Data Documentation

CppExpressionGenerator NEDCppGenerator::exprgen`[protected]`

bool NEDCppGenerator::in_network`[protected]`

int NEDCppGenerator::indentsize`[protected]`

ostream& NEDCppGenerator::out`[protected]`

ostream& NEDCppGenerator::outh`[protected]`

std::string NEDCppGenerator::submodule_var`[protected]`

NEDSymbolTable* NEDCppGenerator::symboltable`[protected]`

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

- cppgenerator.h