OMNeT++ NEDXML 6.2.0
Discrete Event Simulation Library
msgcompiler.h
Go to the documentation of this file.
1 //==========================================================================
2 // MSGCOMPILER.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_MSGCOMPILER_H
18 #define __OMNETPP_NEDXML_MSGCOMPILER_H
19 
20 #include <iostream>
21 #include <sstream>
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <set>
26 
27 #include "errorstore.h"
28 #include "msgelements.h"
29 #include "msgtypetable.h"
30 #include "msganalyzer.h"
31 #include "msgcodegenerator.h"
32 #include "msgcompileroptions.h"
33 
34 namespace omnetpp {
35 namespace nedxml {
36 
45 {
46  public:
47  typedef std::set<std::string> StringSet;
48  typedef std::vector<std::string> StringVector;
54 
55  protected:
60 
61  bool used = false;
65 
66  private:
67  static constexpr const char* ATT_NAME = "name";
68  static const char *BUILTIN_DEFINITIONS;
69 
70  protected:
71  void importBuiltinDefinitions();
72  void processBuiltinImport(const char *txt, const char *fname);
73 
74  void processImport(ImportElement *importElem, const std::string& currentDir);
75  std::string resolveImport(const std::string& importName, const std::string& currentDir);
76  void collectTypes(MsgFileElement *fileElement, bool isImport);
77  void generateCode(MsgFileElement *fileElement);
78  std::string prefixWithNamespace(const std::string& name, const std::string& namespaceName);
79  void validateNamespaceName(const std::string& namespaceName, ASTNode *element);
80 
81  public:
85  MsgCompiler(const MsgCompilerOptions& options, ErrorStore *errors);
86 
91 
96  void generate(MsgFileElement *fileElement, const char *hFile, const char *ccFile, StringSet& outImportedFiles);
97 
101  void printPropertiesLatexDocu(std::ostream& out);
102 
106  static const char *getBuiltinDefinitions() {return BUILTIN_DEFINITIONS;}
107 };
108 
109 } // namespace nedxml
110 } // namespace omnetpp
111 
112 
113 #endif
114 
115 
omnetpp::nedxml::MsgCompilerOptions
Options for MsgCompiler.
Definition: msgcompileroptions.h:32
omnetpp::nedxml::MsgCompiler::Properties
MsgTypeTable::Properties Properties
Definition: msgcompiler.h:50
omnetpp::nedxml::MsgTypeTable::Properties
Definition: msgtypetable.h:64
msgcodegenerator.h
omnetpp::nedxml::MsgTypeTable::ClassInfo
Definition: msgtypetable.h:162
omnetpp::nedxml::MsgCompiler::codegen
MsgCodeGenerator codegen
Definition: msgcompiler.h:59
omnetpp::nedxml::MsgCompiler::importsSeen
StringSet importsSeen
Definition: msgcompiler.h:63
omnetpp::nedxml::MsgCodeGenerator
Code generator part of the message compiler.
Definition: msgcodegenerator.h:40
omnetpp::nedxml::MsgCompiler::getBuiltinDefinitions
static const char * getBuiltinDefinitions()
Definition: msgcompiler.h:106
NEDXML_API
#define NEDXML_API
Definition: nedxmldefs.h:31
omnetpp::nedxml::MsgCompiler::Property
MsgTypeTable::Property Property
Definition: msgcompiler.h:49
omnetpp
Definition: astbuilder.h:25
omnetpp::nedxml::MsgTypeTable::EnumItem
Definition: msgtypetable.h:153
omnetpp::nedxml::MsgCompiler::~MsgCompiler
~MsgCompiler()
Definition: msgcompiler.h:90
omnetpp::nedxml::MsgTypeTable
Definition: msgtypetable.h:39
omnetpp::nedxml::MsgCompiler::importedFiles
StringSet importedFiles
Definition: msgcompiler.h:64
omnetpp::nedxml::MsgCompiler::ClassInfo
MsgTypeTable::ClassInfo ClassInfo
Definition: msgcompiler.h:52
omnetpp::nedxml::MsgTypeTable::Property
Definition: msgtypetable.h:44
omnetpp::nedxml::MsgCompiler::FieldInfo
MsgTypeTable::FieldInfo FieldInfo
Definition: msgcompiler.h:51
omnetpp::nedxml::MsgCompiler::errors
ErrorStore * errors
Definition: msgcompiler.h:62
msgcompileroptions.h
omnetpp::nedxml::MsgCompiler::StringSet
std::set< std::string > StringSet
Definition: msgcompiler.h:47
omnetpp::nedxml::ASTNode
Definition: astnode.h:87
omnetpp::nedxml::MsgCompiler::EnumItem
MsgTypeTable::EnumItem EnumItem
Definition: msgcompiler.h:53
errorstore.h
omnetpp::nedxml::MsgCompiler::typeTable
MsgTypeTable typeTable
Definition: msgcompiler.h:57
omnetpp::nedxml::MsgCompiler::opts
MsgCompilerOptions opts
Definition: msgcompiler.h:56
omnetpp::nedxml::MsgAnalyzer
Part of the message compiler. Produces ClassInfo objects from the ASTNode tree. Assumes object tree h...
Definition: msganalyzer.h:41
omnetpp::nedxml::MsgCompiler::analyzer
MsgAnalyzer analyzer
Definition: msgcompiler.h:58
msganalyzer.h
omnetpp::nedxml::MsgCompiler::StringVector
std::vector< std::string > StringVector
Definition: msgcompiler.h:48
omnetpp::nedxml::ErrorStore
Definition: errorstore.h:37
omnetpp::nedxml::MsgCompiler
Generates C++ code from a MSG file object tree.
Definition: msgcompiler.h:44
omnetpp::nedxml::MsgTypeTable::FieldInfo
Definition: msgtypetable.h:76
msgtypetable.h