Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved and more frequent hash implementations #485

Merged
merged 18 commits into from
Sep 12, 2022
Merged

improved and more frequent hash implementations #485

merged 18 commits into from
Sep 12, 2022

Conversation

JohnS0819
Copy link
Contributor

No description provided.

@ea4k
Copy link
Owner

ea4k commented Aug 19, 2022

Thanks for the PR.
I have just tried to build in macOS without success.
I will try to work on it in the following days, once KLog-2.2 is published. I prefer not to add new code just a few days before a release.

Thank you!

In file included from ../../klog/src/awardswidget.cpp:27: In file included from ../../klog/src/awardswidget.h:33: In file included from ../../klog/src/dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:51: error: expected unqualified-id static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:52: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:54: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:32: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'? static QHash> SetDataHash; ~~~~~^~~~~~~ mem_fun /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here mem_fun(_Sp (_Tp::*__f)()) ^ In file included from ../../klog/src/awardswidget.cpp:27: In file included from ../../klog/src/awardswidget.h:33: In file included from ../../klog/src/dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:70: error: expected member name or ';' after declaration specifiers static QHash> SetDataHash; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ In file included from ../../klog/src/charts/statsfieldperbandwidget.cpp:26: In file included from ../../klog/src/charts/statsfieldperbandwidget.h:34: In file included from ../../klog/src/charts/../dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:51: error: expected unqualified-id static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:52: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:54: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:32: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'? static QHash> SetDataHash; ~~~~~^~~~~~~ mem_fun /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here mem_fun(_Sp (_Tp::*__f)()) ^ In file included from ../../klog/src/charts/statsfieldperbandwidget.cpp:26: In file included from ../../klog/src/charts/statsfieldperbandwidget.h:34: In file included from ../../klog/src/charts/../dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:70: error: expected member name or ';' after declaration specifiers static QHash> SetDataHash; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ In file included from ../../klog/src/main.cpp:39: In file included from ../../klog/src/mainwindow.h:38: In file included from ../../klog/src/setupdialog.h:31: In file included from ../../klog/src/setuppages/setuppageuserdata.h:31: In file included from ../../klog/src/setuppages/../world.h:42: In file included from ../../klog/src/dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:51: error: expected unqualified-id static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:52: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:54: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:32: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'? static QHash> SetDataHash; ~~~~~^~~~~~~ mem_fun /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here mem_fun(_Sp (_Tp::*__f)()) ^ In file included from ../../klog/src/main.cpp:39: In file included from ../../klog/src/mainwindow.h:38: In file included from ../../klog/src/setupdialog.h:31: In file included from ../../klog/src/setuppages/setuppageuserdata.h:31: In file included from ../../klog/src/setuppages/../world.h:42: In file included from ../../klog/src/dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:70: error: expected member name or ';' after declaration specifiers static QHash> SetDataHash; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ ../../klog/src/charts/statsfieldperbandwidget.cpp:28:109: warning: unused parameter 'parent' [-Wunused-parameter] StatsFieldPerBandWidget::StatsFieldPerBandWidget(DataProxy_SQLite *dp, ValidFieldsForStats _field, QWidget *parent) ^ In file included from ../../klog/src/elogqrzlog.cpp:27: In file included from ../../klog/src/elogqrzlog.h:39: In file included from ../../klog/src/dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:51: error: expected unqualified-id static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:52: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:54: error: expected expression static QHash> SetDataHash; ^ ../../klog/src/qso.h:417:32: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'? static QHash> SetDataHash; ~~~~~^~~~~~~ mem_fun /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here mem_fun(_Sp (_Tp::*__f)()) ^ In file included from ../../klog/src/elogqrzlog.cpp:27: In file included from ../../klog/src/elogqrzlog.h:39: In file included from ../../klog/src/dataproxy_sqlite.h:33: ../../klog/src/qso.h:417:70: error: expected member name or ';' after declaration specifiers static QHash> SetDataHash; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ ../../klog/src/elogqrzlog.cpp:34:61: warning: unused parameter '_parentFunction' [-Wunused-parameter] eLogQrzLog::eLogQrzLog(DataProxy_SQLite *dp, const QString &_parentFunction, const QString &_klogVersion) ^ ../../klog/src/elogqrzlog.cpp:70:46: warning: unused parameter '_func' [-Wunused-parameter] void eLogQrzLog::showDebugLog(const QString &_func, const QString &_log) ^ ../../klog/src/elogqrzlog.cpp:70:68: warning: unused parameter '_log' [-Wunused-parameter] void eLogQrzLog::showDebugLog(const QString &_func, const QString &_log) ^ 5 errors generated. make: *** [build/obj/awardswidget.o] Error 1 make: *** Waiting for unfinished jobs.... 1 warning and 5 errors generated. make: *** [build/obj/statsfieldperbandwidget.o] Error 1 3 warnings and 5 errors generated. make: *** [build/obj/elogqrzlog.o] Error 1 5 errors generated. make: *** [build/obj/main.o] Error 1 00:41:54: The process "/usr/bin/make" exited with code 2. Error while building/deploying project KLog (kit: Desktop Qt 5.15.2 clang 64bit) When executing step "Make" 00:41:54: Elapsed time: 00:09.

