reactive_function.h
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #ifndef REACTIVE_FUNCTION_H
8 #define REACTIVE_FUNCTION_H
9 
11 #include <sol/sol.hpp>
12 
13 class TimeseriesRef;
14 class CreatedSeriesBase;
15 class CreatedSeriesTime;
16 class CreatedSeriesXY;
17 
18 namespace PJ
19 {
21 {
23 
24  std::pair<double, double> at(unsigned i) const;
25 
26  void set(unsigned index, double x, double y);
27 
28  double atTime(double t) const;
29 
30  unsigned size() const;
31 
33 };
34 
35 //-----------------------
36 
38 {
39  CreatedSeriesBase(PlotDataMapRef* data_map, const std::string& name, bool timeseries);
40 
41  std::pair<double, double> at(unsigned i) const;
42 
43  void clear();
44 
45  void push_back(double x, double y);
46 
47  unsigned size() const;
48 
50 };
51 
53 {
54  CreatedSeriesTime(PlotDataMapRef* data_map, const std::string& name);
55 };
56 
58 {
59  CreatedSeriesXY(PlotDataMapRef* data_map, const std::string& name);
60 };
61 
62 //-----------------------
63 
65 {
66 public:
67  ReactiveLuaFunction(PlotDataMapRef* data_map, QString lua_global, QString lua_function,
68  QString lua_library);
69 
70  const char* name() const override
71  {
72  return "ReactiveLuaFunction";
73  }
74 
75  int numInputs() const override
76  {
77  return -1;
78  }
79 
80  int numOutputs() const override
81  {
82  return -1;
83  }
84 
85  void reset() override;
86 
87  void setTimeTracker(double time_tracker_value);
88 
89  void calculate() override;
90 
91  const std::vector<std::string>& createdCurves() const
92  {
93  return _created_curves;
94  }
95 
96  bool xmlSaveState(QDomDocument& doc, QDomElement& parent_element) const override;
97 
98  bool xmlLoadState(const QDomElement& parent_element) override;
99 
100  QString getGlobalCode()
101  {
102  return QString::fromStdString(_global_code);
103  }
104 
105  QString getFunctionCode()
106  {
107  return QString::fromStdString(_function_code);
108  }
109 
110 protected:
111  void prepareLua();
112 
113  double _tracker_value = 0;
114  std::string _global_code;
115  std::string _function_code;
116  std::string _library_code;
117 
118  std::vector<std::string> _created_curves;
119 
122 
126 
127 private:
128  void init();
129 };
130 
131 } // namespace PJ
132 
133 #endif // REACTIVE_FUNCTION_H
sol::usertype< TimeseriesRef > _timeseries_ref
PJ::PlotData * _plot_data
Generic interface for a multi input - multi output transformation function. Contrariwise to other plu...
void init(const M_string &remappings)
const std::vector< std::string > & createdCurves() const
sol::protected_function _lua_function
int numInputs() const override
double atTime(double t) const
std::pair< double, double > at(unsigned i) const
std::vector< std::string > _created_curves
unsigned size() const
sol::usertype< CreatedSeriesXY > _created_scatter
const char * name() const override
Name of the plugin type, NOT the particular instance.
void clear(lua_State *L, int table_index)
Definition: sol.hpp:11710
TimeseriesRef(PlotData *data)
sol::usertype< CreatedSeriesTime > _created_timeseries
Definition: format.h:895
int numOutputs() const override


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:39