From e7475a3bd15ba78a4defa4664cc4af48509865f3 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 30 Dec 2019 20:04:22 +0100 Subject: [PATCH] python+MSVC: reorganize headers to reduce req. includes Signed-off-by: Thorsten Liebig --- CMakeLists.txt | 2 +- nf2ff/CMakeLists.txt | 2 +- nf2ff/nf2ff.cpp | 26 ++++++++++++++++++++++++++ nf2ff/nf2ff.h | 12 ++++++------ openems.h | 4 ++-- openems_global.h | 31 +++++++++++++++++++++++++++++++ tools/global.h | 11 +---------- 7 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 openems_global.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bbace04..5e2ae56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,7 +188,7 @@ set(SOURCES openems.cpp ) -set(PUB_HEADERS openems.h) +set(PUB_HEADERS openems.h openems_global.h) # libs ADD_SUBDIRECTORY( tools ) diff --git a/nf2ff/CMakeLists.txt b/nf2ff/CMakeLists.txt index ecc8a27..81801be 100644 --- a/nf2ff/CMakeLists.txt +++ b/nf2ff/CMakeLists.txt @@ -55,7 +55,7 @@ else() INSTALL(TARGETS nf2ff DESTINATION lib${LIB_SUFFIX}) endif() -INSTALL(FILES ${HEADERS} DESTINATION include/openEMS) +INSTALL(FILES nf2ff.h DESTINATION include/openEMS) #TODO tarball, debug, release diff --git a/nf2ff/nf2ff.cpp b/nf2ff/nf2ff.cpp index 62c9238..5aede9b 100644 --- a/nf2ff/nf2ff.cpp +++ b/nf2ff/nf2ff.cpp @@ -133,6 +133,32 @@ void nf2ff::SetMirror(int type, int dir, float pos) m_nf2ff.at(fn)->SetMirror(type, dir, pos); } + +double nf2ff::GetTotalRadPower(size_t f_idx) const +{ + return m_nf2ff.at(f_idx)->GetTotalRadPower(); +} + +double nf2ff::GetMaxDirectivity(size_t f_idx) const +{ + return m_nf2ff.at(f_idx)->GetMaxDirectivity(); +} + +complex** nf2ff::GetETheta(size_t f_idx) const +{ + return m_nf2ff.at(f_idx)->GetETheta(); +} + +complex** nf2ff::GetEPhi(size_t f_idx) const +{ + return m_nf2ff.at(f_idx)->GetEPhi(); +} + +double** nf2ff::GetRadPower(size_t f_idx) const +{ + return m_nf2ff.at(f_idx)->GetRadPower(); +} + bool nf2ff::AnalyseXMLNode(TiXmlElement* ti_nf2ff) { if (ti_nf2ff==NULL) diff --git a/nf2ff/nf2ff.h b/nf2ff/nf2ff.h index 634989b..76de286 100644 --- a/nf2ff/nf2ff.h +++ b/nf2ff/nf2ff.h @@ -23,7 +23,6 @@ #include #include #include -#include "nf2ff_calc.h" using namespace std; @@ -39,6 +38,7 @@ using namespace std; class TiXmlElement; +class nf2ff_calc; class NF2FF_EXPORT nf2ff { @@ -54,12 +54,12 @@ public: void SetMirror(int type, int dir, float pos); - double GetTotalRadPower(size_t f_idx) const {return m_nf2ff.at(f_idx)->GetTotalRadPower();} - double GetMaxDirectivity(size_t f_idx) const {return m_nf2ff.at(f_idx)->GetMaxDirectivity();} + double GetTotalRadPower(size_t f_idx) const; + double GetMaxDirectivity(size_t f_idx) const; - complex** GetETheta(size_t f_idx) const {return m_nf2ff.at(f_idx)->GetETheta();} - complex** GetEPhi(size_t f_idx) const {return m_nf2ff.at(f_idx)->GetEPhi();} - double** GetRadPower(size_t f_idx) const {return m_nf2ff.at(f_idx)->GetRadPower();} + complex** GetETheta(size_t f_idx) const; + complex** GetEPhi(size_t f_idx) const; + double** GetRadPower(size_t f_idx) const; //! Write results to a hdf5 file bool Write2HDF5(string filename); diff --git a/openems.h b/openems.h index 2de8118..b308b13 100644 --- a/openems.h +++ b/openems.h @@ -19,7 +19,7 @@ #define OPENEMS_H #include -#ifdef WIN32 +#ifndef __GNUC__ #include // for struct timeval #else #include @@ -27,7 +27,7 @@ #include #include -#include "tools/global.h" +#include "openems_global.h" #define __OPENEMS_STAT_FILE__ "openEMS_stats.txt" #define __OPENEMS_RUN_STAT_FILE__ "openEMS_run_stats.txt" diff --git a/openems_global.h b/openems_global.h new file mode 100644 index 0000000..0144e01 --- /dev/null +++ b/openems_global.h @@ -0,0 +1,31 @@ +/* +* Copyright (C) 2019 Thorsten Liebig (Thorsten.Liebig@gmx.de) +* +* 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 3 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, see . +*/ + +#ifndef OPENEMS_GLOBAL_H +#define OPENEMS_GLOBAL_H + +#if defined(WIN32) + #ifdef BUILD_OPENEMS_LIB + #define OPENEMS_EXPORT __declspec(dllexport) + #else + #define OPENEMS_EXPORT __declspec(dllimport) + #endif +#else +#define OPENEMS_EXPORT +#endif + +#endif // OPENEMS_GLOBAL_H diff --git a/tools/global.h b/tools/global.h index bbbd8ae..a91b024 100644 --- a/tools/global.h +++ b/tools/global.h @@ -21,16 +21,7 @@ #include #define _USE_MATH_DEFINES -#include "tools/array_ops.h" -#if defined(WIN32) - #ifdef BUILD_OPENEMS_LIB - #define OPENEMS_EXPORT __declspec(dllexport) - #else - #define OPENEMS_EXPORT __declspec(dllimport) - #endif -#else -#define OPENEMS_EXPORT -#endif +#include "openems_global.h" // declare a parameter as unused #define UNUSED(x) (void)(x);