Getting a module's name or slug?

Hello! I could use some help. I’m trying to get a module’s slug from within a structure that inherits from “Module”, like so:


struct VoxglitchModule : Module
{
  VoxglitchModule()
  {
    std::string module_slug = {{ ???? }};

Although this is adjacent to my main question, it could be helpful to know that an actual module extends the Voxglitch module:

struct DigitalSequencer : VoxglitchModule
{

Thanks,
Bret

getModel()->slug

See VCV Rack API: rack::engine::Module Struct Reference

1 Like

Hmm… attempting to get the model from the base-class isn’t working.

plugin::Model *temp = getModel();
std::string slug = temp->slug; // this crashes

I did some troubleshooting, and it looks like getModel() is returning null:

plugin::Model *temp = getModel();

if(temp)
{
  std::string slug = temp->slug;  
}
else
{
  DEBUG("temp is false"); // this is output every time
}

I can work around this by moving the code outside of the classes constructor and into a new function, and calling that function from with the derived classes. No worries.