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 Class . h
* @ brief describe the C + + class that is being wrapped
* @ author Frank Dellaert
2012-06-27 02:52:27 +08:00
* @ author Andrew Melim
2012-07-13 06:28:28 +08:00
* @ author Richard Roberts
2011-10-14 02:41:56 +08:00
* */
# pragma once
# include <string>
2012-07-05 22:05:00 +08:00
# include <map>
2011-10-14 02:41:56 +08:00
# include "Constructor.h"
2012-03-30 13:34:23 +08:00
# include "Deconstructor.h"
2011-10-14 02:41:56 +08:00
# include "Method.h"
2011-12-02 10:32:18 +08:00
# include "StaticMethod.h"
2012-07-13 06:28:28 +08:00
# include "TypeAttributesTable.h"
2012-08-29 05:44:45 +08:00
# include <boost/algorithm/string.hpp>
2011-10-14 02:41:56 +08:00
2011-12-03 00:43:15 +08:00
namespace wrap {
2011-10-14 12:43:06 +08:00
/// Class has name, constructors, methods
2011-10-14 02:41:56 +08:00
struct Class {
2012-10-02 22:40:07 +08:00
typedef std : : map < std : : string , Method > Methods ;
typedef std : : map < std : : string , StaticMethod > StaticMethods ;
2012-07-05 22:05:00 +08:00
2011-10-14 12:43:06 +08:00
/// Constructor creates an empty class
2013-06-20 01:50:05 +08:00
Class ( bool verbose = true ) : isVirtual ( false ) , isSerializable ( false ) , hasSerialization ( false ) , verbose_ ( verbose ) { }
2011-10-14 02:41:56 +08:00
2012-10-02 22:40:07 +08:00
// Then the instance variables are set directly by the Module constructor
2011-12-09 23:44:35 +08:00
std : : string name ; ///< Class name
2012-10-02 22:40:07 +08:00
std : : vector < std : : string > templateArgs ; ///< Template arguments
std : : string typedefName ; ///< The name to typedef *from*, if this class is actually a typedef, i.e. typedef [typedefName] [name]
bool isVirtual ; ///< Whether the class is part of a virtual inheritance chain
2013-06-20 01:50:05 +08:00
bool isSerializable ; ///< Whether we can use boost.serialization to serialize the class - creates exports
bool hasSerialization ; ///< Whether we should create the serialization functions
2012-10-02 22:40:07 +08:00
std : : vector < std : : string > qualifiedParent ; ///< The *single* parent - the last string is the parent class name, preceededing elements are a namespace stack
2012-07-05 22:05:00 +08:00
Methods methods ; ///< Class methods
StaticMethods static_methods ; ///< Static methods
2011-12-09 23:44:35 +08:00
std : : vector < std : : string > namespaces ; ///< Stack of namespaces
2012-07-05 22:04:36 +08:00
Constructor constructor ; ///< Class constructors
2012-10-02 22:40:07 +08:00
Deconstructor deconstructor ; ///< Deconstructor to deallocate C++ object
2011-12-09 23:44:35 +08:00
bool verbose_ ; ///< verbose flag
2011-10-14 12:43:06 +08:00
// And finally MATLAB code is emitted, methods below called by Module::matlab_code
2012-07-18 23:47:06 +08:00
void matlab_proxy ( const std : : string & toolboxPath , const std : : string & wrapperName , const TypeAttributesTable & typeAttributes ,
2012-10-02 22:40:07 +08:00
FileWriter & wrapperFile , std : : vector < std : : string > & functionNames ) const ; ///< emit proxy class
2013-06-20 01:49:57 +08:00
2011-12-09 04:51:13 +08:00
std : : string qualifiedName ( const std : : string & delim = " " ) const ; ///< creates a namespace-qualified name, optional delimiter
2012-07-05 22:04:57 +08:00
2012-10-02 22:40:07 +08:00
std : : vector < Class > expandTemplate ( const std : : string & templateArg , const std : : vector < std : : vector < std : : string > > & instantiations ) const ;
2013-06-20 01:49:57 +08:00
2012-10-02 22:40:07 +08:00
Class expandTemplate ( const std : : string & templateArg , const std : : vector < std : : string > & instantiation , const std : : vector < std : : string > & expandedClassNamespace , const std : : string & expandedClassName ) const ;
2012-07-12 05:43:16 +08:00
2012-10-02 22:40:07 +08:00
// The typedef line for this class, if this class is a typedef, otherwise returns an empty string.
std : : string getTypedef ( ) const ;
2012-07-12 05:43:16 +08:00
2013-06-20 01:50:03 +08:00
// Returns the string for an export flag
std : : string getSerializationExport ( ) const ;
2013-06-20 01:49:59 +08:00
// Creates a member function that performs serialization
2013-06-20 01:50:00 +08:00
void serialization_fragments ( FileWriter & proxyFile , FileWriter & wrapperFile ,
const std : : string & wrapperName , std : : vector < std : : string > & functionNames ) const ;
2012-08-26 23:46:19 +08:00
2013-06-20 01:49:59 +08:00
// Creates a static member function that performs deserialization
2013-06-20 01:50:00 +08:00
void deserialization_fragments ( FileWriter & proxyFile , FileWriter & wrapperFile ,
const std : : string & wrapperName , std : : vector < std : : string > & functionNames ) const ;
2013-06-20 01:49:59 +08:00
2012-07-05 22:04:57 +08:00
private :
2012-10-02 22:40:07 +08:00
void pointer_constructor_fragments ( FileWriter & proxyFile , FileWriter & wrapperFile , const std : : string & wrapperName , std : : vector < std : : string > & functionNames ) const ;
2012-08-26 23:46:19 +08:00
void comment_fragment ( FileWriter & proxyFile ) const ;
2011-10-14 02:41:56 +08:00
} ;
2011-12-03 00:43:15 +08:00
} // \namespace wrap