| 
									
										
										
										
											2014-11-13 19:52:01 +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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * @file Function.h | 
					
						
							|  |  |  |  * @brief Base class for global functions and methods | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							|  |  |  |  * @date Nov 13, 2014 | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Argument.h"
 | 
					
						
							| 
									
										
										
										
											2014-11-30 17:38:24 +08:00
										 |  |  | #include <boost/optional.hpp>
 | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace wrap { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// Function class
 | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  | class Function { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   std::string name_; ///< name of method
 | 
					
						
							| 
									
										
										
										
											2014-11-30 17:38:24 +08:00
										 |  |  |   boost::optional<Qualified> templateArgValue_; ///< value of template argument if applicable
 | 
					
						
							| 
									
										
										
										
											2014-11-14 23:43:53 +08:00
										 |  |  |   bool verbose_; | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 23:43:53 +08:00
										 |  |  |   /**
 | 
					
						
							|  |  |  |    * @brief first time, fill in instance variables, otherwise check if same | 
					
						
							|  |  |  |    * @return true if first time, false thereafter | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2014-12-01 16:48:56 +08:00
										 |  |  |   bool initializeOrCheck(const std::string& name, | 
					
						
							|  |  |  |       boost::optional<const Qualified> instName = boost::none, bool verbose = | 
					
						
							|  |  |  |           false); | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   std::string name() const { | 
					
						
							|  |  |  |     return name_; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-30 03:59:38 +08:00
										 |  |  |   /// Only Methods are non-static
 | 
					
						
							|  |  |  |   virtual bool isStatic() const { | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   std::string matlabName() const { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:38:24 +08:00
										 |  |  |     if (templateArgValue_) | 
					
						
							| 
									
										
										
										
											2014-12-01 16:48:56 +08:00
										 |  |  |       return name_ + templateArgValue_->name(); | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2014-12-01 16:48:56 +08:00
										 |  |  |       return name_; | 
					
						
							| 
									
										
										
										
											2014-11-14 05:43:29 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-11-30 03:53:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /// Emit function call to MATLAB (no argument checking)
 | 
					
						
							|  |  |  |   void emit_call(FileWriter& proxyFile, const ReturnValue& returnVal, | 
					
						
							| 
									
										
										
										
											2014-11-30 03:59:38 +08:00
										 |  |  |       const std::string& wrapperName, int id) const; | 
					
						
							| 
									
										
										
										
											2014-11-30 03:53:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /// Emit checking arguments and function call to MATLAB
 | 
					
						
							|  |  |  |   void emit_conditional_call(FileWriter& proxyFile, | 
					
						
							|  |  |  |       const ReturnValue& returnVal, const ArgumentList& args, | 
					
						
							| 
									
										
										
										
											2014-11-30 03:59:38 +08:00
										 |  |  |       const std::string& wrapperName, int id) const; | 
					
						
							| 
									
										
										
										
											2014-11-30 03:53:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-13 19:52:01 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // \namespace wrap
 | 
					
						
							|  |  |  | 
 |