OMNeT++ NEDXML  5.4.1
msgcodegenerator.h
Go to the documentation of this file.
1 //==========================================================================
2 // MSGCODEGENERATOR.H - part of
3 //
4 // OMNeT++/OMNEST
5 // Discrete System Simulation in C++
6 //
7 //==========================================================================
8 
9 /*--------------------------------------------------------------*
10  Copyright (C) 2002-2017 Andras Varga
11  Copyright (C) 2006-2017 OpenSim Ltd.
12 
13  This file is distributed WITHOUT ANY WARRANTY. See the file
14  `license' for details on this and other legal matters.
15 *--------------------------------------------------------------*/
16 
17 #ifndef __OMNETPP_NEDXML_MSGCODEGENERATOR_H
18 #define __OMNETPP_NEDXML_MSGCODEGENERATOR_H
19 
20 #include <iostream>
21 #include <fstream>
22 #include <sstream>
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <set>
27 
28 #include "errorstore.h"
29 #include "msgelements.h"
30 #include "msgtypetable.h"
31 
32 namespace omnetpp {
33 namespace nedxml {
34 
41 {
42  public:
43  typedef std::vector<std::string> StringVector;
49 
50  protected:
51  std::string hFilename;
52  std::string ccFilename;
53  std::ofstream hStream;
54  std::ofstream ccStream;
55  std::string headerGuard;
56 
57  protected:
58  std::string prefixWithNamespace(const std::string& name, const std::string& namespaceName);
59  std::string makeFuncall(const std::string& var, const std::string& funcTemplate, bool withIndex=false, const std::string& value="");
60 
61  void generateClassDecl(const ClassInfo& classInfo, const std::string& exportDef, const std::string& extraCode);
62  void generateClassImpl(const ClassInfo& classInfo);
63  void generateStructDecl(const ClassInfo& classInfo, const std::string& exportDef, const std::string& extraCode);
64  void generateStructImpl(const ClassInfo& classInfo);
65 
66  public:
67  void openFiles(const char *hFile, const char *ccFile);
68  void closeFiles();
69  void deleteFiles();
70  void generateProlog(const std::string& msgFileName, const std::string& firstNamespace, const std::string& exportDef);
71  void generateEpilog();
72  void generateClass(const ClassInfo& classInfo, const std::string& exportDef, const std::string& extraCode="");
73  void generateStruct(const ClassInfo& classInfo, const std::string& exportDef, const std::string& extraCode="");
74  void generateDescriptorClass(const ClassInfo& a);
75  void generateEnum(const EnumInfo& enumInfo);
76  void generateImport(const std::string& importName);
77  void generateNamespaceBegin(const std::string& namespaceName, bool intoCcFile=true);
78  void generateNamespaceEnd(const std::string& namespaceName, bool intoCcFile=true);
79  void generateTypeAnnouncement(const ClassInfo& classInfo);
80  std::string generatePreComment(ASTNode *nedElement);
81  void generateCplusplusBlock(const std::string& target, const std::string& body);
82  void generateTemplates();
83 };
84 
85 } // namespace nedxml
86 } // namespace omnetpp
87 
88 
89 #endif
90 
91 
std::ofstream ccStream
Definition: msgcodegenerator.h:54
#define NEDXML_API
Definition: nedxmldefs.h:31
Code generator part of the message compiler.
Definition: msgcodegenerator.h:40
MsgTypeTable::Properties Properties
Definition: msgcodegenerator.h:44
std::ofstream hStream
Definition: msgcodegenerator.h:53
Definition: msgtypetable.h:74
MsgTypeTable::EnumInfo EnumInfo
Definition: msgcodegenerator.h:48
MsgTypeTable::FieldInfo FieldInfo
Definition: msgcodegenerator.h:45
MsgTypeTable::ClassInfo ClassInfo
Definition: msgcodegenerator.h:46
std::vector< std::string > StringVector
Definition: msgcodegenerator.h:43
Definition: msgtypetable.h:139
Definition: astbuilder.h:25
Definition: msgtypetable.h:62
MsgTypeTable::EnumItem EnumItem
Definition: msgcodegenerator.h:47
std::string hFilename
Definition: msgcodegenerator.h:51
std::string ccFilename
Definition: msgcodegenerator.h:52
std::string headerGuard
Definition: msgcodegenerator.h:55
Definition: astnode.h:75
Definition: msgtypetable.h:198
Definition: msgtypetable.h:207