Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
StimulusGroup now uses StandardComponentFactory. Allow (but by defaul…
Browse files Browse the repository at this point in the history
…t ignore) "full_name" parameter on all components.
  • Loading branch information
cstawarz committed Mar 28, 2011
1 parent e66c252 commit 68da2de
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Core/ComponentRegistries/ComponentRegistry.cpp
Expand Up @@ -127,7 +127,7 @@ ComponentRegistry::ComponentRegistry() :
registerFactory<StandardStimulusFactory, BlankScreen>();
registerFactory("stimulus/image_file", new ImageStimulusFactory());
registerFactory("stimulus/fixation_point", new FixationPointFactory());
registerFactory("stimulus_group", new StimulusGroup());
registerFactory<StandardComponentFactory, StimulusGroup>();

// sounds
registerFactory("sound/wav_file", new WavFileSoundFactory());
Expand Down
21 changes: 20 additions & 1 deletion Core/PluginServices/ComponentFactory.cpp
Expand Up @@ -16,6 +16,25 @@
BEGIN_NAMESPACE_MW


bool ComponentFactory::shouldIgnoreParameter(const std::string &name) {
return (
//
// Parameters added by the parser
//
(name == "reference_id") ||
(name == "type") ||
(name == "variable_assignment") ||
(name == "working_path") ||
(name == "xml_document_path") ||

//
// Generic, currently-unused parameters that appear in many old experiments
//
(name == "full_name")
);
}


void ComponentFactory::processParameters(StdStringMap &parameters, ComponentRegistryPtr reg, ParameterValueMap &values)
{
requireAttributes(parameters, info.getRequiredParameters(), true);
Expand All @@ -26,7 +45,7 @@ void ComponentFactory::processParameters(StdStringMap &parameters, ComponentRegi
const std::string &name = (*param).first;
ParameterInfoMap::const_iterator iter = infoMap.find(name);

if ((iter == infoMap.end()) && !isInternalParameter(name)) {
if ((iter == infoMap.end()) && !shouldIgnoreParameter(name)) {
throw UnknownAttributeException(name);
}

Expand Down
9 changes: 1 addition & 8 deletions Core/PluginServices/ComponentFactory.h
Expand Up @@ -70,14 +70,7 @@ class ComponentFactory {
}

protected:
static bool isInternalParameter(const std::string &name) {
// Identify parameters added by the parser
return ((name == "reference_id") ||
(name == "type") ||
(name == "variable_assignment") ||
(name == "working_path") ||
(name == "xml_document_path"));
}
static bool shouldIgnoreParameter(const std::string &name);

void processParameters(StdStringMap &parameters, ComponentRegistry *reg, Map<ParameterValue> &values);
void requireAttributes(StdStringMap &parameters, const StdStringVector &attributes, bool useDefaults = false);
Expand Down
54 changes: 37 additions & 17 deletions Core/Stimuli/Stimulus.cpp
Expand Up @@ -18,14 +18,24 @@
#include "OpenGLContextManager.h"

#include "ComponentRegistry.h"
using namespace mw;


BEGIN_NAMESPACE_MW


#define VERBOSE_STIMULI 0


StimulusGroup::StimulusGroup(){}
StimulusGroup::StimulusGroup(const std::string &_tag) : mw::Component(_tag) {}
StimulusGroup::~StimulusGroup(){}
void StimulusGroup::describeComponent(ComponentInfo &info) {
info.setSignature("stimulus_group");
info.addParameter("tag");
}


StimulusGroup::StimulusGroup(const ParameterValueMap &parameters) :
mw::Component(parameters["tag"].getValue())
{ }


void StimulusGroup::addSubGroup(const shared_ptr <StimulusGroup> stim_group) {
sub_groups.push_back(stim_group);
Expand Down Expand Up @@ -154,18 +164,6 @@ void StimulusGroup::addChild(std::map<std::string, std::string> parameters,
}


shared_ptr<mw::Component> StimulusGroup::createObject(std::map<std::string, std::string> parameters,
ComponentRegistry *reg) {
REQUIRE_ATTRIBUTES(parameters, "tag");

string tagname(parameters.find("tag")->second);
// TODO: this is still not 100% clean
shared_ptr<StimulusGroup> newStimulusGroup = shared_ptr<StimulusGroup>(new StimulusGroup(tagname));

return newStimulusGroup;
}


void Stimulus::describeComponent(ComponentInfo &info) {
info.addParameter("tag");
info.addParameter("deferred", "no");
Expand Down Expand Up @@ -389,7 +387,29 @@ Datum Stimulus::getCurrentAnnounceDrawData() {
return (announceData);
}*/


END_NAMESPACE_MW
























12 changes: 5 additions & 7 deletions Core/Stimuli/Stimulus.h
Expand Up @@ -227,7 +227,7 @@ class Stimulus : public Announcable, public mw::Component, public FreezableColle
* StimulusGroup provides a simple mechanism for creating groups of stimuli
* as an organizational convenience. Its use is not necessary
*/
class StimulusGroup : public ExpandableList<Stimulus>, public mw::Component, public ComponentFactory {
class StimulusGroup : public ExpandableList<Stimulus>, public mw::Component {
private:
std::vector <shared_ptr<StimulusGroup> > sub_groups;

Expand All @@ -237,9 +237,10 @@ class StimulusGroup : public ExpandableList<Stimulus>, public mw::Component, pub
void addStimToParents(const shared_ptr <Stimulus> stim);

public:
StimulusGroup();
StimulusGroup(const std::string &_tag);
virtual ~StimulusGroup();
static void describeComponent(ComponentInfo &info);

explicit StimulusGroup(const Map<ParameterValue> &parameters);
virtual ~StimulusGroup() { }

unsigned int dimensionSize(const unsigned int dimension);
unsigned int getNDimensions() const;
Expand All @@ -249,9 +250,6 @@ class StimulusGroup : public ExpandableList<Stimulus>, public mw::Component, pub

void setParent(weak_ptr <StimulusGroup> _parent);

virtual shared_ptr<mw::Component> createObject(std::map<std::string, std::string> parameters,
ComponentRegistry *reg);

virtual void addChild(std::map<std::string, std::string> parameters,
ComponentRegistry *reg,
shared_ptr<mw::Component> child);
Expand Down

0 comments on commit 68da2de

Please sign in to comment.