Skip to content

Commit

Permalink
Return null/undefined if parameter not found
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Sep 28, 2023
1 parent 10106cd commit 978f518
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Source/Processors/Parameter/ParameterOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,27 @@ void ParameterOwner::addParameter(Parameter* p)
parameters.addParameter(p);
}

Parameter* ParameterOwner::getParameter(String name) const
{
if(parameters.contains(name))
return parameters[name];
else
return nullptr;
}

Array<String> ParameterOwner::getParameterNames() const
{
return parameters.getParameterNames();
}

var ParameterOwner::operator [](String name) const
{
if (parameters.contains(name))
return parameters[name]->getValue();
else
return var::undefined();
}


Array<ParameterEditor*> ParameterOwner::createDefaultEditor()
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Processors/Parameter/ParameterOwner.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PLUGIN_API ParameterOwner
void addParameter(Parameter* p);

/** Returns a pointer to a parameter with a given name**/
Parameter* getParameter(String name) const { return parameters[name]; }
Parameter* getParameter(String name) const;

/** Returns true if an object has a parameter with a given name**/
bool hasParameter(String name) const { return parameters.contains(name); }
Expand All @@ -87,7 +87,7 @@ class PLUGIN_API ParameterOwner
Array<String> getParameterNames() const;

/*Bracket operator returns the value of a parameter*/
var operator [](String name) const {return parameters[name]->getValue();}
var operator [](String name) const;

/** Copies parameters from another ParameterOwner and clears the original ParameterCollection*/
void copyParameters(ParameterOwner* object);
Expand Down

0 comments on commit 978f518

Please sign in to comment.