eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
EnumType.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__ENUMTYPE_H_
37 #define _EMBEDDED_RPC__ENUMTYPE_H_
38 
39 #include "DataType.h"
40 #include "EnumMember.h"
41 #include <string>
42 #include <vector>
43 
45 // Classes
47 
48 namespace erpcgen {
49 
53 class EnumType : public DataType
54 {
55 public:
56  typedef std::vector<EnumMember *> member_vector_t;
65  EnumType(const Token &tok)
66  : DataType(tok, kEnumType, kEnumTypeSymbol)
67  {
68  }
69 
76  : DataType("", kEnumType, kEnumTypeSymbol)
77  {
78  }
79 
87  void addMember(EnumMember *newMember);
88 
94  member_vector_t &getMembers() { return m_members; }
95 
101  EnumMember *getMember(std::string name);
102 
108  virtual bool isEnum() const { return true; }
109 
115  uint32_t getNextValue() { return m_currentValue++; }
116 
122  void setCurrentValue(uint32_t value) { m_currentValue = value; }
123 
138  virtual std::string getDescription() const;
139 
140 protected:
141  member_vector_t m_members;
142  uint32_t m_currentValue = 0;
143 };
144 
145 } // namespace erpcgen
146 
147 #endif // _EMBEDDED_RPC__ENUMTYPE_H_
uint32_t getNextValue()
This function returns the next value to use for an enum member.
Definition: EnumType.h:115
std::vector< EnumMember * > member_vector_t
Definition: EnumType.h:56
member_vector_t m_members
Definition: EnumType.h:141
virtual bool isEnum() const
This function return "true" value for identify enum type.
Definition: EnumType.h:108
void addMember(EnumMember *newMember)
This function will add enum member to the enum.
Definition: Type.cpp:383
EnumType(const Token &tok)
Constructor.
Definition: EnumType.h:65
uint32_t m_currentValue
Definition: EnumType.h:142
virtual std::string getDescription() const
This function returns description about the enum.
Definition: Type.cpp:389
EnumType()
Constructor.
Definition: EnumType.h:75
Member of a enum.
Definition: EnumMember.h:51
Base class for data types.
Definition: DataType.h:51
Encapsulates all information about a token.
Definition: Token.h:86
Enumerate data type.
Definition: EnumType.h:53
member_vector_t & getMembers()
This function returns vector of enum members.
Definition: EnumType.h:94
void setCurrentValue(uint32_t value)
This function set current value.
Definition: EnumType.h:122
Definition: AstNode.h:51
EnumMember * getMember(std::string name)
This function returns enum member based on given name.
Definition: Type.cpp:371