crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
Empty.hpp
Go to the documentation of this file.
1 /*
2  *
3  * ---
4  *
5  * Copyright (C) 2022 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  * Empty.hpp
24  *
25  * Empty template class for adding new algorithms to the application.
26  * Duplicate this (and the source) file to implement a new algorithm,
27  * then add it to 'All.cpp' in the same directory.
28  *
29  * TODO: change name, date and description of the file
30  *
31  * Created on: Feb 5, 2021
32  * Author: ans
33  */
34 
35 /*
36  * TODO: change the name of the include guard
37  */
38 #ifndef MODULE_ANALYZER_ALGO_EMPTY_HPP_
39 #define MODULE_ANALYZER_ALGO_EMPTY_HPP_
40 
41 #include "../Thread.hpp"
42 
43 /*
44  * TODO: add additional crawlserv++ headers
45  */
46 //#include "../../../Data/Data.hpp"
47 #include "../../../Main/Database.hpp"
48 //#include "../../../Struct/QueryStruct.hpp"
49 #include "../../../Struct/StatusSetter.hpp"
50 #include "../../../Struct/ThreadOptions.hpp"
51 #include "../../../Struct/ThreadStatus.hpp"
52 
53 /*
54  * TODO: add standard library includes here
55  */
56 //#include <cstddef> // std::size_t
57 //#include <string> // std::string
58 #include <string_view> // std::string_view
59 //#include <utility> // std::pair
60 //#include <vector> // std::vector
61 
63 
64  /*
65  * CONSTANTS
66  */
67 
70 
71  /*
72  * TODO: add constants for the algorithm here
73  *
74  * NOTE: choose a distinct prefix to avoid name conflicts with other algorithms
75  * (or use a namespace)
76  */
77 // inline constexpr auto ...{...};
78 
80 
81  /*
82  * DECLARATION
83  */
84 
85  /*
86  * TODO: change name and description of the class
87  */
88 
90 
94  class Empty final : public Module::Analyzer::Thread {
95  // for convenience
96 
97  /*
98  * TODO: add aliases of used data structures
99  */
101 
102 // using QueryStruct = Struct::QueryStruct;
106 
107 // using StringString = std::pair<std::string, std::string>;
108 
109  public:
112 
113  /*
114  * TODO: change the names of the constructors
115  */
116 
117  Empty(
118  Main::Database& dbBase,
119  const ThreadOptions& threadOptions,
120  const ThreadStatus& threadStatus
121  );
122  Empty(
123  Main::Database& dbBase,
124  const ThreadOptions& threadOptions
125  );
126 
130 
131  std::string_view getName() const override;
132 
136 
137  void onAlgoInitTarget() override;
138  void onAlgoInit() override;
139  void onAlgoTick() override;
140  void onAlgoPause() override;
141  void onAlgoUnpause() override;
142  void onAlgoClear() override;
143 
147 
148  void parseAlgoOption() override;
149  void checkAlgoOptions() override;
150  void resetAlgo() override;
151 
153 
154  private:
155  // algorithm options
156  struct Entries {
157  /*
158  * TODO: add members for algorithm options here
159  */
160  //bool combineSources{true};
161  } algoConfig;
162 
163  // algorithm queries
164  /*
165  * TODO: decide whether queries are needed
166  *
167  * use QueryStruct (or vectors of it) to store queries
168  */
169 
170  // algorithm state
171  /*
172  * TODO: add additional private member variables here
173  */
174  //bool firstTick{true};
175 
176  // algorithm functions
177  /*
178  * TODO: add internal algorithm functions here
179  */
180 
181  // query functions
182  /*
183  * TODO: decide whether queries are needed
184  */
185 // void initQueries() override;
186 // void deleteQueries() override;
187 
188  // internal helper functions
189  /*
190  * TODO: add additional helper functions here
191  */
192  };
193 
194 } /* namespace crawlservpp::Module::Analyzer::Algo */
195 
196 /*
197  * TODO: change the name of the include guard
198  */
199 #endif /* MODULE_ANALYZER_ALGO_EMPTY_HPP_ */
void resetAlgo() override
Resets the configuration options for the algorithm.
Definition: Empty.cpp:309
Namespace for algorithm classes.
Definition: All.cpp:52
void checkAlgoOptions() override
Checks the configuration options for the algorithm.
Definition: Empty.cpp:297
Abstract class providing thread functionality to algorithm (child) classes.
Definition: Thread.hpp:84
void parseAlgoOption() override
Parses a configuration option for the algorithm.
Definition: Empty.cpp:278
Thread status containing its ID, status message, pause state, and progress.
Definition: ThreadStatus.hpp:54
void onAlgoPause() override
Does nothing.
Definition: Empty.cpp:254
void onAlgoUnpause() override
Does nothing.
Definition: Empty.cpp:264
Thread options containing the name of the module run, as well as the IDs of the website, URL list, and configuration used.
Definition: ThreadOptions.hpp:40
void onAlgoTick() override
Does nothing.
Definition: Empty.cpp:204
Class handling database access for the command-and-control and its threads.
Definition: Database.hpp:366
std::string_view getName() const override
Returns the name of the algorithm.
Definition: Empty.cpp:91
void onAlgoInit() override
Initializes the algorithm and processes its input.
Definition: Empty.cpp:144
Class for analyzer exceptions to be used by algorithms.
Definition: Thread.hpp:242
Empty(Main::Database &dbBase, const ThreadOptions &threadOptions, const ThreadStatus &threadStatus)
Continues a previously interrupted algorithm run.
Definition: Empty.cpp:54
Structure containing all the data needed to keep the status of a thread updated.
Definition: StatusSetter.hpp:57
void onAlgoClear() override
Does nothing.
Definition: Empty.cpp:271
Empty algorithm template.
Definition: Empty.hpp:94
void onAlgoInitTarget() override
Initializes the target table for the algorithm.
Definition: Empty.cpp:108