eRPC Generator (erpcgen)  Rev. 1.7.2
NXP Semiconductors
Function.h
1 /*
2  * Copyright (c) 2014, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 
10 #ifndef _EMBEDDED_RPC__FUNCTION_H_
11 #define _EMBEDDED_RPC__FUNCTION_H_
12 
13 #include "DataType.h"
14 #include "StructType.h"
15 #include "Symbol.h"
16 #include <string>
17 
19 // Classes
21 
22 namespace erpcgen {
23 
30 {
31 public:
36  : m_parameters("(fn)")
37  , m_returnType(nullptr)
38  , m_isOneway(false)
39  {
40  }
41 
42  virtual ~FunctionBase(){};
43 
50 
57 
64 
70  void setReturnStructMemberType(StructMember *returnType) { m_returnType = returnType; }
71 
78  bool isOneway() const { return m_isOneway; }
79 
86 
101  virtual std::string getDescription() const = 0;
102 
103 protected:
106  bool m_isOneway;
107 };
108 
109 class Interface;
110 class FunctionType;
116 class Function : public FunctionBase, public Symbol
117 {
118 public:
127  Function(const Token &tok, Interface *interface)
128  : Symbol(kFunctionSymbol, tok)
129  , FunctionBase()
130  , m_uniqueId(++s_idCounter)
131  , m_interface(interface)
132  , m_functionType(nullptr)
133  {
134  }
135 
145  Function(const Token &tok, Interface *interface, uint32_t uniqueId)
146  : Symbol(kFunctionSymbol, tok)
147  , FunctionBase()
148  , m_uniqueId(uniqueId)
149  , m_interface(interface)
150  , m_functionType(nullptr)
151  {
152  s_idCounter = uniqueId;
153  }
154 
160  uint32_t getUniqueId() const { return m_uniqueId; }
161 
167  void setUniqueId(uint32_t newId) { m_uniqueId = newId; }
168 
174  Interface *getInterface() const { return m_interface; }
175 
190  virtual std::string getDescription() const;
191 
197  void setFunctionType(FunctionType *functionType) { m_functionType = functionType; }
198 
204  FunctionType *getFunctionType() const { return m_functionType; }
205 
206 protected:
207  uint32_t m_uniqueId;
211  static uint32_t s_idCounter;
212 };
213 
214 } // namespace erpcgen
215 
216 #endif // _EMBEDDED_RPC__FUNCTION_H_
Function data type.
Definition: FunctionType.h:30
StructMember * getReturnStructMemberType()
This function returns data type of function return value.
Definition: Function.h:63
StructMember * m_returnType
Definition: Function.h:105
Member of a struct.
Definition: StructMember.h:37
StructType & getParameters()
This function returns function parameters.
Definition: Function.h:49
DataType * getReturnType()
This function returns data type of function return value.
Definition: Function.h:56
virtual std::string getDescription() const =0
This function returns description about the interface function.
Structure data type.
Definition: StructType.h:28
Function declaration.
Definition: Function.h:116
uint32_t m_uniqueId
Definition: Function.h:207
Base class for all named declarations in the IDL.
Definition: Symbol.h:27
Function(const Token &tok, Interface *interface)
Constructor.
Definition: Function.h:127
DataType * getDataType()
This function returns pointer to element data type.
Definition: StructMember.h:81
Function(const Token &tok, Interface *interface, uint32_t uniqueId)
Constructor.
Definition: Function.h:145
Interface * getInterface() const
This function returns parent Interface.
Definition: Function.h:174
FunctionType * m_functionType
Definition: Function.h:209
Base class for data types.
Definition: DataType.h:25
Encapsulates all information about a token.
Definition: Token.h:60
static uint32_t s_idCounter
Definition: Function.h:211
StructType m_parameters
Definition: Function.h:104
Interface * m_interface
Definition: Function.h:208
Function base declaration.
Definition: Function.h:29
uint32_t getUniqueId() const
This function returns function unique id.
Definition: Function.h:160
FunctionType * getFunctionType() const
This function returns FunctionType (callback type).
Definition: Function.h:204
void setFunctionType(FunctionType *functionType)
This function sets FunctionType (callback type).
Definition: Function.h:197
An interface that contains functions.
Definition: Interface.h:28
void setIsOneway(bool isOneway)
This function set true/false, when function return type is/isn&#39;t oneway.
Definition: Function.h:85
FunctionBase()
Constructor.
Definition: Function.h:35
bool m_isOneway
Definition: Function.h:106
bool isOneway() const
This function returns true/false, when function return type is/isn&#39;t oneway.
Definition: Function.h:78
void setReturnStructMemberType(StructMember *returnType)
This function set data type of function return value.
Definition: Function.h:70
void setUniqueId(uint32_t newId)
This function set function unique id.
Definition: Function.h:167
Definition: AstNode.h:25