crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
All.hpp
Go to the documentation of this file.
1 /*
2  *
3  * ---
4  *
5  * Copyright (C) 2021 Anselm Schmidt (ans[ät]ohai.su)
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version in addition to the terms of any
11  * licences already herein identified.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  *
21  * ---
22  *
23  * All.hpp
24  *
25  * Registration of implemented algorithms.
26  *
27  * NOTE: Algorithms need to be included in 'All.cpp'
28  * and 'json/algos.json' (located in 'crawlserv_frontend')
29  * in order to be usable by the frontend.
30  *
31  * Created on: Jan 13, 2019
32  * Author: ans
33  */
34 
35 #ifndef MODULE_ANALYZER_ALGO_ALL_HPP_
36 #define MODULE_ANALYZER_ALGO_ALL_HPP_
37 
38 #include "../Thread.hpp"
39 
40 #include "../../../Struct/AlgoThreadProperties.hpp"
41 
42 #include <memory> // std::make_unique, std::unique_ptr
43 
46 
47  // for convenience
49 
50  using AlgoThreadPtr = std::unique_ptr<Module::Analyzer::Thread>;
51 
54 
56 
58 
59 } /* namespace crawlservpp::Module::Analyzer::Algo */
60 
61 // macro for algorithm thread creation
62 //NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
63 #define REGISTER_ALGORITHM(ID, CLASS) \
64  if(thread.algoId == (ID)) { \
65  if(thread.status.id > 0) {\
66  return std::make_unique<CLASS>(\
67  thread.dbBase, \
68  thread.options, \
69  thread.status \
70  ); \
71  }\
72  return std::make_unique<CLASS>(thread.dbBase, thread.options); \
73  }
74 
75 #endif /* MODULE_ANALYZER_ALGO_ALL_HPP_ */
std::unique_ptr< Module::Analyzer::Thread > AlgoThreadPtr
Definition: All.hpp:50
Namespace for algorithm classes.
Definition: All.cpp:52
AlgoThreadPtr initAlgo(const AlgoThreadProperties &thread)
Creates an algorithm thread.
Definition: All.cpp:75
Struct::AlgoThreadProperties AlgoThreadProperties
Definition: All.hpp:48
Properties of an algorithm thread.
Definition: AlgoThreadProperties.hpp:46