The signature is declared and implemented in the .h file, and begin with the BEGIN_SIGNATURE_HOOK macro and ends with the END_SIGNATURE_HOOK macro. The minimal signature must include identification information. See part Complete the signature
Header File (.h)
#ifndef __EXAMPLEFUNC_H__ #define __EXAMPLEFUNC_H__ #include "openfluid-base.h" #include "openfluid-core.h" // ===================================================================== // ===================================================================== DECLARE_PLUGIN_HOOKS; // ===================================================================== // ===================================================================== class ExampleFunction : public openfluid::base::PluggableFunction { private: public: ExampleFunction(); ~ExampleFunction(); bool initParams(openfluid::core::ParamsMap Params); bool prepareData(); bool checkConsistency(); bool initializeRun(const openfluid::base::SimulationInfo* SimInfo); bool runStep(const openfluid::base::SimulationStatus* SimStatus); bool finalizeRun(const openfluid::base::SimulationInfo* SimInfo); }; #endif // __EXAMPLEFUNC_H__
Implementation file (.cpp)
#include "ExampleFunc.h" // ===================================================================== // ===================================================================== DEFINE_FUNCTION_HOOK(ExampleFunction); // ===================================================================== // ===================================================================== BEGIN_SIGNATURE_HOOK DECLARE_SIGNATURE_ID(wxT("examplefunc")); DECLARE_SIGNATURE_NAME(wxT("Example Function")); DECLARE_SIGNATURE_DESCRIPTION(wxT("")); DECLARE_SIGNATURE_VERSION(wxT("1.0")); DECLARE_SIGNATURE_SDKVERSION; DECLARE_SIGNATURE_STATUS(openfluid::base::EXPERIMENTAL); DECLARE_SIGNATURE_DOMAIN(wxT("")); DECLARE_SIGNATURE_PROCESS(wxT("")); DECLARE_SIGNATURE_METHOD(wxT("")); DECLARE_SIGNATURE_AUTHORNAME(wxT("")); DECLARE_SIGNATURE_AUTHOREMAIL(wxT("")); END_SIGNATURE_HOOK // ===================================================================== // ===================================================================== ExampleFunction::ExampleFunction() : PluggableFunction() { // here code for constructor } // ===================================================================== // ===================================================================== ExampleFunction::~ExampleFunction() { // here code for destructor } // ===================================================================== // ===================================================================== bool ExampleFunction::initParams(openfluid::core::ParamsMap Params) { // here code for function parameters initialization return true; } // ===================================================================== // ===================================================================== bool ExampleFunction::prepareData() { // here code for data preparation befor consistency checking return true; } // ===================================================================== // ===================================================================== bool ExampleFunction::checkConsistency() { // here code for function consistency checking return true; } // ===================================================================== // ===================================================================== bool ExampleFunction::initializeRun(const openfluid::base::SimulationInfo* SimInfo) { // here code for initialization just before the simulation return true; } // ===================================================================== // ===================================================================== bool ExampleFunction::runStep(const openfluid::base::SimulationStatus* SimStatus) { // here code for each time step return true; } // ===================================================================== // ===================================================================== bool ExampleFunction::finalizeRun(const openfluid::base::SimulationInfo* SimInfo) { // here code for finalization just after the simulation return true; }
Makefile
CPP = g++ WXLIBS = $(shell wx-config --libs base) WXFLAGS = $(shell wx-config --cxxflags base) OPENFLUIDLIBS = $(shell openfluid-config --libs) OPENFLUIDFLAGS = $(shell openfluid-config --cflags) BINFILE = examplefunc SRCFILESROOT = ExampleFunc INSTALLPATH = $(HOME)/.openfluid/engine/functions OBJPATH = . BINPATH = . LDFLAGS = PLUGEXT = sompi ifeq ($(OSTYPE),msys) LDFLAGS=-Wl,--enable-runtime-pseudo-reloc PLUGEXT = dllmpi endif ifdef FORCEINSTALLPATH INSTALLPATH = $(FORCEINSTALLPATH) endif ifdef FORCEOBJPATH OBJPATH = $(FORCEOBJPATH) endif ifdef FORCEBINPATH BINPATH = $(FORCEBINPATH) endif all: $(CPP) -c $(SRCFILESROOT).cpp -o $(OBJPATH)/$(SRCFILESROOT).o -fPIC $(WXFLAGS) $(OPENFLUIDFLAGS) $(CPP) $(OBJPATH)/$(SRCFILESROOT).o $(WXLIBS) $(OPENFLUIDLIBS) -o $(BINPATH)/$(BINFILE).$(PLUGEXT) -shared $(LDFLAGS) clean: rm -f $(BINPATH)/$(BINFILE).$(PLUGEXT) rm -f $(OBJPATH)/$(SRCFILESROOT).o install: all @mkdir -p $(INSTALLPATH) @cp ./$(BINFILE).$(PLUGEXT) $(INSTALLPATH)