openETCS
case study for the European Train Control System developed for the authors dissertation
|
generator for C++ sources More...
#include <CPPGenerator.h>
Public Member Functions | |
CCPPGenerator () throw () | |
default oonstructor | |
virtual void | Generate (::DSM::CSyntaxTree *const pSyntaxTree,::std::ostream &OutStream) throw (::oETCS::GEN::Error::CException) |
generation method | |
virtual | ~CCPPGenerator () throw () |
destructor |
Private Member Functions | |
void | BuildAbstractModel (GOPPRR::CGraph *const pFunctionBlock,::std::map< ::std::string, oETCS::GEN::CFBNode > &FBNodes) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateCommunication (GOPPRR::CGraph *const pCommunication, GOPPRR::CProject *const pProject,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateControlFlows (GOPPRR::CProject *const pProject,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateDataFlow (GOPPRR::CGraph *const pMainFunctionBlock, GOPPRR::CGraph *const pEVCGraph, GOPPRR::CObject *const pEVCState,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateDataFlow (const ::std::string &OID, GOPPRR::CGraph *const pSubFunctionBlock,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateDataFlowForCommunication (const ::std::string &OID, GOPPRR::CGraph *const pCommGraph,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateDMI (GOPPRR::CGraph *const pMainFunctionBlock, GOPPRR::CGraph *const pEVCGraph, GOPPRR::CObject *const pEVCState,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateDMI (const ::std::string &OID, GOPPRR::CGraph *const pSubFunctionBlock,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateEVCTransitions (GOPPRR::CGraph *const pMainFunctionBlock, GOPPRR::CObject *const pEVCState, GOPPRR::CGraph *const pRootGraph,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateFunctionBlock (GOPPRR::CGraph *const pFunctionBlock, GOPPRR::CProject *const pProject,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateFunctionBlockElements (GOPPRR::CProject *const pProject,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateLanguage (GOPPRR::CProject *const pProject,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateRootGraph (GOPPRR::CGraph *const pRootGraph, GOPPRR::CProject *const pProject,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateTransitions (GOPPRR::CGraph *const pRootGraph,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateTransitions (GOPPRR::CGraph *const pFunctionBlock, GOPPRR::CObject *const pEVCState,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
void | GenerateTransitions (GOPPRR::CGraph *const pFunctionBlock, GOPPRR::CGraph *const pControlFlow, GOPPRR::CObject *const pEVCState, GOPPRR::CObject *const pState,::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method |
Static Private Member Functions | |
static void | GenerateFooter (::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
static void | GenerateHeader (::std::ostream &OutStream) throw (::GOPPRR::Error::CException) |
internal helper method | |
static bool | IsFunctionBlock (GOPPRR::CObject *const pObject) throw (::GOPPRR::Error::CException) |
internal helper methods | |
::std::string | PrefixFromPort (GOPPRR::CPort *const pPort) throw (::GOPPRR::Error::CException) |
internal helper method | |
static void | ProcessAbstractModel (const oETCS::GEN::CFBNode &Node,::std::list< ::std::string > &ExecutionOrder,::std::vector< const oETCS::GEN::CFBNode * > &NodeStack) throw () |
internal helper method | |
::std::string | TypeFromPort (GOPPRR::CPort *const pPort) throw (::GOPPRR::Error::CException) |
internal helper method |
Private Attributes | |
::std::map< ::std::string,::std::string > | m_FBMap |
map with function block meta model type names to C++ domain framework names | |
::std::map< ::std::string,::std::string > | m_FBMMap |
map with function block meta model method/port names to C++ domain framework method names | |
::std::map< ::std::string, bool > | m_GeneratedControlFlows |
map of already generated control flow OIDs | |
::std::map< ::std::string, bool > | m_GeneratedEVCTransitions |
map of already generated EVC transition OIDs | |
::std::map< ::std::string, bool > | m_GeneratedTransitions |
map of already generated transition OIDs |
generator for C++ sources
Definition at line 58 of file CPPGenerator.h.
|
explicit |
default oonstructor
Definition at line 39 of file CPPGenerator.cpp.
|
virtual |
destructor
Definition at line 153 of file CPPGenerator.cpp.
|
private |
internal helper method
Builds the abstract function block model for a function block graph recursively.
[in,out] | pFunctionBlock,: | pointer to current function block graph |
[in] | FBNodes | map of nodes objects indexed by their OID |
Definition at line 2793 of file CPPGenerator.cpp.
References oETCS::GEN::CFBNode::DEFINED, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CGraph::m_RoleSet, and oETCS::GEN::CFBNode::UNDEFINED.
Referenced by GenerateControlFlows(), and GenerateDataFlow().
|
virtual |
generation method
Generates from a syntax tree the corresponding output.
[in] | pTree | pointer to the syntax tree used for generation |
[in] | OutStream | stream object used for output of generation |
Implements oETCS::GEN::CGenerator.
Definition at line 164 of file CPPGenerator.cpp.
References __GENERATOR__EVCSTATEMACHINE__, DSM::CGOPPRRSyntaxTree::GetProject(), and GOPPRR::CProject::m_GraphSet.
Referenced by oETCS::GEN::CMain::Execute(), and oETCS::UT::CGenerator::TestGenerateCpp().
|
private |
internal helper method
Generates source code of any type of communication graph from a GOPPRR syntax tree.
[in] | pCommnication | pointer to the function block graph |
[in] | pProject | pointer to the parent project of the openETCS model |
[in] | OutStream | stream object used for output of generation |
Definition at line 1125 of file CPPGenerator.cpp.
References GOPPRR::CNonProperty::m_ID, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CGraph::m_PortSet, GOPPRR::CGraph::m_RelationshipSet, and GOPPRR::CGraph::m_RoleSet.
|
private |
internal helper method
Generates source code for creating all states of all control flows.
[in] | pProject | pointer to the openETCS project object |
[in] | OutStream | stream object used for output of generation |
Definition at line 1766 of file CPPGenerator.cpp.
References BuildAbstractModel(), oETCS::GEN::CFBNode::m_Inputs, GOPPRR::CProject::m_ObjectSet, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CGraph::m_RelationshipSet, GOPPRR::CGraph::m_RoleSet, GOPPRR::CConcept::m_Type, GOPPRR::CGraph::Objects(), ProcessAbstractModel(), GOPPRR::CGraph::Roles(), and oETCS::GEN::CFBNode::UNDEFINED.
|
private |
internal helper method
Generates source code for data flow objects (CDataFlow) for a MainFunctionBlock graph
[in] | pMainFunctionBlock | pointer to the main function block |
[in] | pEVCGraph | pointer to EVC root graph |
[in] | pEVCState | pointer to the related EVCState object |
[in] | OutStream | stream object used for output of generation |
Definition at line 1249 of file CPPGenerator.cpp.
References BuildAbstractModel(), oETCS::GEN::CFBNode::m_Inputs, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CGraph::m_RelationshipSet, GOPPRR::CGraph::m_RoleSet, ProcessAbstractModel(), and GOPPRR::CNonProperty::Properties().
|
private |
internal helper method
Generates source code for adding objects in a sub function block to a certain data flow objectt
[in] | OID | OID of the related main function block graph |
[in] | pSubFunctionBlock | pointer to current sub function block graph |
[in] | OutStream | stream object used for output of generation |
Definition at line 1450 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet, and GOPPRR::CGraph::m_RelationshipSet.
|
private |
internal helper method
Generates source code adding the related CBitFlow objects for a communication graph
[in] | OID | OID of the related main function block graph |
[in] | pCommGraph | pointer to current communication graph |
[in] | OutStream | stream object used for output of generation |
Definition at line 1514 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CGraph::m_RelationshipSet, and GOPPRR::CConcept::m_Type.
|
private |
internal helper method
Generates source code for DMI widgets (CDMIWidget) for a MainFunctionBlock graph
[in] | pMainFunctionBlock | pointer to the main function block |
[in] | pEVCGraph | pointer to EVC root graph |
[in] | pEVCState | pointer to the related EVCState object |
[in] | OutStream | stream object used for output of generation |
Definition at line 1555 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet.
|
private |
internal helper method
Generates source code for DMI widgets (CDMIWidget) for a SubFunctionBlock graph
[in] | OID | OID of the related main function block |
[in] | pSubFunctionBlock | pointer to the subfunction block |
[in] | OutStream | stream object used for output of generation |
Definition at line 1628 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet.
|
private |
internal helper method
Generates source code for EVC transitions in a certain main function block.
[in] | pMainFunctionBlock | pointer to the main function block graph |
[in] | pEVCState | pointer to related EVC state object |
[in] | pRootGraph | pointer to the root graph (EVCStateMachine) |
[in] | OutStream | stream object used for output of generation |
Definition at line 1685 of file CPPGenerator.cpp.
References GOPPRR::CNonProperty::m_ID, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CGraph::m_RelationshipSet, GOPPRR::CGraph::m_RoleSet, and GOPPRR::CNonProperty::Properties().
|
staticprivate |
internal helper method
Generates source code footer.
[in] | OutStream | stream object used for output of generation |
Definition at line 2892 of file CPPGenerator.cpp.
|
private |
internal helper method
Generates source code of any sub type of function block graph from a GOPPRR syntax tree.
[in] | pFunctionBlock | pointer to the function block graph |
[in] | pProject | pointer to the parent project of the openETCS model |
[in] | OutStream | stream object used for output of generation |
Definition at line 863 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet, GOPPRR::CGraph::m_PortSet, GOPPRR::CGraph::m_RelationshipSet, GOPPRR::CGraph::m_RoleSet, and PrefixFromPort().
|
private |
internal helper method
Generates source code for creating all function block classes in a project.
[in] | pProject | pointer to the parent project of the openETCS model |
[in] | OutStream | stream object used for output of generation |
Definition at line 489 of file CPPGenerator.cpp.
References __GENERATOR__EVCSTATE__, __GENERATOR__MAINFB__, __GENERATOR__SUBFB__, __GENERATOR__TELEGRAMGRAPH__, GOPPRR::CObject::m_Explosions, GOPPRR::CProject::m_GraphSet, GOPPRR::CProperty::m_NonProperties, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CGraph::m_PortSet, and GOPPRR::CNonProperty::Properties().
|
staticprivate |
internal helper method
Generates source code header, like initial comment block and includes. Is independent from model tree reprensentation
[in] | OutStream | stream object used for output of generation |
Definition at line 2852 of file CPPGenerator.cpp.
Referenced by GenerateRootGraph().
|
private |
internal helper method
Generates source code of for the language classes
[in] | pProject | pointer to the project of the openETCS model |
[in] | OutStream | stream object used for output of generation |
Definition at line 2184 of file CPPGenerator.cpp.
References __GENERATOR__EVCSTATE__, __GENERATOR__MAINFB__, __GENERATOR__SUBFB__, __GENERATOR__TELEGRAMGRAPH__, GOPPRR::CObject::m_Explosions, GOPPRR::CProperty::m_NonProperties, GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CObject::m_pDecomposition, GOPPRR::CGraph::m_PortSet, GOPPRR::CNonProperty::m_Properties, GOPPRR::CGraph::m_RoleSet, GOPPRR::CConcept::m_Type, GOPPRR::CGraph::Objects(), GOPPRR::CNonProperty::Properties(), and GOPPRR::CGraph::Roles().
|
private |
internal helper method
Generates source code of a root graph (EVC state machine) from a GOPPRR syntax tree.
[in] | pRootGraph | pointer to the root graph of the openETCS model |
[in] | pProject | pointer to the parent project of the openETCS model |
[in] | OutStream | stream object used for output of generation |
Definition at line 240 of file CPPGenerator.cpp.
References __GENERATOR__EVCSTATE__, __GENERATOR__MAINFB__, __GENERATOR__SUBFB__, __GENERATOR__TELEGRAMGRAPH__, GenerateHeader(), GOPPRR::CObject::m_Explosions, GOPPRR::CProperty::m_NonProperties, GOPPRR::CConcept::m_OID, and GOPPRR::CNonProperty::Properties().
|
private |
internal helper method
Generates source code for creating all states of all control flows.
[in] | pRootGraph | pointer to the root graph of the openETCS model |
[in] | OutStream | stream object used for output of generation |
Definition at line 1996 of file CPPGenerator.cpp.
References __GENERATOR__EVCSTATE__, GOPPRR::CObject::m_Explosions, and GOPPRR::CGraph::m_ObjectSet.
|
private |
internal helper method
Generates source code for creating all trainsitions of control flows in a certain function block graph (data flow).
[in] | pFunctionBlock | pointer data flow graph |
[in] | pControlFlow | pointer to the related control flow graph |
[in] | pEVCState | pointer to parent EVC state object |
[in] | pState | pointer to the state object |
[in] | OutStream | stream object used for output of generation |
Definition at line 2034 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet, and GOPPRR::CGraph::Objects().
|
private |
internal helper method
Generates source code for creating all trainsitions of control flows in a certain function block graph (data flow).
[in] | pFunctionBlock | pointer to the data flow grah |
[in] | pControlFlow | pointer to the related control flow graph |
[in] | pEVCState | pointer to parent EVC state object |
[in] | pState | pointer to the state object |
[in] | OutStream | stream object used for output of generation |
Definition at line 2107 of file CPPGenerator.cpp.
References GOPPRR::CGraph::m_ObjectSet, GOPPRR::CConcept::m_OID, GOPPRR::CGraph::m_RelationshipSet, GOPPRR::CGraph::m_RoleSet, and GOPPRR::CConcept::m_Type.
|
staticprivate |
internal helper methods
Evaluates, if a certain GOPPRR object is a function block element.
[in] | pObject | pointer to the object to evaluate |
Definition at line 2907 of file CPPGenerator.cpp.
References __GENERATOR__FBTYPES__.
|
staticprivate |
internal helper method
Gets a string with the corresponding data type prefix for certain port of a function block object.
[in] | pPort | pointer to the port |
Definition at line 2996 of file CPPGenerator.cpp.
Referenced by GenerateFunctionBlock().
|
staticprivate |
internal helper method
Processes recursively a abstract function block node model to find start nodes.
[in] | pNode | node to be processed |
[in,out] | ExecutionOrder,: | list with OID in order of their later execution |
[in,out] | NodeStack,: | vector with pointer to already recursively processed nodes to detect data flow loops |
Definition at line 3059 of file CPPGenerator.cpp.
Referenced by GenerateControlFlows(), and GenerateDataFlow().
|
staticprivate |
internal helper method
Gets a string with the corresponding C++ type for a certain port of a function block object.
[in] | pPort | pointer to the port |
Definition at line 2940 of file CPPGenerator.cpp.
|
private |
map with function block meta model type names to C++ domain framework names
Definition at line 391 of file CPPGenerator.h.
Referenced by CCPPGenerator().
|
private |
map with function block meta model method/port names to C++ domain framework method names
Definition at line 398 of file CPPGenerator.h.
Referenced by CCPPGenerator().
|
private |
map of already generated control flow OIDs
Definition at line 419 of file CPPGenerator.h.
|
private |
map of already generated EVC transition OIDs
Definition at line 412 of file CPPGenerator.h.
|
private |
map of already generated transition OIDs
Definition at line 405 of file CPPGenerator.h.
Copyright (C) 2010-2012 Johannes Feuser (feuser@uni-bremen.de)
The openETCS library is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or any later version.
The openETCS library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with the openETCS library. If not, see
"http://www.gnu.org/licenses/.