mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-13 01:05:36 +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 *
|
* CMeson implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
CMeson::CMeson(const std::string &name)
|
CMeson::CMeson(const std::string name)
|
||||||
: Module(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// parse parameters ////////////////////////////////////////////////////////////
|
// parse parameters ////////////////////////////////////////////////////////////
|
||||||
void CMeson::parseParameters(XmlReader &reader, const std::string &name)
|
void CMeson::parseParameters(XmlReader &reader, const std::string name)
|
||||||
{
|
{
|
||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,11 @@ public:
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
CMeson(const std::string &name);
|
CMeson(const std::string name);
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~CMeson(void) = default;
|
virtual ~CMeson(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string &name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// dependency relation
|
// dependency relation
|
||||||
virtual std::vector<std::string> getInput(void);
|
virtual std::vector<std::string> getInput(void);
|
||||||
virtual std::vector<std::string> getOutput(void);
|
virtual std::vector<std::string> getOutput(void);
|
||||||
|
@ -34,12 +34,12 @@ using namespace Hadrons;
|
|||||||
* MQuark implementation *
|
* MQuark implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
MQuark::MQuark(const std::string &name)
|
MQuark::MQuark(const std::string name)
|
||||||
: Module(name)
|
: Module(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// parse parameters
|
// parse parameters
|
||||||
void MQuark::parseParameters(XmlReader &reader, const std::string &name)
|
void MQuark::parseParameters(XmlReader &reader, const std::string name)
|
||||||
{
|
{
|
||||||
read(reader, name, par_);
|
read(reader, name, par_);
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,11 @@ public:
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
MQuark(const std::string &name);
|
MQuark(const std::string name);
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~MQuark(void) = default;
|
virtual ~MQuark(void) = default;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string &name);
|
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||||
// dependency relation
|
// dependency relation
|
||||||
virtual std::vector<std::string> getInput(void);
|
virtual std::vector<std::string> getInput(void);
|
||||||
virtual std::vector<std::string> getOutput(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 *
|
* Module implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
Module::Module(const std::string &name)
|
Module::Module(const std::string name)
|
||||||
: name_(name)
|
: name_(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public:\
|
|||||||
mod##Registrar(void)\
|
mod##Registrar(void)\
|
||||||
{\
|
{\
|
||||||
ModuleFactory &modFac = ModuleFactory::getInstance();\
|
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));\
|
return std::unique_ptr<mod>(new mod(name));\
|
||||||
});\
|
});\
|
||||||
@ -56,13 +56,13 @@ class Module
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
Module(const std::string &name);
|
Module(const std::string name);
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~Module(void) = default;
|
virtual ~Module(void) = default;
|
||||||
// access
|
// access
|
||||||
std::string getName(void) const;
|
std::string getName(void) const;
|
||||||
// parse parameters
|
// parse parameters
|
||||||
virtual void parseParameters(XmlReader &reader, const std::string &name) = 0;
|
virtual void parseParameters(XmlReader &reader, const std::string name) = 0;
|
||||||
// dependency relation
|
// dependency relation
|
||||||
virtual std::vector<std::string> getInput(void) = 0;
|
virtual std::vector<std::string> getInput(void) = 0;
|
||||||
virtual std::vector<std::string> getOutput(void) = 0;
|
virtual std::vector<std::string> getOutput(void) = 0;
|
||||||
|
@ -39,7 +39,7 @@ ModuleFactory::ModuleFactory(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// registration ////////////////////////////////////////////////////////////////
|
// registration ////////////////////////////////////////////////////////////////
|
||||||
void ModuleFactory::registerModule(const std::string &type,
|
void ModuleFactory::registerModule(const std::string type,
|
||||||
const FactoryFunc &f)
|
const FactoryFunc &f)
|
||||||
{
|
{
|
||||||
factory_[type] = f;
|
factory_[type] = f;
|
||||||
@ -59,8 +59,8 @@ std::vector<std::string> ModuleFactory::getModuleList(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// factory /////////////////////////////////////////////////////////////////////
|
// factory /////////////////////////////////////////////////////////////////////
|
||||||
std::unique_ptr<Module> ModuleFactory::create(const std::string &type,
|
std::unique_ptr<Module> ModuleFactory::create(const std::string type,
|
||||||
const std::string &name) const
|
const std::string name) const
|
||||||
{
|
{
|
||||||
FactoryFunc func;
|
FactoryFunc func;
|
||||||
|
|
||||||
|
@ -40,16 +40,16 @@ class ModuleFactory
|
|||||||
{
|
{
|
||||||
SINGLETON(ModuleFactory)
|
SINGLETON(ModuleFactory)
|
||||||
public:
|
public:
|
||||||
typedef std::function<std::unique_ptr<Module>(const std::string &)>
|
typedef std::function<std::unique_ptr<Module>(const std::string )>
|
||||||
FactoryFunc;
|
FactoryFunc;
|
||||||
public:
|
public:
|
||||||
// registration
|
// registration
|
||||||
void registerModule(const std::string &type, const FactoryFunc &f);
|
void registerModule(const std::string type, const FactoryFunc &f);
|
||||||
// get module list
|
// get module list
|
||||||
std::vector<std::string> getModuleList(void) const;
|
std::vector<std::string> getModuleList(void) const;
|
||||||
// factory
|
// factory
|
||||||
std::unique_ptr<Module> create(const std::string &type,
|
std::unique_ptr<Module> create(const std::string type,
|
||||||
const std::string &name) const;
|
const std::string name) const;
|
||||||
private:
|
private:
|
||||||
std::map<std::string, FactoryFunc> factory_;
|
std::map<std::string, FactoryFunc> factory_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user