1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Hadrons: module creation fix

This commit is contained in:
Antonin Portelli 2016-12-05 11:44:16 +09:00
parent ee5b1fe043
commit 7433eed274
2 changed files with 24 additions and 2 deletions

View File

@ -65,6 +65,11 @@ public:
virtual ~Application(void) = default; virtual ~Application(void) = default;
// access // access
void setPar(const GlobalPar &par); void setPar(const GlobalPar &par);
// module creation
template <typename M>
void createModule(const std::string name);
template <typename M>
void createModule(const std::string name, const typename M::Par &par);
// execute // execute
void run(void); void run(void);
// parse parameter file // parse parameter file
@ -81,6 +86,23 @@ private:
std::vector<unsigned int> program_; std::vector<unsigned int> program_;
}; };
/******************************************************************************
* Application template implementation *
******************************************************************************/
// module creation /////////////////////////////////////////////////////////////
template <typename M>
void Application::createModule(const std::string name)
{
env_.createModule<M>(name);
}
template <typename M>
void Application::createModule(const std::string name,
const typename M::Par &par)
{
env_.createModule<M>(name, par);
}
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_Application_hpp_ #endif // Hadrons_Application_hpp_

View File

@ -251,9 +251,9 @@ template <typename M>
void Environment::createModule(const std::string name, void Environment::createModule(const std::string name,
const typename M::Par &par) const typename M::Par &par)
{ {
std::unique_ptr<M> pt(new M(name)); ModPt pt(new M(name));
pt->setPar(par); static_cast<M *>(pt.get())->setPar(par);
pushModule(pt); pushModule(pt);
} }