template_instantiator/declaration.py
Go to the documentation of this file.
1 """Instantiate a forward declaration."""
2 
3 import gtwrap.interface_parser as parser
4 from gtwrap.template_instantiator.helpers import instantiate_name
5 
6 
7 class InstantiatedDeclaration(parser.ForwardDeclaration):
8  """
9  Instantiate typedefs of forward declarations.
10  This is useful when we wish to typedef a templated class
11  which is not defined in the current project.
12 
13  E.g.
14  class FactorFromAnotherMother;
15 
16  typedef FactorFromAnotherMother<gtsam::Pose3> FactorWeCanUse;
17  """
18  def __init__(self, original, instantiations=(), new_name=''):
19  super().__init__(original.typename,
20  original.parent_type,
21  original.is_virtual,
22  parent=original.parent)
23 
24  self.original = original
25  self.instantiations = instantiations
26  self.parent = original.parent
27 
29  original.name, instantiations) if not new_name else new_name
30 
31  def to_cpp(self):
32  """Generate the C++ code for wrapping."""
33  instantiated_names = [
34  inst.qualified_name() for inst in self.instantiations
35  ]
36  name = "{}<{}>".format(self.original.name,
37  ",".join(instantiated_names))
38  namespaces_name = self.namespaces()
39  namespaces_name.append(name)
40  # Leverage Typename to generate the fully qualified C++ name
41  return parser.Typename(namespaces_name).to_cpp()
42 
43  def __repr__(self):
44  return "Instantiated {}".format(
45  super(InstantiatedDeclaration, self).__repr__())
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:09