Template Function Karana::Core::addToDSMethod

Template Function Karana::Core::addToDSMethod#

Function Documentation#

template<class PyClass>
void Karana::Core::addToDSMethod(auto &cls, std::string_view class_name, const std::string ds_module_name, const std::string ds_class_name, const std::string ds_class_method)#

Add a toDS method to the given class.

You MUST call the ADD_TO_DS_METHOD_CASTER before calling this.

To provide some extra information for the parameters below. Suppose we have a class called MyClass and an associated DataStruct class located at MyPackage.MyModule.MyClassDS. This class has a method called fromMyClass that creates a MyClassDS instance from a MyClass instance, then the params below will be: class_name - MyClass ds_module_name - MyPackage.MyModule ds_class_name - MyClassDS ds_class_method - toMyClass

Parameters:
  • The – pybind11::class_ to add the toDS method to.

  • class_name – The name of the class in Python.

  • ds_module_name – The full name of the module that contains the associated DataStruct for the Python class.

  • ds_class_name – The name of the associated DataStruct class in Python.

  • ds_class_method – The name of the method on the DataStruct class that takes in an instance of the class and creates a DataStruct class from it.