mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Hadrons: more module templates
This commit is contained in:
		
							
								
								
									
										83
									
								
								extras/Hadrons/Modules/templates/Module_tmp.hpp.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								extras/Hadrons/Modules/templates/Module_tmp.hpp.template
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
				
			|||||||
 | 
					#ifndef Hadrons____FILEBASENAME____hpp_
 | 
				
			||||||
 | 
					#define Hadrons____FILEBASENAME____hpp_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Grid/Hadrons/Global.hpp>
 | 
				
			||||||
 | 
					#include <Grid/Hadrons/Module.hpp>
 | 
				
			||||||
 | 
					#include <Grid/Hadrons/ModuleFactory.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BEGIN_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/******************************************************************************
 | 
				
			||||||
 | 
					 *                         ___FILEBASENAME___                                 *
 | 
				
			||||||
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					class ___FILEBASENAME___Par: Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    GRID_SERIALIZABLE_CLASS_MEMBERS(___FILEBASENAME___Par,
 | 
				
			||||||
 | 
					                                    unsigned int, i);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					class T___FILEBASENAME___: public Module<___FILEBASENAME___Par>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    // constructor
 | 
				
			||||||
 | 
					    T___FILEBASENAME___(const std::string name);
 | 
				
			||||||
 | 
					    // destructor
 | 
				
			||||||
 | 
					    virtual ~T___FILEBASENAME___(void) = default;
 | 
				
			||||||
 | 
					    // dependency relation
 | 
				
			||||||
 | 
					    virtual std::vector<std::string> getInput(void);
 | 
				
			||||||
 | 
					    virtual std::vector<std::string> getOutput(void);
 | 
				
			||||||
 | 
					    // setup
 | 
				
			||||||
 | 
					    virtual void setup(void);
 | 
				
			||||||
 | 
					    // execution
 | 
				
			||||||
 | 
					    virtual void execute(void);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef T___FILEBASENAME___<FIMPL> ___FILEBASENAME___;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/******************************************************************************
 | 
				
			||||||
 | 
					 *                 T___FILEBASENAME___ implementation                             *
 | 
				
			||||||
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					// constructor /////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					T___FILEBASENAME___<FImpl>::T___FILEBASENAME___(const std::string name)
 | 
				
			||||||
 | 
					: Module<___FILEBASENAME___Par>(name)
 | 
				
			||||||
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// dependencies/products ///////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					std::vector<std::string> T___FILEBASENAME___<FImpl>::getInput(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::vector<std::string> in;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return in;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					std::vector<std::string> T___FILEBASENAME___<FImpl>::getOutput(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::vector<std::string> out = {getName()};
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return out;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// setup ///////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					void T___FILEBASENAME___<FImpl>::setup(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// execution ///////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					void T___FILEBASENAME___<FImpl>::execute(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MODULE_REGISTER(___FILEBASENAME___);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					END_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // Hadrons____FILEBASENAME____hpp_
 | 
				
			||||||
@@ -0,0 +1,87 @@
 | 
				
			|||||||
 | 
					#ifndef Hadrons____FILEBASENAME____hpp_
 | 
				
			||||||
 | 
					#define Hadrons____FILEBASENAME____hpp_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Grid/Hadrons/Global.hpp>
 | 
				
			||||||
 | 
					#include <Grid/Hadrons/Module.hpp>
 | 
				
			||||||
 | 
					#include <Grid/Hadrons/ModuleFactory.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BEGIN_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/******************************************************************************
 | 
				
			||||||
 | 
					 *                         ___FILEBASENAME___                                 *
 | 
				
			||||||
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					BEGIN_MODULE_NAMESPACE(___NAMESPACE___)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ___FILEBASENAME___Par: Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    GRID_SERIALIZABLE_CLASS_MEMBERS(___FILEBASENAME___Par,
 | 
				
			||||||
 | 
					                                    unsigned int, i);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					class T___FILEBASENAME___: public Module<___FILEBASENAME___Par>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    // constructor
 | 
				
			||||||
 | 
					    T___FILEBASENAME___(const std::string name);
 | 
				
			||||||
 | 
					    // destructor
 | 
				
			||||||
 | 
					    virtual ~T___FILEBASENAME___(void) = default;
 | 
				
			||||||
 | 
					    // dependency relation
 | 
				
			||||||
 | 
					    virtual std::vector<std::string> getInput(void);
 | 
				
			||||||
 | 
					    virtual std::vector<std::string> getOutput(void);
 | 
				
			||||||
 | 
					    // setup
 | 
				
			||||||
 | 
					    virtual void setup(void);
 | 
				
			||||||
 | 
					    // execution
 | 
				
			||||||
 | 
					    virtual void execute(void);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef T___FILEBASENAME___<FIMPL> ___FILEBASENAME___;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/******************************************************************************
 | 
				
			||||||
 | 
					 *                 T___FILEBASENAME___ implementation                             *
 | 
				
			||||||
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					// constructor /////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					T___FILEBASENAME___<FImpl>::T___FILEBASENAME___(const std::string name)
 | 
				
			||||||
 | 
					: Module<___FILEBASENAME___Par>(name)
 | 
				
			||||||
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// dependencies/products ///////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					std::vector<std::string> T___FILEBASENAME___<FImpl>::getInput(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::vector<std::string> in;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return in;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					std::vector<std::string> T___FILEBASENAME___<FImpl>::getOutput(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::vector<std::string> out = {getName()};
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return out;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// setup ///////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					void T___FILEBASENAME___<FImpl>::setup(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// execution ///////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					template <typename FImpl>
 | 
				
			||||||
 | 
					void T___FILEBASENAME___<FImpl>::execute(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					END_MODULE_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MODULE_REGISTER_NS(___FILEBASENAME___, ___NAMESPACE___);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					END_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // Hadrons____FILEBASENAME____hpp_
 | 
				
			||||||
							
								
								
									
										28
									
								
								extras/Hadrons/add_module_template.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								extras/Hadrons/add_module_template.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if (( $# != 1 && $# != 2)); then
 | 
				
			||||||
 | 
					    echo "usage: `basename $0` <module name> [<namespace>]" 1>&2
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					NAME=$1
 | 
				
			||||||
 | 
					NS=$2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if (( $# == 1 )); then
 | 
				
			||||||
 | 
						if [ -e "Modules/${NAME}.cc" ] || [ -e "Modules/${NAME}.hpp" ]; then
 | 
				
			||||||
 | 
						    echo "error: files Modules/${NAME}.* already exists" 1>&2
 | 
				
			||||||
 | 
						    exit 1
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
						sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module_tmp.hpp.template > Modules/${NAME}.hpp
 | 
				
			||||||
 | 
					elif (( $# == 2 )); then
 | 
				
			||||||
 | 
						mkdir -p Modules/${NS}
 | 
				
			||||||
 | 
						if [ -e "Modules/${NS}/${NAME}.cc" ] || [ -e "Modules/${NS}/${NAME}.hpp" ]; then
 | 
				
			||||||
 | 
						    echo "error: files Modules/${NS}/${NAME}.* already exists" 1>&2
 | 
				
			||||||
 | 
						    exit 1
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
						TMPCC=".${NS}.${NAME}.tmp.cc"
 | 
				
			||||||
 | 
						TMPHPP=".${NS}.${NAME}.tmp.hpp"
 | 
				
			||||||
 | 
						sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module_tmp_in_NS.hpp.template > ${TMPHPP}
 | 
				
			||||||
 | 
						sed "s/___NAMESPACE___/${NS}/g" ${TMPHPP} > Modules/${NS}/${NAME}.hpp
 | 
				
			||||||
 | 
						rm -f ${TMPCC} ${TMPHPP}
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					./make_module_list.sh
 | 
				
			||||||
		Reference in New Issue
	
	Block a user