CppClass.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include "MetaClass.h"
27 
28 #include "CppEnum.h"
29 #include "CppMethod.h"
30 #include "CppField.h"
31 #include "CppCtor.h"
32 
33 namespace armarx
34 {
35  class CppClass;
36  using CppClassPtr = std::shared_ptr<CppClass>;
37 
38  class CppClass :
39  virtual public MetaClass
40  {
41  public:
42  CppClass(const std::vector<std::string>& namespaces, const std::string& name, const std::string& templates = "");
43 
44  virtual void write(const MetaWriterPtr& writer) override;
45  void writeCpp(const CppWriterPtr& writer);
46  static void WriteCpp(const std::vector<CppClassPtr>& classes, const CppWriterPtr& writer);
47 
48  void addPublicMethod(const CppMethodPtr method);
49  CppMethodPtr addPublicMethod(const std::string& header, const std::string& doc = "", const bool enforceBlockGeneration = false);
50 
51  void addCtor(const CppCtorPtr&);
52  CppCtorPtr addCtor(const std::string& arguments);
53  CppCtorPtr addCtor(const std::string& arguments, const CppBlockPtr& b);
54 
55  void addPublicField(const CppFieldPtr& field);
56  void addPrivateField(const CppFieldPtr& field);
57  void addProtectedField(const CppFieldPtr& field);
58 
59  void addInnerClass(const CppClassPtr inner);
60  CppClassPtr addInnerClass(const std::string& name);
61 
62  void addInnerEnum(const CppEnumPtr inner);
63  CppEnumPtr addInnerEnum(const std::string& name);
64 
65  void addInherit(const std::string& inherit);
66 
67  void addInclude(const std::string include);
68  bool hasInclude(const std::string include);
69 
70  void setTemplates(const std::string&);
71 
72 
73  private:
74  std::vector<std::string> namespaces;
75  std::string templates;
76  std::vector<CppMethodPtr> publicMethods;
77  std::vector<CppFieldPtr> privateFields;
78  std::vector<CppFieldPtr> protectedFields;
79  std::vector<CppFieldPtr> publicFields;
80  std::vector<std::string> inherit;
81  std::vector<CppEnumPtr> innerEnums;
82  std::vector<CppClassPtr> innerClasses;
83  std::vector<CppCtorPtr> ctors;
84  std::vector<std::string> includes;
85  };
86 }
87 
armarx::CppClass::writeCpp
void writeCpp(const CppWriterPtr &writer)
Definition: CppClass.cpp:57
CppMethod.h
armarx::CppCtorPtr
std::shared_ptr< CppCtor > CppCtorPtr
Definition: CppCtor.h:31
armarx::CppClass::write
virtual void write(const MetaWriterPtr &writer) override
Definition: CppClass.cpp:43
MetaClass.h
armarx::CppClassPtr
std::shared_ptr< CppClass > CppClassPtr
Definition: CppClass.h:36
CppCtor.h
armarx::CppBlockPtr
std::shared_ptr< CppBlock > CppBlockPtr
Definition: CppBlock.h:35
armarx::CppClass::addPublicMethod
void addPublicMethod(const CppMethodPtr method)
Definition: CppClass.cpp:195
armarx::CppClass::addInherit
void addInherit(const std::string &inherit)
Definition: CppClass.cpp:271
armarx::CppFieldPtr
std::shared_ptr< CppField > CppFieldPtr
Definition: CppField.h:34
armarx::CppEnumPtr
std::shared_ptr< CppEnum > CppEnumPtr
Definition: CppEnum.h:55
armarx::MetaClass::name
std::string name
Definition: MetaClass.h:48
armarx::CppClass::CppClass
CppClass(const std::vector< std::string > &namespaces, const std::string &name, const std::string &templates="")
Definition: CppClass.cpp:36
CppEnum.h
armarx::CppClass::hasInclude
bool hasInclude(const std::string include)
Definition: CppClass.cpp:281
armarx::CppClass::addInnerClass
void addInnerClass(const CppClassPtr inner)
Definition: CppClass.cpp:252
CppField.h
armarx::CppClass
Definition: CppClass.h:38
armarx::CppMethodPtr
std::shared_ptr< CppMethod > CppMethodPtr
Definition: CppMethod.h:32
armarx::CppClass::setTemplates
void setTemplates(const std::string &)
Definition: CppClass.cpp:287
armarx::MetaClass
Definition: MetaClass.h:35
armarx::CppClass::WriteCpp
static void WriteCpp(const std::vector< CppClassPtr > &classes, const CppWriterPtr &writer)
Definition: CppClass.cpp:49
armarx::MetaWriterPtr
std::shared_ptr< MetaWriter > MetaWriterPtr
Definition: MetaWriter.h:37
armarx::CppClass::addPublicField
void addPublicField(const CppFieldPtr &field)
Definition: CppClass.cpp:239
armarx::CppClass::addPrivateField
void addPrivateField(const CppFieldPtr &field)
Definition: CppClass.cpp:227
armarx::CppClass::addInclude
void addInclude(const std::string include)
Definition: CppClass.cpp:276
armarx::CppWriterPtr
std::shared_ptr< CppWriter > CppWriterPtr
Definition: CppWriter.h:35
armarx::CppClass::addInnerEnum
void addInnerEnum(const CppEnumPtr inner)
Definition: CppClass.cpp:257
armarx::CppClass::addCtor
void addCtor(const CppCtorPtr &)
Definition: CppClass.cpp:208
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CppClass::addProtectedField
void addProtectedField(const CppFieldPtr &field)
Definition: CppClass.cpp:233