Fawkes API Fawkes Development Version

cpp_generator.h

00001  
00002 /***************************************************************************
00003  *  cpp_generator.h - C++ Interface generator
00004  *
00005  *  Created: Thu Oct 12 01:59:02 2006
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __INTERFACES_GENERATOR_CPP_GENERATOR_H_
00024 #define __INTERFACES_GENERATOR_CPP_GENERATOR_H_
00025 
00026 #include "field.h"
00027 #include "constant.h"
00028 #include "enum_constant.h"
00029 #include "message.h"
00030 #include "pseudomap.h"
00031 
00032 #include <vector>
00033 #include <string>
00034 #include <stdio.h>
00035 
00036 class CppInterfaceGenerator
00037 {
00038  public:
00039   CppInterfaceGenerator(std::string directory, std::string interface_name,
00040                         std::string config_basename, std::string author,
00041                         std::string year, std::string creation_date,
00042                         std::string data_comment,
00043                         const unsigned char *hash, size_t hash_size,
00044                         const std::vector<InterfaceConstant> &constants,
00045                         const std::vector<InterfaceEnumConstant> &enum_constants,
00046                         const std::vector<InterfaceField> &data_fields,
00047                         const std::vector<InterfacePseudoMap> &pseudo_maps,
00048                         const std::vector<InterfaceMessage> &messages
00049                         );
00050   ~CppInterfaceGenerator();
00051 
00052   void write_h(FILE *f);
00053   void write_cpp(FILE *f);
00054 
00055   void write_constants_cpp(FILE *f);
00056   void write_constants_h(FILE *f);
00057   void write_enum_constants_tostring_cpp(FILE *f);
00058 
00059   void write_messages_cpp(FILE *f);
00060   void write_messages_h(FILE *f);
00061   void write_ctor_dtor_h(FILE *f,  std::string /* indent space */ is,
00062                          std::string classname);
00063   void write_ctor_dtor_cpp(FILE *f, std::string classname, std::string super_class,
00064                            std::string inclusion_prefix, std::vector<InterfaceField> fields,
00065                            std::vector<InterfaceMessage> messages);
00066 
00067   void write_message_ctor_dtor_h(FILE *f,  std::string /* indent space */ is,
00068                                  std::string classname,
00069                                  std::vector<InterfaceField> fields);
00070   void write_message_ctor_dtor_cpp(FILE *f, std::string classname, std::string super_class,
00071                                    std::string inclusion_prefix,
00072                                    std::vector<InterfaceField> fields);
00073   void write_message_clone_method_h(FILE *f, std::string is);
00074   void write_message_clone_method_cpp(FILE *f, std::string classname);
00075 
00076 
00077   void write_methods_h(FILE *f,
00078                        std::string /* indent space */ is,
00079                        std::vector<InterfaceField> fields);
00080   void write_methods_cpp(FILE *f,
00081                          std::string interface_classname,
00082                          std::string classname,
00083                          std::vector<InterfaceField> fields,
00084                          std::string inclusion_prefix,
00085                          bool write_data_changed);
00086 
00087   void write_create_message_method_cpp(FILE *f);
00088   void write_copy_value_method_cpp(FILE *f);
00089   void write_enum_tostring_method_cpp(FILE *f);
00090   void write_basemethods_h(FILE *f, std::string is);
00091   void write_basemethods_cpp(FILE *f);
00092 
00093   void write_methods_h(FILE *f,
00094                        std::string /* indent space */ is,
00095                        std::vector<InterfaceField> fields,
00096                        std::vector<InterfacePseudoMap> pseudo_maps);
00097   void write_methods_cpp(FILE *f,
00098                          std::string interface_classname,
00099                          std::string classname,
00100                          std::vector<InterfaceField> fields,
00101                          std::vector<InterfacePseudoMap> pseudo_maps,
00102                          std::string inclusion_prefix);
00103 
00104   void write_management_funcs_cpp(FILE *f);
00105 
00106   void write_add_fieldinfo_calls(FILE *f, std::vector<InterfaceField> &fields);
00107 
00108 
00109   void write_struct(FILE *f, std::string name, std::string /* indent space */ is,
00110                     std::vector<InterfaceField> fields);
00111 
00112   void write_header(FILE *f, std::string filename);
00113   void write_deflector(FILE *f);
00114   void generate();
00115 
00116  private:
00117   std::vector<InterfaceConstant>     constants;
00118   std::vector<InterfaceEnumConstant> enum_constants;
00119   std::vector<InterfaceField>        data_fields;
00120   std::vector<InterfacePseudoMap>    pseudo_maps;
00121   std::vector<InterfaceMessage>      messages;
00122 
00123   std::string dir;
00124   std::string filename_cpp;
00125   std::string filename_h;
00126   std::string filename_o;
00127   std::string class_name;
00128   std::string deflector;
00129   std::string gendate;
00130   std::string author;
00131   std::string year;
00132   std::string creation_date;
00133   std::string data_comment;
00134 
00135   const unsigned char *hash;
00136   size_t hash_size;
00137 };
00138 
00139 
00140 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends