be_global.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_IDL_BE_GLOBAL_H
00009 #define OPENDDS_IDL_BE_GLOBAL_H
00010 
00011 #include "ace/SString.h"
00012 
00013 #include <string>
00014 #include <sstream>
00015 #include <set>
00016 
00017 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00018 # pragma once
00019 #endif /* ACE_LACKS_PRAGMA_ONCE */
00020 
00021 class AST_Generator;
00022 
00023 // Defines a class containing all back end global data.
00024 
00025 class BE_GlobalData {
00026 public:
00027   // = TITLE
00028   //    BE_GlobalData
00029   //
00030   // = DESCRIPTION
00031   //    Storage of global data specific to the compiler back end
00032   //
00033   BE_GlobalData();
00034 
00035   virtual ~BE_GlobalData();
00036 
00037   // Data accessors.
00038 
00039   const char* holding_scope_name() const;
00040 
00041   void destroy();
00042   // Cleanup function.
00043 
00044   const char* filename() const;
00045   void filename(const char* fname);
00046 
00047   //bool do_included_files() const;
00048 
00049   ACE_CString spawn_options();
00050   // Command line passed to ACE_Process::spawn. Different
00051   // implementations in IDL and IFR backends.
00052 
00053   void parse_args(long& i, char** av);
00054   // Parse args that affect the backend.
00055 
00056   void open_streams(const char* filename);
00057 
00058   std::ostringstream header_, impl_, idl_, ws_config_, itl_, facets_header_, facets_impl_,
00059     lang_header_;
00060   ACE_CString header_name_, impl_name_, idl_name_, ws_config_name_, itl_name_,
00061     facets_header_name_, facets_impl_name_, lang_header_name_,
00062     output_dir_, tao_inc_pre_;
00063 
00064   ///print message to all open streams
00065   void multicast(const char* message);
00066 
00067   enum stream_enum_t {
00068     STREAM_H, STREAM_CPP, STREAM_IDL, STREAM_WS, STREAM_ITL,
00069     STREAM_FACETS_H, STREAM_FACETS_CPP,
00070     STREAM_LANG_H
00071   };
00072 
00073   void reset_includes();
00074 
00075   void add_include(const char* file, stream_enum_t which = STREAM_H);
00076 
00077   /// Called to indicate that OpenDDS marshaling (serialization) code for the
00078   /// current file will depend on marshaling code generated for the indicated
00079   /// file.  For example, if the current file is A.idl and it contains a struct
00080   /// which has a field of type B, defined in B.idl, the full path to B.idl is
00081   /// passed to this function.
00082   void add_referenced(const char* file);
00083 
00084   void set_inc_paths(const char* cmdline);
00085   void add_inc_path(const char* path);
00086 
00087   std::string get_include_block(stream_enum_t which);
00088 
00089   ACE_CString export_macro() const;
00090   void export_macro(const ACE_CString& str);
00091 
00092   ACE_CString export_include() const;
00093   void export_include(const ACE_CString& str);
00094 
00095   ACE_CString versioning_name() const;
00096   void versioning_name(const ACE_CString& str);
00097 
00098   ACE_CString versioning_begin() const;
00099   void versioning_begin(const ACE_CString& str);
00100 
00101   ACE_CString versioning_end() const;
00102   void versioning_end(const ACE_CString& str);
00103 
00104   ACE_CString pch_include() const;
00105   void pch_include(const ACE_CString& str);
00106 
00107   bool java() const;
00108   void java(bool b);
00109 
00110   bool v8() const;
00111   void v8(bool b);
00112 
00113   bool face_ts() const;
00114   void face_ts(bool b);
00115 
00116   ACE_CString java_arg() const;
00117   void java_arg(const ACE_CString& str);
00118 
00119   enum LanguageMapping {
00120     LANGMAP_NONE, ///< Don't generate, let tao_idl handle it
00121     LANGMAP_FACE_CXX, ///< Generate C++ language mapping from FACE spec
00122     LANGMAP_SP_CXX ///< Generate C++ language mapping for Safety Profile
00123   };
00124 
00125   LanguageMapping language_mapping() const;
00126   void language_mapping(LanguageMapping lm);
00127 
00128   ACE_CString sequence_suffix() const;
00129   void sequence_suffix(const ACE_CString& str);
00130 
00131   bool suppress_idl() const { return suppress_idl_; }
00132   bool suppress_typecode() const { return suppress_typecode_; }
00133 
00134   bool generate_wireshark() const { return generate_wireshark_; }
00135   bool generate_itl() const { return generate_itl_; }
00136 
00137   static bool writeFile(const char* fileName, const std::string &content);
00138 
00139 private:
00140   const char* filename_;
00141   // Name of the IDL file we are processing.
00142 
00143   bool java_, suppress_idl_, suppress_typecode_,
00144     generate_wireshark_, generate_itl_, v8_, face_ts_;
00145 
00146   ACE_CString export_macro_, export_include_, versioning_name_, versioning_begin_, versioning_end_, pch_include_, java_arg_, seq_;
00147 
00148   LanguageMapping language_mapping_;
00149 };
00150 
00151 class BE_Comment_Guard {
00152 public:
00153 
00154   BE_Comment_Guard(const char* type, const char* name);
00155   ~BE_Comment_Guard();
00156 
00157 private:
00158   const char *type_, *name_;
00159 };
00160 
00161 #endif /* OPENDDS_IDL_BE_GLOBAL_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1