mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Hadrons: pass strings by value
This commit is contained in:
parent
3834d81181
commit
feae35d92c
@ -34,12 +34,12 @@ using namespace Hadrons;
|
||||
* CMeson implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
CMeson::CMeson(const std::string &name)
|
||||
CMeson::CMeson(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void CMeson::parseParameters(XmlReader &reader, const std::string &name)
|
||||
void CMeson::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ public:
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
CMeson(const std::string &name);
|
||||
CMeson(const std::string name);
|
||||
// destructor
|
||||
virtual ~CMeson(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string &name);
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
|
@ -34,12 +34,12 @@ using namespace Hadrons;
|
||||
* MQuark implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
MQuark::MQuark(const std::string &name)
|
||||
MQuark::MQuark(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters
|
||||
void MQuark::parseParameters(XmlReader &reader, const std::string &name)
|
||||
void MQuark::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ public:
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
MQuark(const std::string &name);
|
||||
MQuark(const std::string name);
|
||||
// destructor
|
||||
virtual ~MQuark(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string &name);
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
|
9
programs/Hadrons/MSource.cc
Normal file
9
programs/Hadrons/MSource.cc
Normal file
@ -0,0 +1,9 @@
|
||||
//
|
||||
// MSource.cpp
|
||||
// Grid
|
||||
//
|
||||
// Created by Antonin Portelli on 16/04/2016.
|
||||
//
|
||||
//
|
||||
|
||||
#include "MSource.hpp"
|
14
programs/Hadrons/MSource.hpp
Normal file
14
programs/Hadrons/MSource.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
//
|
||||
// MSource.hpp
|
||||
// Grid
|
||||
//
|
||||
// Created by Antonin Portelli on 16/04/2016.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef MSource_hpp
|
||||
#define MSource_hpp
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#endif /* MSource_hpp */
|
@ -34,7 +34,7 @@ using namespace Hadrons;
|
||||
* Module implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
Module::Module(const std::string &name)
|
||||
Module::Module(const std::string name)
|
||||
: name_(name)
|
||||
{}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:\
|
||||
mod##Registrar(void)\
|
||||
{\
|
||||
ModuleFactory &modFac = ModuleFactory::getInstance();\
|
||||
modFac.registerModule(#mod, [&](const std::string &name)\
|
||||
modFac.registerModule(#mod, [&](const std::string name)\
|
||||
{\
|
||||
return std::unique_ptr<mod>(new mod(name));\
|
||||
});\
|
||||
@ -56,13 +56,13 @@ class Module
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
Module(const std::string &name);
|
||||
Module(const std::string name);
|
||||
// destructor
|
||||
virtual ~Module(void) = default;
|
||||
// access
|
||||
std::string getName(void) const;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string &name) = 0;
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name) = 0;
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void) = 0;
|
||||
virtual std::vector<std::string> getOutput(void) = 0;
|
||||
|
@ -39,7 +39,7 @@ ModuleFactory::ModuleFactory(void)
|
||||
}
|
||||
|
||||
// registration ////////////////////////////////////////////////////////////////
|
||||
void ModuleFactory::registerModule(const std::string &type,
|
||||
void ModuleFactory::registerModule(const std::string type,
|
||||
const FactoryFunc &f)
|
||||
{
|
||||
factory_[type] = f;
|
||||
@ -59,8 +59,8 @@ std::vector<std::string> ModuleFactory::getModuleList(void) const
|
||||
}
|
||||
|
||||
// factory /////////////////////////////////////////////////////////////////////
|
||||
std::unique_ptr<Module> ModuleFactory::create(const std::string &type,
|
||||
const std::string &name) const
|
||||
std::unique_ptr<Module> ModuleFactory::create(const std::string type,
|
||||
const std::string name) const
|
||||
{
|
||||
FactoryFunc func;
|
||||
|
||||
|
@ -40,16 +40,16 @@ class ModuleFactory
|
||||
{
|
||||
SINGLETON(ModuleFactory)
|
||||
public:
|
||||
typedef std::function<std::unique_ptr<Module>(const std::string &)>
|
||||
typedef std::function<std::unique_ptr<Module>(const std::string )>
|
||||
FactoryFunc;
|
||||
public:
|
||||
// registration
|
||||
void registerModule(const std::string &type, const FactoryFunc &f);
|
||||
void registerModule(const std::string type, const FactoryFunc &f);
|
||||
// get module list
|
||||
std::vector<std::string> getModuleList(void) const;
|
||||
// factory
|
||||
std::unique_ptr<Module> create(const std::string &type,
|
||||
const std::string &name) const;
|
||||
std::unique_ptr<Module> create(const std::string type,
|
||||
const std::string name) const;
|
||||
private:
|
||||
std::map<std::string, FactoryFunc> factory_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user