| 
									
										
										
										
											2016-09-09 19:26:11 +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 TemplateMethod.ccp | 
					
						
							|  |  |  |  * @author Duy-Nguyen Ta | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "TemplateMethod.h"
 | 
					
						
							| 
									
										
										
										
											2016-09-12 06:14:19 +08:00
										 |  |  | #include "Class.h"
 | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2016-09-09 19:26:11 +08:00
										 |  |  | using namespace std; | 
					
						
							|  |  |  | using namespace wrap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2016-09-12 06:14:19 +08:00
										 |  |  | void TemplateMethod::emit_cython_pxd(FileWriter& file, const Class& cls) const { | 
					
						
							| 
									
										
										
										
											2016-09-09 19:26:11 +08:00
										 |  |  |   for(size_t i = 0; i < nrOverloads(); ++i) { | 
					
						
							|  |  |  |     file.oss << "\t\t"; | 
					
						
							| 
									
										
										
										
											2016-09-12 06:14:19 +08:00
										 |  |  |     returnVals_[i].emit_cython_pxd(file, cls.cythonClass()); | 
					
						
							| 
									
										
										
										
											2016-09-09 19:26:11 +08:00
										 |  |  |     file.oss << name_ << "[" << argName << "]" << "("; | 
					
						
							| 
									
										
										
										
											2016-09-12 06:14:19 +08:00
										 |  |  |     argumentList(i).emit_cython_pxd(file, cls.cythonClass()); | 
					
						
							| 
									
										
										
										
											2016-09-09 19:26:11 +08:00
										 |  |  |     file.oss << ")\n"; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | bool TemplateMethod::addOverload(Str name, const ArgumentList& args, | 
					
						
							|  |  |  |     const ReturnValue& retVal, bool is_const, | 
					
						
							|  |  |  |     std::string _argName, bool verbose) { | 
					
						
							|  |  |  |   argName = _argName; | 
					
						
							|  |  |  |   bool first = MethodBase::addOverload(name, args, retVal, boost::none, verbose); | 
					
						
							|  |  |  |   if (first) | 
					
						
							|  |  |  |     is_const_ = is_const; | 
					
						
							|  |  |  |   else if (is_const && !is_const_) | 
					
						
							|  |  |  |     throw std::runtime_error( | 
					
						
							|  |  |  |         "Method::addOverload now designated as const whereas before it was not"); | 
					
						
							|  |  |  |   else if (!is_const && is_const_) | 
					
						
							|  |  |  |     throw std::runtime_error( | 
					
						
							|  |  |  |         "Method::addOverload now designated as non-const whereas before it was"); | 
					
						
							|  |  |  |   return first; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ |