Skip to content

Commit

Permalink
Add ensureIsActive
Browse files Browse the repository at this point in the history
  • Loading branch information
Schroedingers-Cat committed Jun 17, 2024
1 parent 8507079 commit fe1d73c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/clap/helpers/plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ namespace clap { namespace helpers {
// General Checks //
////////////////////
void ensureIsInactive(const char *methodName) const noexcept;
void ensureIsActive(const char *methodName) const noexcept;

///////////////
// Utilities //
Expand Down
13 changes: 13 additions & 0 deletions include/clap/helpers/plugin.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,19 @@ namespace clap { namespace helpers {
hostMisbehaving(msg.str());
}

template <MisbehaviourHandler h, CheckingLevel l>
void Plugin<h, l>::ensureIsActive(const char *methodName) const noexcept {
if (l == CheckingLevel::None)
return;

if (isActive())
return;

std::ostringstream msg;
msg << "it is illegal to call " << methodName << "() while the plugin is not active!";
hostMisbehaving(msg.str());
}

///////////////
// Utilities //
///////////////
Expand Down

0 comments on commit fe1d73c

Please sign in to comment.