libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
jsclassregistrar.cpp
Go to the documentation of this file.
1
2#include "jsclassregistrar.h"
3
4namespace pappso
5{
6std::unordered_map<NamespaceClassnamePairAsKey,
19
20
21void
23{
24 qDebug() << "Registering the constructor of the classes marked for JS.";
25
26 qsizetype count = getNameSpaceClassNameJsConstructorRegistrarMap().size();
27 qDebug() << "Size of the map: count" << count;
28
29 for(const auto &entry : getNameSpaceClassNameJsConstructorRegistrarMap())
30 entry.second(engine);
31}
32
33// Note that name_space can be compounded: MsXpS::libXpertMass, for class name Formula, for example.
34void
36 const QString &class_name,
37 QJSEngine *engine)
38{
39 // Remember, the registrar map is actually a map of map:
40
41 // Key type: pair of namespace and class name
42 // using NamespaceClassnamePairAsKey = std::pair<QString, QString>;
43 // using RegisterFunc = std::function<void(QJSEngine *)>;
44 //
45 // std::unordered_map<NamespaceClassnamePairAsKey,
46 // RegisterFunc,
47 // NsClassKeyHash,
48 // AreNamespaceClassnamePairAsKeyEqual>
49
50 // So, first look for a pair<NamespaceClassnamePairAsKey, RegisterFunc>
51 // having key = {name_sape, class_name}, that is, a std::pair<QString,
52 // QString>. Once we get that map item, run the second member of the
53 // outer map item which actually runs the functor.
54 auto it = getNameSpaceClassNameJsConstructorRegistrarMap().find({name_space, class_name});
56 it->second(engine);
57 else
58 qWarning().noquote() << "No JS constructor registered for namespace" << name_space
59 << "and class name" << class_name;
60}
61
62}// namespace pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
void registerJsConstructorForNameSpaceClassNameInRegistrarMap(const QString &name_space, const QString &class_name, QJSEngine *engine)
std::function< void(QJSEngine *)> RegisterFunc
void registerJsConstructorForEachClassInRegistrarMap(QJSEngine *engine)
std::unordered_map< NamespaceClassnamePairAsKey, RegisterFunc, NamespaceClassnameAsKeyHash, AreNamespaceClassnamePairsEqual > & getNameSpaceClassNameJsConstructorRegistrarMap()
std::pair< QString, QString > NamespaceClassnamePairAsKey