crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
AlgoThreadProperties.hpp
Go to the documentation of this file.
1 /*
2  *
3  * ---
4  *
5  * Copyright (C) 2023 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  * AlgoThreadProperties.hpp
24  *
25  * Properties of an algorithm thread.
26  *
27  * Created on: Mar 12, 2019
28  * Author: ans
29  */
30 
31 #ifndef STRUCT_ALGOTHREADPROPERTIES_HPP_
32 #define STRUCT_ALGOTHREADPROPERTIES_HPP_
33 
34 #include "../Main/Database.hpp"
35 #include "../Main/Exception.hpp"
36 #include "../Struct/ThreadOptions.hpp"
37 #include "../Struct/ThreadStatus.hpp"
38 
39 #include <cstdint> // std::uint32_t
40 #include <optional> // std::optional
41 
44 
49 
51  std::uint32_t algoId;
52 
55 
57 
61 
65 
68 
72 
74 
83  std::uint32_t setAlgoId,
84  const ThreadOptions& setOptions,
85  Main::Database& setDatabase
86  )
87  : algoId(setAlgoId),
88  options(setOptions),
89  dbBase(setDatabase)
90  {}
91 
93 
108  std::uint32_t setAlgoId,
109  const ThreadOptions& setOptions,
110  const ThreadStatus& setStatus,
111  Main::Database& setDatabase
112  )
113  : algoId(setAlgoId),
114  options(setOptions),
115  status(setStatus),
116  dbBase(setDatabase) {
117  if(status.id == 0) {
118  throw Main::Exception(
119  "AlgoThreadProperties::AlgoThreadProperties():"
120  " Invalid thread ID for previously interrupted algorithm (is zero)"
121  );
122  }
123  }
124 
126  virtual ~AlgoThreadProperties() = default;
127 
129 
132 
136 
139 
142 
145 
147  };
148 
149 } /* namespace crawlservpp::Struct */
150 
151 #endif /* STRUCT_ALGOTHREADPROPERTIES_HPP_ */
AlgoThreadProperties(std::uint32_t setAlgoId, const ThreadOptions &setOptions, Main::Database &setDatabase)
Constructor setting properties for a newly created thread.
Definition: AlgoThreadProperties.hpp:82
Thread status containing its ID, status message, pause state, and progress.
Definition: ThreadStatus.hpp:54
Main::Database & dbBase
Reference to the database instance used by the thread.
Definition: AlgoThreadProperties.hpp:67
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
ThreadOptions options
Options used for the algorithm thread.
Definition: AlgoThreadProperties.hpp:54
std::uint32_t algoId
The ID of the algorithm run by the thread.
Definition: AlgoThreadProperties.hpp:51
Class handling database access for the command-and-control and its threads.
Definition: Database.hpp:366
AlgoThreadProperties(std::uint32_t setAlgoId, const ThreadOptions &setOptions, const ThreadStatus &setStatus, Main::Database &setDatabase)
Constructor setting properties for a previously interrupted thread.
Definition: AlgoThreadProperties.hpp:107
AlgoThreadProperties & operator=(AlgoThreadProperties &)=delete
Deleted copy assignment operator.
virtual ~AlgoThreadProperties()=default
Default destructor.
Base class for all exceptions thrown by the application.
Definition: Exception.hpp:90
Namespace for data structures.
Definition: AlgoThreadProperties.hpp:43
Properties of an algorithm thread.
Definition: AlgoThreadProperties.hpp:46
std::uint64_t id
The ID of the thread.
Definition: ThreadStatus.hpp:59
ThreadStatus status
Status of the algorithm thread.
Definition: AlgoThreadProperties.hpp:60