parameter.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_PARAMETER
20 #define ATOM_QUERY_PARAMETER
21 
22 
23 #include <string>
24 
25 #include "tools/dvalue.h"
26 #include "query/results.h"
27 #include "query/condition.h"
28 
29 
30 namespace Atom
31 {
32  namespace Query
33  {
34  enum class ParameterType;
35  class Parameter;
36  }
37 }
38 
39 
40 enum class Atom::Query::ParameterType
41 {
42  kField
43  ,kPosition
44 };
45 
47 {
48  public:
49  using Ptr = std::shared_ptr<Parameter>;
50 
51  Parameter(std::string name, Tools::DValue value, bool editable);
52  Parameter(std::string name, Query::Field::Position field_position, std::string related_action, bool editable);
53 
54  ParameterType get_parameter_type() const { return parameter_type_; }
55  std::string get_name() const { return name_; }
56  std::string get_error() const { return error_; }
57  bool get_editable() const { return editable_; }
58  Tools::DValue& get_value()
59  {
60  auto& var = value_;
61  return var;
62  }
63  Query::Field::Position& get_field_position()
64  {
65  auto& var = field_position_;
66  return var;
67  }
68  std::string get_related_action() const { return related_action_; }
69  Query::Condition<Ptr>::Ptr& get_condition()
70  {
71  auto& var = condition_;
72  return var;
73  }
74 
75  void set_parameter_type(ParameterType parameter_type) { parameter_type_ = parameter_type; }
76  void set_name(std::string name) { name_ = name; }
77  void set_error(std::string error) { error_ = error; }
78  void set_editable(bool editable) { editable_ = editable; }
79  void set_value(Tools::DValue value) { value_ = value; }
80  void set_related_action(std::string related_action) { related_action_ = related_action; }
81 
82  void SetupCondition_(std::string identifier, Query::ConditionType type, Query::Condition<Ptr>::Functor functor);
83 
84  private:
85  ParameterType parameter_type_;
86  std::string name_;
87  std::string error_;
88  bool editable_;
89  Tools::DValue value_;
90  Query::Field::Position field_position_;
91  std::string related_action_;
92  Query::Condition<Ptr>::Ptr condition_;
93 };
94 
95 #endif // ATOM_QUERY_PARAMETER
Definition: parameter.h:47
Definition: dvalue.h:48
Definition: field.h:43