msgcompiler.h Source File

NEDXML API: msgcompiler.h Source File
NEDXML API
msgcompiler.h
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
34namespace omnetpp {
35namespace nedxml {
36
44class NEDXML_API MsgCompiler
45{
46 public:
47 typedef std::set<std::string> StringSet;
48 typedef std::vector<std::string> StringVector;
49 typedef MsgTypeTable::Property Property;
50 typedef MsgTypeTable::Properties Properties;
51 typedef MsgTypeTable::FieldInfo FieldInfo;
52 typedef MsgTypeTable::ClassInfo ClassInfo;
53 typedef MsgTypeTable::EnumItem EnumItem;
54
55 protected:
57 MsgTypeTable typeTable;
58 MsgAnalyzer analyzer;
59 MsgCodeGenerator codegen;
60
61 bool used = false;
62 ErrorStore *errors;
63 StringSet importsSeen;
64 StringSet importedFiles;
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
Definition astnode.h:88
Definition errorstore.h:38
Part of the message compiler. Produces ClassInfo objects from the ASTNode tree. Assumes object tree h...
Definition msganalyzer.h:42
Code generator part of the message compiler.
Definition msgcodegenerator.h:41
void generate(MsgFileElement *fileElement, const char *hFile, const char *ccFile, StringSet &outImportedFiles)
static const char * getBuiltinDefinitions()
Definition msgcompiler.h:106
MsgCompiler(const MsgCompilerOptions &options, ErrorStore *errors)
void printPropertiesLatexDocu(std::ostream &out)
~MsgCompiler()
Definition msgcompiler.h:90
Definition msgtypetable.h:40
Options for MsgCompiler.
Definition msgcompileroptions.h:33