| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file serialization.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @brief Global functions for performing serialization, designed for use with matlab | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * @date Jun 12, 2013 | 
					
						
							|  |  |  |  * @author Alex Cunningham | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <gtsam/nonlinear/NonlinearFactorGraph.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Serialize/Deserialize a NonlinearFactorGraph
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | std::string serializeGraph(const NonlinearFactorGraph& graph); | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | NonlinearFactorGraph::shared_ptr deserializeGraph(const std::string& serialized_graph); | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | std::string serializeGraphXML(const NonlinearFactorGraph& graph, | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  |     const std::string& name = "graph"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | NonlinearFactorGraph::shared_ptr deserializeGraphXML(const std::string& serialized_graph, | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  |     const std::string& name = "graph"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Serialize/Deserialize a Values
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | std::string serializeValues(const Values& values); | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | Values::shared_ptr deserializeValues(const std::string& serialized_values); | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | std::string serializeValuesXML(const Values& values, const std::string& name = "values"); | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | Values::shared_ptr deserializeValuesXML(const std::string& serialized_values, | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  |     const std::string& name = "values"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-13 22:29:31 +08:00
										 |  |  | // Serialize to/from files
 | 
					
						
							|  |  |  | // serialize functions return true if successful
 | 
					
						
							|  |  |  | // Filename arguments include path
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Serialize
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | bool serializeGraphToFile(const NonlinearFactorGraph& graph, const std::string& fname); | 
					
						
							|  |  |  | bool serializeGraphToXMLFile(const NonlinearFactorGraph& graph, | 
					
						
							| 
									
										
										
										
											2013-06-13 22:29:31 +08:00
										 |  |  |     const std::string& fname, const std::string& name = "graph"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | bool serializeValuesToFile(const Values& values, const std::string& fname); | 
					
						
							|  |  |  | bool serializeValuesToXMLFile(const Values& values, | 
					
						
							| 
									
										
										
										
											2013-06-13 22:29:31 +08:00
										 |  |  |     const std::string& fname, const std::string& name = "values"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Deserialize
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | NonlinearFactorGraph::shared_ptr deserializeGraphFromFile(const std::string& fname); | 
					
						
							|  |  |  | NonlinearFactorGraph::shared_ptr deserializeGraphFromXMLFile(const std::string& fname, | 
					
						
							| 
									
										
										
										
											2013-06-13 22:29:31 +08:00
										 |  |  |     const std::string& name = "graph"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-21 01:08:30 +08:00
										 |  |  | Values::shared_ptr deserializeValuesFromFile(const std::string& fname); | 
					
						
							|  |  |  | Values::shared_ptr deserializeValuesFromXMLFile(const std::string& fname, | 
					
						
							| 
									
										
										
										
											2013-06-13 22:29:31 +08:00
										 |  |  |     const std::string& name = "values"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-13 03:30:20 +08:00
										 |  |  | } // \namespace gtsam
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |