| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation,  | 
					
						
							|  |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2011-10-14 11:23:14 +08:00
										 |  |  |  * @file Module.h | 
					
						
							|  |  |  |  * @brief describes module to be wrapped | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							| 
									
										
										
										
											2012-07-13 06:28:28 +08:00
										 |  |  |  * @author Richard Roberts | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Class.h"
 | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | #include "GlobalFunction.h"
 | 
					
						
							| 
									
										
										
										
											2012-07-13 06:28:28 +08:00
										 |  |  | #include "TemplateInstantiationTypedef.h"
 | 
					
						
							|  |  |  | #include "ForwardDeclaration.h"
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-29 23:13:02 +08:00
										 |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <map>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-03 00:43:15 +08:00
										 |  |  | namespace wrap { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 12:43:06 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * A module just has a name and a list of classes | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | struct Module { | 
					
						
							| 
									
										
										
										
											2012-07-10 04:19:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   typedef std::map<std::string, GlobalFunction> GlobalFunctions; | 
					
						
							| 
									
										
										
										
											2012-07-23 22:09:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   // Filled during parsing:
 | 
					
						
							|  |  |  |   std::string name; ///< module name
 | 
					
						
							|  |  |  |   bool verbose; ///< verbose flag
 | 
					
						
							| 
									
										
										
										
											2011-12-07 11:05:33 +08:00
										 |  |  |   std::vector<Class> classes; ///< list of classes
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   std::vector<TemplateInstantiationTypedef> templateInstantiationTypedefs; ///< list of template instantiations
 | 
					
						
							| 
									
										
										
										
											2012-07-10 04:19:37 +08:00
										 |  |  |   std::vector<ForwardDeclaration> forward_declarations; | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   std::vector<std::string> includes; ///< Include statements
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   GlobalFunctions global_functions; | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   // After parsing:
 | 
					
						
							|  |  |  |   std::vector<Class> expandedClasses; | 
					
						
							|  |  |  |   bool hasSerialiable; | 
					
						
							|  |  |  |   TypeAttributesTable typeAttributes; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 12:43:06 +08:00
										 |  |  |   /// constructor that parses interface file
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   Module(const std::string& interfacePath, const std::string& moduleName, | 
					
						
							|  |  |  |       bool enable_verbose = true); | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  |   /// Dummy constructor that does no parsing - use only for testing
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   Module(const std::string& moduleName, bool enable_verbose = true); | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   /// non-const function that performs parsing - typically called by constructor
 | 
					
						
							|  |  |  |   /// Throws exception on failure
 | 
					
						
							|  |  |  |   void parseMarkup(const std::string& data); | 
					
						
							| 
									
										
										
										
											2012-07-05 22:04:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   /// MATLAB code generation:
 | 
					
						
							|  |  |  |   void matlab_code(const std::string& path) const; | 
					
						
							| 
									
										
										
										
											2012-07-11 22:54:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   void generateIncludes(FileWriter& file) const; | 
					
						
							| 
									
										
										
										
											2012-07-12 10:11:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   void finish_wrapper(FileWriter& file, | 
					
						
							|  |  |  |       const std::vector<std::string>& functionNames) const; | 
					
						
							| 
									
										
										
										
											2012-11-28 03:03:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-15 00:47:25 +08:00
										 |  |  |   /// Python code generation:
 | 
					
						
							|  |  |  |   void python_wrapper(const std::string& path) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-12 10:11:29 +08:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2014-11-15 00:04:45 +08:00
										 |  |  |   static std::vector<Class> ExpandTypedefInstantiations( | 
					
						
							|  |  |  |       const std::vector<Class>& classes, | 
					
						
							|  |  |  |       const std::vector<TemplateInstantiationTypedef> instantiations); | 
					
						
							|  |  |  |   static std::vector<std::string> GenerateValidTypes( | 
					
						
							|  |  |  |       const std::vector<Class>& classes, | 
					
						
							|  |  |  |       const std::vector<ForwardDeclaration> forwardDeclarations); | 
					
						
							|  |  |  |   static void WriteCollectorsAndCleanupFcn(FileWriter& wrapperFile, | 
					
						
							|  |  |  |       const std::string& moduleName, const std::vector<Class>& classes); | 
					
						
							|  |  |  |   static void WriteRTTIRegistry(FileWriter& wrapperFile, | 
					
						
							|  |  |  |       const std::string& moduleName, const std::vector<Class>& classes); | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-03 00:43:15 +08:00
										 |  |  | } // \namespace wrap
 |