INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

gen.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2008 Alex Makarenko
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef GEN_H
00012 #define GEN_H
00013 
00014 #include <Slice/Parser.h>
00015 #include <IceUtil/OutputUtil.h>
00016 #include <map>
00017 #include <vector>
00018 
00019 namespace slice2orca
00020 {
00021 
00022 class Gen : private ::IceUtil::noncopyable
00023 {
00024 public:
00025 
00026     Gen(const std::string&,
00027         const std::string&,
00028         const std::string&,
00029         const std::string&,
00030         const std::vector<std::string>&,
00031         const std::string&,
00032         const std::vector<std::string>&,
00033         const std::string&,
00034         const std::string&,
00035         bool,
00036         bool,
00037         bool,
00038         bool,
00039         // custom options
00040         const std::string& module,
00041         bool,
00042         bool);
00043     ~Gen();
00044 
00045     bool operator!() const; // Returns true if there was a constructor error
00046 
00047     void generate(const Slice::UnitPtr&);
00048     
00049     static bool setUseWstring(Slice::ContainedPtr, std::list<bool>&, bool);
00050     static bool resetUseWstring(std::list<bool>&);
00051 
00052 private:
00053 
00054     void writeExtraHeaders(::IceUtilInternal::Output&);
00055 
00056     ::IceUtilInternal::Output H;
00057     ::IceUtilInternal::Output C;
00058 
00059     std::string _base;
00060     std::string _headerExtension;
00061     std::string _sourceExtension;
00062     std::vector<std::string> _extraHeaders;
00063     std::string _include;
00064     std::vector<std::string> _includePaths;
00065     std::string _dllExport;
00066     bool _impl;
00067     bool _checksum;
00068     bool _stream;
00069     bool _ice;
00070     // custom options
00071     std::string _module;
00072     bool _util;
00073     bool _log;
00074 
00075     class GlobalIncludeVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00076     {
00077     public:
00078 
00079         GlobalIncludeVisitor(::IceUtilInternal::Output&);
00080 
00081         virtual bool visitModuleStart(const Slice::ModulePtr&);
00082 
00083     private:
00084 
00085         ::IceUtilInternal::Output& H;
00086 
00087         bool _finished;
00088     };
00089 
00090     class ToMetaDataVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00091     {
00092     public:
00093 
00094         ToMetaDataVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&);
00095 
00096 //         virtual bool visitClassDefStart(const Slice::ClassDefPtr&);
00097         virtual bool visitStructStart(const Slice::StructPtr&);
00098 
00099         // custom parameters
00100         std::string libDir_;
00101         std::string baseFilename_;
00102     private:
00103 
00104         ::IceUtilInternal::Output& H;
00105         ::IceUtilInternal::Output& C;
00106     };
00107 
00108     class ToStringVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00109     {
00110     public:
00111 
00112         ToStringVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool);
00113 
00114         virtual bool visitModuleStart(const Slice::ModulePtr&);
00115         virtual void visitModuleEnd(const Slice::ModulePtr&);
00116         virtual bool visitClassDefStart(const Slice::ClassDefPtr&);
00117         virtual void visitClassDefEnd(const Slice::ClassDefPtr&);
00118         virtual bool visitExceptionStart(const Slice::ExceptionPtr&);
00119         virtual void visitExceptionEnd(const Slice::ExceptionPtr&);
00120         virtual bool visitStructStart(const Slice::StructPtr&);
00121         virtual void visitStructEnd(const Slice::StructPtr&);
00122         virtual void visitSequence(const Slice::SequencePtr&);
00123         virtual void visitDictionary(const Slice::DictionaryPtr&);
00124         virtual void visitEnum(const Slice::EnumPtr&);
00125         virtual void visitConst(const Slice::ConstPtr&);
00126         virtual void visitDataMember(const Slice::DataMemberPtr&);
00127 
00128         // custom parameter
00129         std::string libNamespace_;
00130         std::string libDir_;
00131         std::string baseFilename_;
00132     private:
00133 
00134         void emitUpcall(const Slice::ExceptionPtr&, const std::string&, bool = false);
00135 
00136         ::IceUtilInternal::Output& H;
00137         ::IceUtilInternal::Output& C;
00138 
00139         std::string _dllExport;
00140         bool _stream;
00141         bool _doneStaticSymbol;
00142         bool _useWstring;
00143         std::list<bool> _useWstringHist;
00144     };
00145 
00146     class ToInitVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00147     {
00148     public:
00149 
00150         ToInitVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool);
00151 
00152         virtual bool visitModuleStart(const Slice::ModulePtr&);
00153         virtual void visitModuleEnd(const Slice::ModulePtr&);
00154         virtual bool visitClassDefStart(const Slice::ClassDefPtr&);
00155         virtual void visitClassDefEnd(const Slice::ClassDefPtr&);
00156         virtual bool visitExceptionStart(const Slice::ExceptionPtr&);
00157         virtual void visitExceptionEnd(const Slice::ExceptionPtr&);
00158         virtual bool visitStructStart(const Slice::StructPtr&);
00159         virtual void visitStructEnd(const Slice::StructPtr&);
00160         virtual void visitSequence(const Slice::SequencePtr&);
00161         virtual void visitDictionary(const Slice::DictionaryPtr&);
00162         virtual void visitEnum(const Slice::EnumPtr&);
00163         virtual void visitConst(const Slice::ConstPtr&);
00164         virtual void visitDataMember(const Slice::DataMemberPtr&);
00165 
00166         // alexm: the namespace of the generated library
00167         std::string libNamespace_;
00168     private:
00169 
00170         void emitUpcall(const Slice::ExceptionPtr&, const std::string&, bool = false);
00171 
00172         ::IceUtilInternal::Output& H;
00173         ::IceUtilInternal::Output& C;
00174 
00175         std::string _dllExport;
00176         bool _stream;
00177         bool _doneStaticSymbol;
00178         bool _useWstring;
00179         std::list<bool> _useWstringHist;
00180     };
00181 
00182     class ToLogVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00183     {
00184     public:
00185 
00186         ToLogVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool);
00187 
00188         virtual bool visitModuleStart(const Slice::ModulePtr&);
00189         virtual void visitModuleEnd(const Slice::ModulePtr&);
00190         virtual bool visitClassDefStart(const Slice::ClassDefPtr&);
00191         virtual void visitClassDefEnd(const Slice::ClassDefPtr&);
00192         virtual bool visitExceptionStart(const Slice::ExceptionPtr&);
00193         virtual void visitExceptionEnd(const Slice::ExceptionPtr&);
00194         virtual bool visitStructStart(const Slice::StructPtr&);
00195         virtual void visitStructEnd(const Slice::StructPtr&);
00196         virtual void visitSequence(const Slice::SequencePtr&);
00197         virtual void visitDictionary(const Slice::DictionaryPtr&);
00198         virtual void visitEnum(const Slice::EnumPtr&);
00199         virtual void visitConst(const Slice::ConstPtr&);
00200         virtual void visitDataMember(const Slice::DataMemberPtr&);
00201 
00202         // alexm: the namespace of the generated library
00203         std::string libNamespace_;
00204     private:
00205 
00206         void emitUpcall(const Slice::ExceptionPtr&, const std::string&, bool = false);
00207 
00208         ::IceUtilInternal::Output& H;
00209         ::IceUtilInternal::Output& C;
00210 
00211         std::string _dllExport;
00212         bool _stream;
00213         bool _doneStaticSymbol;
00214         bool _useWstring;
00215         std::list<bool> _useWstringHist;
00216     };
00217 
00218     class FromLogVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00219     {
00220     public:
00221 
00222         FromLogVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool);
00223 
00224         virtual bool visitModuleStart(const Slice::ModulePtr&);
00225         virtual void visitModuleEnd(const Slice::ModulePtr&);
00226         virtual bool visitClassDefStart(const Slice::ClassDefPtr&);
00227         virtual void visitClassDefEnd(const Slice::ClassDefPtr&);
00228         virtual bool visitExceptionStart(const Slice::ExceptionPtr&);
00229         virtual void visitExceptionEnd(const Slice::ExceptionPtr&);
00230         virtual bool visitStructStart(const Slice::StructPtr&);
00231         virtual void visitStructEnd(const Slice::StructPtr&);
00232         virtual void visitSequence(const Slice::SequencePtr&);
00233         virtual void visitDictionary(const Slice::DictionaryPtr&);
00234         virtual void visitEnum(const Slice::EnumPtr&);
00235         virtual void visitConst(const Slice::ConstPtr&);
00236         virtual void visitDataMember(const Slice::DataMemberPtr&);
00237 
00238         // alexm: the namespace of the generated library
00239         std::string libNamespace_;
00240     private:
00241 
00242         void emitUpcall(const Slice::ExceptionPtr&, const std::string&, bool = false);
00243 
00244         ::IceUtilInternal::Output& H;
00245         ::IceUtilInternal::Output& C;
00246 
00247         std::string _dllExport;
00248         bool _stream;
00249         bool _doneStaticSymbol;
00250         bool _useWstring;
00251         std::list<bool> _useWstringHist;
00252     };
00253 
00254     enum OutputType
00255     {
00256         OutputString,
00257         OutputInit,
00258         OutputToLog,
00259         OutputFromLog
00260     };
00261 
00262     class HandleVisitor : private ::IceUtil::noncopyable, public Slice::ParserVisitor
00263     {
00264     public:
00265 
00266         HandleVisitor(::IceUtilInternal::Output&, ::IceUtilInternal::Output&, const std::string&, bool, OutputType );
00267 
00268         virtual bool visitModuleStart(const Slice::ModulePtr&);
00269         virtual void visitModuleEnd(const Slice::ModulePtr&);
00270         virtual void visitClassDecl(const Slice::ClassDeclPtr&);
00271         virtual bool visitClassDefStart(const Slice::ClassDefPtr&);
00272 
00273         // alexm: the namespace of the generated library
00274         std::string libNamespace_;
00275     private:
00276 
00277         ::IceUtilInternal::Output& H;
00278         ::IceUtilInternal::Output& C;
00279 
00280         std::string _dllExport;
00281         bool _stream;
00282 
00283         // alexm: store inheritance information
00284         // e.g. Base <-- Derived <-- Super
00285         // as we go through derived classes we compile information for each base class
00286         // the map<string,vector<string> will contains the following
00287         // [B],<D,S>
00288         // [D],<S>
00289         typedef std::map<std::string,std::vector<std::string> > InheritanceMap;
00290         InheritanceMap inherit_;
00291 
00292         OutputType outputType_;
00293     };
00294 };
00295 
00296 }
00297 
00298 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5