| 
									
										
										
										
											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 Method.h | 
					
						
							|  |  |  |  * @brief describes and generates code for methods | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							| 
									
										
										
										
											2012-07-13 06:28:28 +08:00
										 |  |  |  * @author Richard Roberts | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  | #include "StaticMethod.h"
 | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-03 00:43:15 +08:00
										 |  |  | namespace wrap { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 11:23:14 +08:00
										 |  |  | /// Method class
 | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  | class Method: public StaticMethod { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   bool is_const_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:34:33 +08:00
										 |  |  |   typedef const std::string& Str; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   /// Constructor creates empty object
 | 
					
						
							|  |  |  |   Method(bool verbose = true) : | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       StaticMethod(verbose), is_const_(false) { | 
					
						
							| 
									
										
										
										
											2014-11-13 03:51:47 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 08:12:43 +08:00
										 |  |  |   Method(const std::string& name, bool verbose = true) : | 
					
						
							|  |  |  |     StaticMethod(name,verbose), is_const_(false) { | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 06:21:05 +08:00
										 |  |  |   virtual bool isStatic() const { | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   virtual bool isConst() const { | 
					
						
							|  |  |  |     return is_const_; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // The first time this function is called, it initializes the class members
 | 
					
						
							|  |  |  |   // with those in rhs, but in subsequent calls it adds additional argument
 | 
					
						
							|  |  |  |   // lists as function overloads.
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:34:33 +08:00
										 |  |  |   void addOverload(bool verbose, bool is_const, Str name, | 
					
						
							| 
									
										
										
										
											2014-11-13 08:26:06 +08:00
										 |  |  |       const ArgumentList& args, const ReturnValue& retVal, | 
					
						
							|  |  |  |       const Qualified& instName = Qualified()); | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 04:11:29 +08:00
										 |  |  |   friend std::ostream& operator<<(std::ostream& os, const Method& m) { | 
					
						
							|  |  |  |     for (size_t i = 0; i < m.nrOverloads(); i++) | 
					
						
							|  |  |  |       os << m.returnVals_[i] << " " << m.name_ << m.argLists_[i]; | 
					
						
							|  |  |  |     return os; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-05 22:05:00 +08:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2014-11-13 08:26:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |   // Emit method header
 | 
					
						
							|  |  |  |   void proxy_header(FileWriter& proxyFile) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 00:34:33 +08:00
										 |  |  |   virtual std::string wrapper_call(FileWriter& wrapperFile, Str cppClassName, | 
					
						
							|  |  |  |       Str matlabUniqueName, const ArgumentList& args, | 
					
						
							|  |  |  |       const ReturnValue& returnVal, const TypeAttributesTable& typeAttributes, | 
					
						
							| 
									
										
										
										
											2014-11-14 00:28:05 +08:00
										 |  |  |       const Qualified& instName) const; | 
					
						
							| 
									
										
										
										
											2011-10-14 02:41:56 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-03 00:43:15 +08:00
										 |  |  | } // \namespace wrap
 | 
					
						
							|  |  |  | 
 |