2017-01-16 10:18:09 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./lib/qcd/action/gauge/WilsonGaugeAction.h
|
|
|
|
|
|
|
|
Copyright (C) 2016
|
|
|
|
|
|
|
|
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
|
|
|
|
|
|
|
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 2 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, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution
|
|
|
|
directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
|
|
|
#ifndef HMC_MODULES_H
|
|
|
|
#define HMC_MODULES_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
Define loadable, serializable modules
|
|
|
|
for the HMC execution
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Grid {
|
|
|
|
|
2017-01-18 16:31:51 +00:00
|
|
|
// Empty class for no parameters
|
|
|
|
class NoParameters{};
|
|
|
|
|
|
|
|
|
2017-01-16 10:18:09 +00:00
|
|
|
/*
|
|
|
|
Base class for modules with parameters
|
|
|
|
*/
|
|
|
|
template < class P >
|
|
|
|
class Parametrized{
|
|
|
|
public:
|
|
|
|
typedef P Parameters;
|
|
|
|
|
|
|
|
Parametrized(Parameters Par):Par_(Par){};
|
|
|
|
|
|
|
|
template <class ReaderClass>
|
2017-01-20 12:56:20 +00:00
|
|
|
Parametrized(Reader<ReaderClass> & R, std::string section_name = "parameters"){
|
|
|
|
read(R, section_name, Par_);
|
2017-01-16 10:18:09 +00:00
|
|
|
}
|
2017-01-16 16:07:12 +00:00
|
|
|
|
|
|
|
void set_parameters(Parameters Par){
|
2017-01-20 12:56:20 +00:00
|
|
|
Par_ = Par;
|
2017-01-16 16:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void print_parameters(){
|
2017-01-20 12:56:20 +00:00
|
|
|
std::cout << Par_ << std::endl;
|
2017-01-16 16:07:12 +00:00
|
|
|
}
|
|
|
|
|
2017-01-16 10:18:09 +00:00
|
|
|
protected:
|
|
|
|
Parameters Par_;
|
|
|
|
private:
|
2017-01-20 12:56:20 +00:00
|
|
|
std::string section_name;
|
2017-01-18 16:31:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class Parametrized<NoParameters>{
|
2017-01-20 12:56:20 +00:00
|
|
|
public:
|
2017-01-18 16:31:51 +00:00
|
|
|
typedef NoParameters Parameters;
|
|
|
|
|
|
|
|
Parametrized(Parameters Par){};
|
|
|
|
|
|
|
|
template <class ReaderClass>
|
|
|
|
Parametrized(Reader<ReaderClass> & Reader){};
|
|
|
|
|
|
|
|
void set_parameters(Parameters Par){}
|
|
|
|
|
|
|
|
void print_parameters(){}
|
|
|
|
|
2017-01-16 10:18:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-01-18 16:31:51 +00:00
|
|
|
|
2017-01-27 11:23:51 +00:00
|
|
|
////////////////////////////////////////
|
|
|
|
// Lowest level abstract module class
|
|
|
|
////////////////////////////////////////
|
2017-01-18 16:31:51 +00:00
|
|
|
template <class Prod>
|
|
|
|
class HMCModuleBase {
|
|
|
|
public:
|
2017-01-16 10:18:09 +00:00
|
|
|
typedef Prod Product;
|
|
|
|
|
2017-01-18 16:31:51 +00:00
|
|
|
virtual Prod* getPtr() = 0;
|
2017-01-16 10:18:09 +00:00
|
|
|
|
2017-01-20 12:56:20 +00:00
|
|
|
// add a getReference?
|
|
|
|
|
2017-01-18 16:31:51 +00:00
|
|
|
virtual void print_parameters(){}; // default to nothing
|
|
|
|
};
|
2017-01-16 10:18:09 +00:00
|
|
|
|
|
|
|
|
2017-01-27 11:23:51 +00:00
|
|
|
/////////////////////////////////////////////
|
|
|
|
// Registration class
|
|
|
|
/////////////////////////////////////////////
|
2017-01-16 10:18:09 +00:00
|
|
|
|
|
|
|
template <class T, class TheFactory>
|
|
|
|
class Registrar {
|
|
|
|
public:
|
|
|
|
Registrar(std::string className) {
|
|
|
|
// register the class factory function
|
2017-01-20 12:56:20 +00:00
|
|
|
TheFactory::getInstance().registerBuilder(className,
|
|
|
|
[&](typename TheFactory::TheReader Reader)
|
|
|
|
{
|
|
|
|
return std::unique_ptr<T>(new T(Reader));
|
|
|
|
}
|
|
|
|
);
|
2017-01-16 10:18:09 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //HMC_MODULES_H
|