Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
cpp_generator.h
1 
2 /***************************************************************************
3  * cpp_generator.h - C++ Interface generator
4  *
5  * Created: Thu Oct 12 01:59:02 2006
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __INTERFACES_GENERATOR_CPP_GENERATOR_H_
24 #define __INTERFACES_GENERATOR_CPP_GENERATOR_H_
25 
26 #include "field.h"
27 #include "constant.h"
28 #include "enum_constant.h"
29 #include "message.h"
30 #include "pseudomap.h"
31 
32 #include <vector>
33 #include <string>
34 #include <stdio.h>
35 
37 {
38  public:
39  CppInterfaceGenerator(std::string directory, std::string interface_name,
40  std::string config_basename, std::string author,
41  std::string year, std::string creation_date,
42  std::string data_comment,
43  const unsigned char *hash, size_t hash_size,
44  const std::vector<InterfaceConstant> &constants,
45  const std::vector<InterfaceEnumConstant> &enum_constants,
46  const std::vector<InterfaceField> &data_fields,
47  const std::vector<InterfacePseudoMap> &pseudo_maps,
48  const std::vector<InterfaceMessage> &messages
49  );
51 
52  void write_h(FILE *f);
53  void write_cpp(FILE *f);
54 
55  void write_constants_cpp(FILE *f);
56  void write_constants_h(FILE *f);
58 
59  void write_messages_cpp(FILE *f);
60  void write_messages_h(FILE *f);
61  void write_ctor_dtor_h(FILE *f, std::string /* indent space */ is,
62  std::string classname);
63  void write_ctor_dtor_cpp(FILE *f, std::string classname, std::string super_class,
64  std::string inclusion_prefix, std::vector<InterfaceField> fields,
65  std::vector<InterfaceMessage> messages);
66 
67  void write_message_ctor_dtor_h(FILE *f, std::string /* indent space */ is,
68  std::string classname,
69  std::vector<InterfaceField> fields);
70  void write_message_ctor_dtor_cpp(FILE *f, std::string classname, std::string super_class,
71  std::string inclusion_prefix,
72  std::vector<InterfaceField> fields);
73  void write_message_clone_method_h(FILE *f, std::string is);
74  void write_message_clone_method_cpp(FILE *f, std::string classname);
75 
76 
77  void write_methods_h(FILE *f,
78  std::string /* indent space */ is,
79  std::vector<InterfaceField> fields);
80  void write_methods_cpp(FILE *f,
81  std::string interface_classname,
82  std::string classname,
83  std::vector<InterfaceField> fields,
84  std::string inclusion_prefix,
85  bool write_data_changed);
86 
87  void write_create_message_method_cpp(FILE *f);
88  void write_copy_value_method_cpp(FILE *f);
89  void write_enum_tostring_method_cpp(FILE *f);
90  void write_basemethods_h(FILE *f, std::string is);
91  void write_basemethods_cpp(FILE *f);
92 
93  void write_methods_h(FILE *f,
94  std::string /* indent space */ is,
95  std::vector<InterfaceField> fields,
96  std::vector<InterfacePseudoMap> pseudo_maps);
97  void write_methods_cpp(FILE *f,
98  std::string interface_classname,
99  std::string classname,
100  std::vector<InterfaceField> fields,
101  std::vector<InterfacePseudoMap> pseudo_maps,
102  std::string inclusion_prefix);
103 
104  void write_management_funcs_cpp(FILE *f);
105 
106  void write_add_fieldinfo_calls(FILE *f, std::vector<InterfaceField> &fields);
107 
108 
109  void write_struct(FILE *f, std::string name, std::string /* indent space */ is,
110  std::vector<InterfaceField> fields);
111 
112  void write_header(FILE *f, std::string filename);
113  void write_deflector(FILE *f);
114  void generate();
115 
116  private:
117  std::vector<InterfaceConstant> constants;
118  std::vector<InterfaceEnumConstant> enum_constants;
119  std::vector<InterfaceField> data_fields;
120  std::vector<InterfacePseudoMap> pseudo_maps;
121  std::vector<InterfaceMessage> messages;
122 
123  std::string dir;
124  std::string filename_cpp;
125  std::string filename_h;
126  std::string filename_o;
127  std::string class_name;
128  std::string deflector;
129  std::string gendate;
130  std::string author;
131  std::string year;
132  std::string creation_date;
133  std::string data_comment;
134 
135  const unsigned char *hash;
136  size_t hash_size;
137 };
138 
139 
140 #endif