eRPC Generator (erpcgen)  Rev. 1.9.0
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 
17 #include <string>
18 
20 // Classes
22 
23 namespace erpcgen {
24 
31 {
32 public:
37  : m_parameters("(fn)")
38  , m_returnType(nullptr)
39  , m_isOneway(false)
40  {
41  }
42 
43  virtual ~FunctionBase(){};
44 
51 
58 
65 
71  void setReturnStructMemberType(StructMember *returnType) { m_returnType = returnType; }
72 
79  bool isOneway() const { return m_isOneway; }
80 
86  void setIsOneway(bool argIsOneway) { m_isOneway = argIsOneway; }
87 
102  virtual std::string getDescription() const = 0;
103 
104 protected:
107  bool m_isOneway;
108 };
109 
110 class Interface;
111 class FunctionType;
117 class Function : public FunctionBase, public Symbol
118 {
119 public:
128  Function(const Token &tok, Interface *interface)
129  : FunctionBase()
130  , Symbol(kFunctionSymbol, tok)
131  , m_uniqueId(++s_idCounter)
132  , m_interface(interface)
133  , m_functionType(nullptr)
134  {
135  }
136 
146  Function(const Token &tok, Interface *interface, uint32_t uniqueId)
147  : FunctionBase()
148  , Symbol(kFunctionSymbol, tok)
149  , m_uniqueId(uniqueId)
150  , m_interface(interface)
151  , m_functionType(nullptr)
152  {
153  s_idCounter = uniqueId;
154  }
155 
161  uint32_t getUniqueId() const { return m_uniqueId; }
162 
168  void setUniqueId(uint32_t newId) { m_uniqueId = newId; }
169 
175  Interface *getInterface() const { return m_interface; }
176 
191  virtual std::string getDescription() const;
192 
198  void setFunctionType(FunctionType *functionType) { m_functionType = functionType; }
199 
205  FunctionType *getFunctionType() const { return m_functionType; }
206 
207 protected:
208  uint32_t m_uniqueId;
212  static uint32_t s_idCounter;
213 };
214 
215 } // namespace erpcgen
216 
217 #endif // _EMBEDDED_RPC__FUNCTION_H_
Function data type.
Definition: FunctionType.h:31
StructMember * getReturnStructMemberType()
This function returns data type of function return value.
Definition: Function.h:64
StructMember * m_returnType
Definition: Function.h:106
Member of a struct.
Definition: StructMember.h:38
StructType & getParameters()
This function returns function parameters.
Definition: Function.h:50
DataType * getReturnType()
This function returns data type of function return value.
Definition: Function.h:57
virtual std::string getDescription() const =0
This function returns description about the interface function.
Structure data type.
Definition: StructType.h:29
Function declaration.
Definition: Function.h:117
uint32_t m_uniqueId
Definition: Function.h:208
Base class for all named declarations in the IDL.
Definition: Symbol.h:28
Function(const Token &tok, Interface *interface)
Constructor.
Definition: Function.h:128
DataType * getDataType()
This function returns pointer to element data type.
Definition: StructMember.h:82
Function(const Token &tok, Interface *interface, uint32_t uniqueId)
Constructor.
Definition: Function.h:146
Interface * getInterface() const
This function returns parent Interface.
Definition: Function.h:175
FunctionType * m_functionType
Definition: Function.h:210
Base class for data types.
Definition: DataType.h:26
Encapsulates all information about a token.
Definition: Token.h:60
static uint32_t s_idCounter
Definition: Function.h:212
StructType m_parameters
Definition: Function.h:105
Interface * m_interface
Definition: Function.h:209
Function base declaration.
Definition: Function.h:30
uint32_t getUniqueId() const
This function returns function unique id.
Definition: Function.h:161
FunctionType * getFunctionType() const
This function returns FunctionType (callback type).
Definition: Function.h:205
void setFunctionType(FunctionType *functionType)
This function sets FunctionType (callback type).
Definition: Function.h:198
An interface that contains functions.
Definition: Interface.h:29
FunctionBase()
Constructor.
Definition: Function.h:36
bool m_isOneway
Definition: Function.h:107
bool isOneway() const
This function returns true/false, when function return type is/isn&#39;t oneway.
Definition: Function.h:79
void setReturnStructMemberType(StructMember *returnType)
This function set data type of function return value.
Definition: Function.h:71
void setUniqueId(uint32_t newId)
This function set function unique id.
Definition: Function.h:168
Definition: AstNode.h:26
void setIsOneway(bool argIsOneway)
This function set true/false, when function return type is/isn&#39;t oneway.
Definition: Function.h:86