eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
Function.h
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2014, 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__FUNCTION_H_
37 #define _EMBEDDED_RPC__FUNCTION_H_
38 
39 #include "DataType.h"
40 #include "StructType.h"
41 #include "Symbol.h"
42 #include <string>
43 
45 // Classes
47 
48 namespace erpcgen {
49 
56 {
57 public:
62  : m_parameters("(fn)")
63  , m_returnType(nullptr)
64  , m_isOneway(false)
65  {
66  }
67 
68  virtual ~FunctionBase(){};
69 
76 
83 
90 
96  void setReturnStructMemberType(StructMember *returnType) { m_returnType = returnType; }
97 
104  bool isOneway() const { return m_isOneway; }
105 
112 
127  virtual std::string getDescription() const = 0;
128 
129 protected:
132  bool m_isOneway;
133 };
134 
135 class Interface;
136 class FunctionType;
142 class Function : public FunctionBase, public Symbol
143 {
144 public:
153  Function(const Token &tok, Interface *interface)
154  : Symbol(kFunctionSymbol, tok)
155  , FunctionBase()
156  , m_uniqueId(++s_idCounter)
157  , m_interface(interface)
158  , m_functionType(nullptr)
159  {
160  }
161 
171  Function(const Token &tok, Interface *interface, uint32_t uniqueId)
172  : Symbol(kFunctionSymbol, tok)
173  , FunctionBase()
174  , m_uniqueId(uniqueId)
175  , m_interface(interface)
176  , m_functionType(nullptr)
177  {
178  s_idCounter = uniqueId;
179  }
180 
186  uint32_t getUniqueId() const { return m_uniqueId; }
187 
193  void setUniqueId(uint32_t newId) { m_uniqueId = newId; }
194 
200  Interface *getInterface() const { return m_interface; }
201 
216  virtual std::string getDescription() const;
217 
223  void setFunctionType(FunctionType *functionType) { m_functionType = functionType; }
224 
230  FunctionType *getFunctionType() const { return m_functionType; }
231 
232 protected:
233  uint32_t m_uniqueId;
237  static uint32_t s_idCounter;
238 };
239 
240 } // namespace erpcgen
241 
242 #endif // _EMBEDDED_RPC__FUNCTION_H_
Function data type.
Definition: FunctionType.h:56
StructMember * getReturnStructMemberType()
This function returns data type of function return value.
Definition: Function.h:89
StructMember * m_returnType
Definition: Function.h:131
Member of a struct.
Definition: StructMember.h:63
StructType & getParameters()
This function returns function parameters.
Definition: Function.h:75
DataType * getReturnType()
This function returns data type of function return value.
Definition: Function.h:82
virtual std::string getDescription() const =0
This function returns description about the interface function.
Structure data type.
Definition: StructType.h:54
Function declaration.
Definition: Function.h:142
uint32_t m_uniqueId
Definition: Function.h:233
Base class for all named declarations in the IDL.
Definition: Symbol.h:53
Function(const Token &tok, Interface *interface)
Constructor.
Definition: Function.h:153
DataType * getDataType()
This function returns pointer to element data type.
Definition: StructMember.h:107
Function(const Token &tok, Interface *interface, uint32_t uniqueId)
Constructor.
Definition: Function.h:171
Interface * getInterface() const
This function returns parent Interface.
Definition: Function.h:200
FunctionType * m_functionType
Definition: Function.h:235
Base class for data types.
Definition: DataType.h:51
Encapsulates all information about a token.
Definition: Token.h:86
static uint32_t s_idCounter
Definition: Function.h:237
StructType m_parameters
Definition: Function.h:130
Interface * m_interface
Definition: Function.h:234
Function base declaration.
Definition: Function.h:55
uint32_t getUniqueId() const
This function returns function unique id.
Definition: Function.h:186
FunctionType * getFunctionType() const
This function returns FunctionType (callback type).
Definition: Function.h:230
void setFunctionType(FunctionType *functionType)
This function sets FunctionType (callback type).
Definition: Function.h:223
An interface that contains functions.
Definition: Interface.h:54
void setIsOneway(bool isOneway)
This function set true/false, when function return type is/isn&#39;t oneway.
Definition: Function.h:111
FunctionBase()
Constructor.
Definition: Function.h:61
bool m_isOneway
Definition: Function.h:132
bool isOneway() const
This function returns true/false, when function return type is/isn&#39;t oneway.
Definition: Function.h:104
void setReturnStructMemberType(StructMember *returnType)
This function set data type of function return value.
Definition: Function.h:96
void setUniqueId(uint32_t newId)
This function set function unique id.
Definition: Function.h:193
Definition: AstNode.h:51