condition.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2023 Jose F Rivas C <josefelixrc7@gmail.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef ATOM_QUERY_CONDITION
20 #define ATOM_QUERY_CONDITION
21 
22 
23 #include "query/results.h"
24 #include "tools/output_logger.h"
25 
26 
27 namespace Atom
28 {
29  namespace Query
30  {
31  enum class ConditionType;
32  class Condition;
33  }
34 }
35 
36 
37 enum class Atom::Query::ConditionType
38 {
39  kWarning
40  ,kError
41 };
42 
44 {
45  public:
46  using Ptr = std::shared_ptr<Condition>;
47  using Functor = std::function<bool(Results::Ptr)>;
48 
49  Condition(std::string identifier, ConditionType type, Functor functor);
50 
51  ConditionType get_type() const { return type_; }
52  std::string get_identifier() const { return identifier_; }
53  Functor& get_functor()
54  {
55  auto& var = functor_;
56  return var;
57  }
58 
59  void set_identifier(std::string identifier) { identifier_ = identifier; }
60  void set_type(ConditionType type) { type_ = type; }
61 
62  bool VerifyCondition_(Results::Ptr results);
63 
64  private:
65  std::string identifier_;
66  ConditionType type_;
67  Functor functor_;
68 };
69 
70 #endif // ATOM_QUERY_CONDITION
Definition: condition.h:44