eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
InterfaceDefinition.h
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  * that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  * of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or
17  * other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _EMBEDDED_RPC__INTERFACEDEFINITION_H_
37 #define _EMBEDDED_RPC__INTERFACEDEFINITION_H_
38 
39 #include "AstNode.h"
40 #include "types/Program.h"
41 #include "types/SymbolScope.h"
42 #include <boost/filesystem.hpp>
43 #include <iostream>
44 
46 // Classes
48 
49 namespace erpcgen {
50 
57 {
58 public:
59  enum codec_t
60  {
61  kNotSpecified,
62  kBasicCodec,
63  };
69 
73  virtual ~InterfaceDefinition() {}
74 
80  void init();
81 
92  void parse(const char *inputFile);
93 
99  AstNode *getAst() { return m_ast; }
100 
106  SymbolScope &getGlobals() { return m_globals; }
107 
118  void setProgramInfo(const std::string &fileName, const std::string &outputFilePath, codec_t codec);
119 
125  void setProgramName(const std::string &programName) { m_programName = programName; }
126 
132  const std::string getProgramName() { return getProgramSymbol()->getName(); }
133 
139  boost::filesystem::path getOutputDirectory() { return m_outputDirectory; }
140 
146  std::string getOutputFilename() { return m_outputFilename; }
147 
153  void setOutputFilename(const std::string &filename);
154 
161  bool hasProgramSymbol();
162 
169 
178  codec_t getCodecType() { return m_codec; }
179 
185  uint16_t getIdlCrc16() { return m_idlCrc16; }
186 
187 private:
188  /* Instance Variables */
189  AstNode *m_ast;
190  SymbolScope m_globals;
191  Program *m_program;
192  std::string m_programName;
193  std::string m_outputFilename;
194  boost::filesystem::path m_outputDirectory;
195  codec_t m_codec;
196  uint16_t m_idlCrc16;
198  /* Private Functions */
202  void createBuiltinTypes();
203 };
204 
205 } // namespace erpcgen
206 
207 #endif // _EMBEDDED_RPC__INTERFACEDEFINITION_H_
Collects all definitions from an IDL.
Definition: InterfaceDefinition.h:56
codec_t getCodecType()
This function returns used codec type in eRPC application.
Definition: InterfaceDefinition.h:178
virtual ~InterfaceDefinition()
Destructor.
Definition: InterfaceDefinition.h:73
void setOutputFilename(const std::string &filename)
This function sets output file name.
Definition: InterfaceDefinition.cpp:139
Homogeneous AST node class.
Definition: AstNode.h:61
AstNode * getAst()
This function returns node belong to this object.
Definition: InterfaceDefinition.h:99
Program declaration.
Definition: Program.h:53
Program * getProgramSymbol()
This function returns program symbol.
Definition: InterfaceDefinition.cpp:127
uint16_t getIdlCrc16()
This function returns crc16 of all used IDL files.
Definition: InterfaceDefinition.h:185
void parse(const char *inputFile)
This function parse given IDL file.
Definition: InterfaceDefinition.cpp:71
const std::string & getName() const
This function returns symbol name.
Definition: Symbol.h:150
A scoped namespace containing symbols.
Definition: SymbolScope.h:53
std::string getOutputFilename()
This function returns output file name.
Definition: InterfaceDefinition.h:146
const std::string getProgramName()
This function returns program name.
Definition: InterfaceDefinition.h:132
InterfaceDefinition()
Default constructor.
Definition: InterfaceDefinition.cpp:55
void init()
This function initialize symbol scope variable m_globals.
Definition: InterfaceDefinition.cpp:66
void setProgramName(const std::string &programName)
This function sets program name.
Definition: InterfaceDefinition.h:125
bool hasProgramSymbol()
This function returns information if program symbol was set in parsed file.
Definition: InterfaceDefinition.cpp:122
boost::filesystem::path getOutputDirectory()
This function returns output directory path.
Definition: InterfaceDefinition.h:139
SymbolScope & getGlobals()
This function returns global symbol scope.
Definition: InterfaceDefinition.h:106
Definition: AstNode.h:51
void setProgramInfo(const std::string &fileName, const std::string &outputFilePath, codec_t codec)
This function sets program information.
Definition: InterfaceDefinition.cpp:115