docstr: Set the linked cpp attribute if possible
  
  Parameters
  ----------
  self : `object`
      the instance
  
  val : `object`
      the value to be set
  
  cpp_setter : `function`
      the function to use
docstr_tok: ["Set","the","linked","cpp","attribute","if","possible","Parameters","--","--","--","--","--","self",":","`","object","`","the","instance","val",":","`","object","`","the","value","to","be","set","cpp_setter",":","`","function","`","the","function","to","use"]
code: def set_cpp_attribute(self, val, cpp_setter):
      """Set the linked cpp attribute if possible
  
      Parameters
      ----------
      self : `object`
          the instance
  
      val : `object`
          the value to be set
  
      cpp_setter : `function`
          the function to use
      """
      # First we get the C++ object from its name (its name is an attribute
      # in the class)
      if not hasattr(self, "_cpp_obj_name"):
          raise NameError(
              "_cpp_obj_name must be set as class attribute to "
              "use automatic C++ setters"
          )
  
      # Retrieve C++ associated object if it has been instantiated
      cpp_obj = None
      if hasattr(self, self._cpp_obj_name):
          cpp_obj = getattr(self, self._cpp_obj_name)
  
      # If the cpp_obj is instantiated, we update it
      if cpp_obj is not None:
          # Get the setter for this attribute in the C++
          if not hasattr(cpp_obj, cpp_setter):
              raise NameError(
                  "%s is not a method of %s"
                  % (cpp_setter, cpp_obj.__class__)
              )
          cpp_obj_setter = getattr(cpp_obj, cpp_setter)
          cpp_obj_setter(val)
  
imports: import os
  import inspect
  from datetime import datetime
  from abc import ABCMeta
  import json
  import pydoc
  import numpy
  import numpydoc
  from numpydoc import docscrape
  import copy
label_desc: Use image node_id 2 for calling the BaseMeta obj's underlying member method code with example usage: obj.set_cpp_attribute(val, cpp_setter) without return types