Search Results
ModuleDefBuilder.h
/*
* MoMEMta: a modular implementation of the Matrix Element Method
* Copyright (C) 2016 Universite catholique de Louvain (UCL), Belgium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <momemta/ModuleDef.h>
// Forward declaration
class Module;
class ParameterSet;
class Pool;
namespace momemta {
struct ModuleRegistrationData {
ModuleRegistrationData() {}
ModuleRegistrationData(const ModuleDef& def): module_def(def) { }
ModuleDef module_def;
};
namespace registration {
// Builder class passed to the REGISTER_MODULE macro
class ModuleDefBuilder {
public:
explicit ModuleDefBuilder(const std::string& name);
template <typename ModuleType>
ModuleDefBuilder& Type() {
// Currently not used
return *this;
}
ModuleDefBuilder& Attr(const std::string& spec);
ModuleDefBuilder& GlobalAttr(const std::string& spec);
ModuleDefBuilder& OptionalAttr(const std::string& spec);
/* TODO: Add support for type when defining inputs, in the same way as attributes
TODO: we can then ensure that inputs are connected to compatible outputs */
ModuleDefBuilder& Input(const std::string& spec);
ModuleDefBuilder& OptionalInput(const std::string& spec);
ModuleDefBuilder& Inputs(const std::string& spec);
ModuleDefBuilder& OptionalInputs(const std::string& spec);
ModuleDefBuilder& Output(const std::string& spec);
ModuleDefBuilder& Sticky();
ModuleRegistrationData Build() const;
std::string name() const;
private:
mutable ModuleRegistrationData reg_data;
std::vector<std::string> attrs;
std::vector<std::string> inputs;
std::vector<std::string> outputs;
};
}
}