1
0
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:
Antonin Portelli 2016-04-16 08:41:12 +01:00
parent 3834d81181
commit feae35d92c
10 changed files with 42 additions and 19 deletions

View File

@ -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_);
}

View File

@ -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);

View File

@ -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_);
}

View File

@ -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);

View File

@ -0,0 +1,9 @@
//
// MSource.cpp
// Grid
//
// Created by Antonin Portelli on 16/04/2016.
//
//
#include "MSource.hpp"

View 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 */

View File

@ -34,7 +34,7 @@ using namespace Hadrons;
* Module implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
Module::Module(const std::string &name)
Module::Module(const std::string name)
: name_(name)
{}

View File

@ -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;

View File

@ -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;

View File

@ -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_;
};