Skip to content

Commit

Permalink
Add ParameterOwner class to handle parameters
Browse files Browse the repository at this point in the history
Move parameter storage, access, and handling functionality from InfoObject to the ParameterOwner class.
  • Loading branch information
anjaldoshi committed Jul 21, 2023
1 parent e8c98b8 commit d0bf33c
Show file tree
Hide file tree
Showing 23 changed files with 486 additions and 312 deletions.
2 changes: 1 addition & 1 deletion Plugins/BasicSpikeDisplay/SpikeDetector/SpikeDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void SpikeDetector::parameterValueChanged(Parameter* p)
{
if (p->getName().equalsIgnoreCase("name"))
{
p->getOwner()->setName(p->getValueAsString());
((SpikeChannel*)p->getOwner())->setName(p->getValueAsString());

CoreServices::updateSignalChain(getEditor());

Expand Down
40 changes: 21 additions & 19 deletions Source/Processors/GenericProcessor/GenericProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const String GenericProcessor::m_unusedNameString("xxx-UNUSED-OPEN-EPHYS-xxx");

GenericProcessor::GenericProcessor(const String& name, bool headlessMode_)
: GenericProcessorBase(name)
, InfoObject(InfoObject::Type::PROCESSOR_INFO)
, ParameterOwner(ParameterOwner::Type::OTHER)
, headlessMode(headlessMode_)
, sourceNode(nullptr)
, destNode(nullptr)
Expand Down Expand Up @@ -176,7 +176,7 @@ void GenericProcessor::addBooleanParameter(
{

BooleanParameter* p = new BooleanParameter(
this,
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand All @@ -201,7 +201,7 @@ void GenericProcessor::addCategoricalParameter(
{

CategoricalParameter* p = new CategoricalParameter(
this,
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand All @@ -228,7 +228,8 @@ void GenericProcessor::addIntParameter(
{

IntParameter* p =
new IntParameter(this,
new IntParameter(
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand All @@ -254,7 +255,8 @@ void GenericProcessor::addStringParameter(
bool deactivateDuringAcquisition)
{
StringParameter* p =
new StringParameter(this,
new StringParameter(
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand Down Expand Up @@ -282,7 +284,8 @@ void GenericProcessor::addFloatParameter(
{

FloatParameter* p =
new FloatParameter(this,
new FloatParameter(
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand Down Expand Up @@ -312,7 +315,8 @@ void GenericProcessor::addMaskChannelsParameter(
Array<var> defaultValue;

MaskChannelsParameter* p =
new MaskChannelsParameter(this,
new MaskChannelsParameter(
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand All @@ -339,7 +343,8 @@ void GenericProcessor::addSelectedChannelsParameter(
Array<var> defaultValue;

SelectedChannelsParameter* p =
new SelectedChannelsParameter(this,
new SelectedChannelsParameter(
scope == Parameter::PROCESSOR_SCOPE ? this : nullptr,
scope,
name,
displayName,
Expand Down Expand Up @@ -411,11 +416,6 @@ void GenericProcessor::setSourceNode(GenericProcessor* sn)
else
{
sourceNode = sn;
if(sourceNode != nullptr)
{
setSourceNodeId(sourceNode->getNodeId());
setSourceNodeName(sourceNode->getName());
}
}
}

Expand Down Expand Up @@ -782,7 +782,6 @@ int GenericProcessor::copyDataStreamSettings(const DataStream* stream, int conti
void GenericProcessor::updateDisplayName(String name)
{
m_name = name;
InfoObject::setName(name);
}


Expand Down Expand Up @@ -920,15 +919,15 @@ void GenericProcessor::update()
{
SelectedChannelsParameter* p = (SelectedChannelsParameter*)param;
SelectedChannelsParameter* p2 = new SelectedChannelsParameter(*p);
p2->setChannelCount(stream->getChannelCount());
stream->addParameter(p2);
p2->setChannelCount(stream->getChannelCount());
}
else if (param->getType() == Parameter::MASK_CHANNELS_PARAM)
{
MaskChannelsParameter* p = (MaskChannelsParameter*)param;
MaskChannelsParameter* p2 = new MaskChannelsParameter(*p);
p2->setChannelCount(stream->getChannelCount());
stream->addParameter(p2);
p2->setChannelCount(stream->getChannelCount());
}
}
}
Expand All @@ -940,12 +939,13 @@ void GenericProcessor::update()
{
SelectedChannelsParameter* p = (SelectedChannelsParameter*) stream->getParameter(param->getName());
p->setChannelCount(stream->getChannelCount());
//LOGD("GenericProcessor::update() Setting SelectedChannelsParameter channel count for ", stream->getStreamId(), " to ", stream->getChannelCount(), " channels");
LOGD("GenericProcessor::update() Setting SelectedChannelsParameter channel count for ", stream->getStreamId(), " to ", stream->getChannelCount(), " channels");

} else if (param->getType() == Parameter::MASK_CHANNELS_PARAM)
{
MaskChannelsParameter* p = (MaskChannelsParameter*) stream->getParameter(param->getName());
p->setChannelCount(stream->getChannelCount());
LOGD("GenericProcessor::update() Setting MaskChannelsParameter channel count for ", stream->getStreamId(), " to ", stream->getChannelCount(), " channels");

}
}
Expand All @@ -960,9 +960,9 @@ void GenericProcessor::update()

if (index > -1)
{
//LOGD("GenericProcessor::update() Copying savedDataStreamParameters for ", stream->getStreamId());
LOGD("GenericProcessor::update() Copying savedDataStreamParameters for ", stream->getStreamId());

//std::cout << "COPYING STREAM PARAMETERS TO" << std::endl;
std::cout << "COPYING STREAM PARAMETERS TO" << std::endl;
savedDataStreamParameters[index]->copyParametersTo(stream);
savedDataStreamParameters.remove(index);
}
Expand Down Expand Up @@ -1749,13 +1749,15 @@ void GenericProcessor::loadFromXml()
SelectedChannelsParameter* p = (SelectedChannelsParameter*)parameter;

SelectedChannelsParameter* p2 = new SelectedChannelsParameter(*p);
p2->setChannelCount(parameterCollection->owner.channel_count);
p2->fromXml(streamParams);
parameterCollection->addParameter(p2);
}
else if (parameter->getType() == Parameter::MASK_CHANNELS_PARAM)
{
MaskChannelsParameter* p = (MaskChannelsParameter*)parameter;
MaskChannelsParameter* p2 = new MaskChannelsParameter(*p);
p2->setChannelCount(parameterCollection->owner.channel_count);
p2->fromXml(streamParams);
parameterCollection->addParameter(p2);
}
Expand Down
11 changes: 6 additions & 5 deletions Source/Processors/GenericProcessor/GenericProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "GenericProcessorBase.h"

#include "../Parameter/Parameter.h"
#include "../Parameter/ParameterOwner.h"
#include "../../CoreServices.h"
#include "../PluginManager/PluginClass.h"
#include "../../Processors/Dsp/LinearSmoothedValueAtomic.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ class GenericProcessorBase;
class GenericEditor;

class ConfigurationObject;
class InfoObject;
class ParameterOwner;
class DeviceInfo;

class Spike;
Expand All @@ -82,7 +83,7 @@ namespace AccessClass
*/
class PLUGIN_API GenericProcessor : public GenericProcessorBase
, public PluginClass
, public InfoObject
, public ParameterOwner
{
friend AccessClass::ExternalProcessorAccessor;
friend class RecordEngine;
Expand Down Expand Up @@ -266,9 +267,9 @@ class PLUGIN_API GenericProcessor : public GenericProcessorBase
// PARAMETERS
// --------------------------------------------

using InfoObject::addParameter;
using InfoObject::getParameter;
using InfoObject::getParameters;
using ParameterOwner::addParameter;
using ParameterOwner::getParameter;
using ParameterOwner::getParameters;

/** Adds a boolean parameter, which will later be accessed by name*/
void addBooleanParameter(Parameter::ParameterScope scope,
Expand Down
2 changes: 2 additions & 0 deletions Source/Processors/Parameter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ add_sources(open-ephys
ParameterCollection.cpp
ParameterCollection.h
ParameterHelpers.h
ParameterOwner.cpp
ParameterOwner.h
)

#add nested directories
Expand Down
Loading

0 comments on commit d0bf33c

Please sign in to comment.