@JohnS0819
Copy link
Contributor Author

Oh I see the problem. Lines 416 in QSO.h and 2616 in QSO.cpp aren't portable to macOS. Using a decltype should fix that.

Line 416 should be changed to:
static QHash<QString, decltype(std::mem_fn(&setSig))> SetDataHash;

and line 2616 should be changed to:
QHash<QString, decltype(std::mem_fn(&QSO::setSig))> QSO::SetDataHash;

@ea4k
Copy link
Owner

ea4k commented Aug 20, 2022

The line in qso.h seems to be OK but not the one for qso.cpp.

I have never used those templates neither these functions...
Do you have any good link to understand that code?

@JohnS0819
Copy link
Contributor Author

The line in qso.h seems to be OK but not the one for qso.cpp.

Do you think you could send me the build error log.

I have never used those templates neither these functions...
Do you have any good link to understand that code?

Sure. For the cliffnotes version, std::mem_fn is essentially just a wrapper for a function pointer, more specifically a member function pointer. Unfortunately mem_fn has unspecified return type, so to get around this I thought that using decltype would work (apparently it didn't). Here's some more detailed explanations of them.
cpp reference
good read on the subject

@ea4k
Copy link
Owner

ea4k commented Aug 20, 2022

I had to change the line of qso.h to:
static QHash<QString, decltype(std::mem_fn(&QSO::setSig))> SetDataHash;

In the qso.cpp:

I get an error in the lines after I have renamed "_Mem_fn" to "mem_fn" like this:
{"ADDRESS", std::mem_fn<bool(QSO::*)(const QString&)>(&QSO::setAddress)},

The error I get is:
qso.cpp:2623:13: error: no matching function for call to 'mem_fn'
functional:1405:1: note: candidate template ignored: could not match 'bool (QSO::*)(const QString &)' against 'bool (const QString &)'

If I try to compile I get the following: (please know that I have not changed the "_Mem_fn" to "mem_fn" except in the first line:

===== compilation errors ====
Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/AGL.framework/Headers -I../../../../Qt/5.15.2/clang_64/mkspecs/macx-clang -F/Users/d/Qt/5.15.2/clang_64/lib -o build/obj/setupdialog.o ../../klog/src/setupdialog.cpp
../../klog/src/qso.cpp:2623:13: error: no matching function for call to 'mem_fn'
{"ADDRESS", std::mem_fn<bool(QSO::)(const QString&)>(&QSO::setAddress)},
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1405:1: note: candidate template ignored: could not match 'bool (QSO::
)(const QString &)' against 'bool (const QString &)'
mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
^
../../klog/src/qso.cpp:2624:32: error: expected unqualified-id
{"AGE", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAge)},
^
../../klog/src/qso.cpp:2624:33: error: expected expression
{"AGE", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAge)},
^
../../klog/src/qso.cpp:2624:35: error: expected expression
{"AGE", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAge)},
^
../../klog/src/qso.cpp:2624:14: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'?
{"AGE", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAge)},
~~~~~^~~~~~~
mem_fun
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here
mem_fun(_Sp (_Tp::__f)())
^
../../klog/src/qso.cpp:2625:44: error: expected unqualified-id
{"A_INDEX", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setA_Index)},
^
../../klog/src/qso.cpp:2625:45: error: expected expression
{"A_INDEX", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setA_Index)},
^
../../klog/src/qso.cpp:2625:47: error: expected expression
{"A_INDEX", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setA_Index)},
^
../../klog/src/qso.cpp:2625:26: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'?
{"A_INDEX", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setA_Index)},
~~~~~^~~~~~~
mem_fun
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here
mem_fun(_Sp (_Tp::
__f)())
^
../../klog/src/qso.cpp:2626:43: error: expected unqualified-id
{"ANT_AZ", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAnt_az)},
^
../../klog/src/qso.cpp:2626:44: error: expected expression
{"ANT_AZ", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAnt_az)},
^
../../klog/src/qso.cpp:2626:46: error: expected expression
{"ANT_AZ", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAnt_az)},
^
../../klog/src/qso.cpp:2626:25: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'?
{"ANT_AZ", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAnt_az)},
~~~~~^~~~~~~
mem_fun
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here
mem_fun(_Sp (_Tp::__f)())
^
../../klog/src/qso.cpp:2627:43: error: expected unqualified-id
{"ANT_EL", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAnt_el)},
^
../../klog/src/qso.cpp:2627:44: error: expected expression
{"ANT_EL", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAnt_el)},
^
../../klog/src/qso.cpp:2627:46: error: expected expression
{"ANT_EL", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAnt_el)},
^
../../klog/src/qso.cpp:2627:25: error: no member named '_Mem_fn' in namespace 'std'; did you mean 'mem_fun'?
{"ANT_EL", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAnt_el)},
~~~~~^~~~~~~
mem_fun
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/functional:1157:1: note: 'mem_fun' declared here
mem_fun(_Sp (_Tp::
__f)())
^
../../klog/src/qso.cpp:2628:45: error: expected unqualified-id
{"ANT_PATH", std::_Mem_fn<bool(QSO::)(const QString&)>(&QSO::setAnt_Path)},
^
../../klog/src/qso.cpp:2628:46: error: expected expression
{"ANT_PATH", std::_Mem_fn<bool(QSO::
)(const QString&)>(&QSO::setAnt_Path)},
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [build/obj/qso.o] Error 1
make: *** Waiting for unfinished jobs....
../../klog/src/setupdialog.cpp:35:57: warning: unused parameter 'parent' [-Wunused-parameter]
SetupDialog::SetupDialog(DataProxy_SQLite *dp, QWidget *parent)
^
1 warning generated.
18:23:44: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project KLog (kit: Desktop Qt 5.15.2 clang 64bit)
When executing step "Make"
18:23:44: Elapsed time: 00:32.

@JohnS0819
Copy link
Contributor Author

Ok thank you, that was another mistake on my end. I had forgotten that there were additional usages of _mem_fn inside the initializehash() function. To fix that just find and replace all occurrences of "std::_Mem_fn<bool(QSO::*)(const QString&)>" with "decltype(std::mem_fn(&QSO::setSig))" and that should fix it

@JohnS0819
Copy link
Contributor Author

@ea4k I've added some commits that should fix any build issues, do you think you could take a look when you have time.

Best,
JohnS0819

@ea4k
Copy link
Owner

ea4k commented Sep 8, 2022

The PR compiles in my system but crashes on KLog start.
I will check as it may be related with the code in utilities.cpp that was in master when yo did the PR.

@ea4k ea4k merged commit a83e9e2 into ea4k:master Sep 12, 2022
ea4k added a commit that referenced this pull request Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants