Loading...
Searching...
No Matches
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 NAF_QUERY_PARAMETER
20#define NAF_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
30namespace NAF
31{
32 namespace Query
33 {
34 enum class ParameterType;
35 class Parameter;
36 }
37}
38
39
40enum class NAF::Query::ParameterType
41{
42 kField
43 ,kPosition
44};
45
47{
48 public:
49 using Ptr = std::shared_ptr<Parameter>;
50 using Vector = std::vector<Ptr>;
51
52 Parameter(std::string name, Tools::DValue::Ptr value, bool editable);
53 Parameter(std::string name, Query::Field::Position field_position, std::string related_action, bool editable);
54
55 ParameterType get_parameter_type() const { return parameter_type_; }
56 std::string get_name() const { return name_; }
57 std::string get_error() const { return error_; }
58 bool get_editable() const { return editable_; }
59 Tools::DValue::Ptr& get_value()
60 {
61 auto& var = value_;
62 return var;
63 }
64 Query::Field::Position& get_field_position()
65 {
66 auto& var = field_position_;
67 return var;
68 }
69 std::string get_related_action() const { return related_action_; }
70 Query::Condition<Ptr>::Ptr& get_condition()
71 {
72 auto& var = condition_;
73 return var;
74 }
75
76 void set_parameter_type(ParameterType parameter_type) { parameter_type_ = parameter_type; }
77 void set_name(std::string name) { name_ = name; }
78 void set_error(std::string error) { error_ = error; }
79 void set_editable(bool editable) { editable_ = editable; }
80 void set_value(Tools::DValue::Ptr value) { value_ = value; }
81 void set_related_action(std::string related_action) { related_action_ = related_action; }
82
83 std::string ToString_();
84 std::string& StringValue_();
85 int& IntValue_();
86 bool& BoolValue_();
87 float& FloatValue_();
88 void SetupCondition_(std::string identifier, Query::ConditionType type, Query::Condition<Ptr>::Functor functor);
89
90 private:
91 ParameterType parameter_type_;
92 std::string name_;
93 std::string error_;
94 bool editable_;
95 Tools::DValue::Ptr value_;
96 Query::Field::Position field_position_;
97 std::string related_action_;
98 Query::Condition<Ptr>::Ptr condition_;
99};
100
101#endif // NAF_QUERY_PARAMETER
Definition parameter.h:47
Definition field.h:43