itpp_sci  1.0.0
it++ based simulation framework for scicoslab, scilab and scipy
_sci_emu.hpp
1 /*xxx
2  * \brief templated EMULATOR of SCI_API
3  * \author maki
4  */
5 #ifndef SCI_EMU_HPP
6 #define SCI_EMU_HPP
7 
8 #include "sci\_sci_base.hpp"
9 #include "sci\_sci_create_sci_var.hpp"
10 
11 namespace SCI
12 {
13 
15 
16 void sci_var_value_get(sci_var* p_v, double *p_double);
17 void sci_var_value_get(sci_var* p_v, vec *p_vec);
18 void sci_var_value_get(sci_var* p_v, mat *p_mat);
19 
20 void sci_var_value_get(sci_var* p_v, int *p_int);
21 void sci_var_value_get(sci_var* p_v, ivec *p_ivec);
22 void sci_var_value_get(sci_var* p_v, imat *p_imat);
23 
24 void sci_var_value_get(sci_var* p_v, bool *p_bool);
25 void sci_var_value_get(sci_var* p_v, bvec *p_bvec);
26 void sci_var_value_get(sci_var* p_v, bmat *p_bmat);
27 
28 void sci_var_value_get(sci_var* p_v, complex<double> *p_complex);
29 void sci_var_value_get(sci_var* p_v, cvec *p_cvec);
30 void sci_var_value_get(sci_var* p_v, cmat *p_cmat);
31 
33 sci_base* EMU_SCI_CREATE(int sci_type);
34 
36 void EMU_SCI_EXEC(sci_base *p_dev, int sci_command);
37 
39 void EMU_SCI_DESTROY(sci_base *p_dev);
40 
41 //--------------- TEMPLATES --------------
43 template <class P >
44 void EMU_SCI_SET(sci_base *p_dev, int sci_param, P param)
45 {
46  sci_var *p_v;
47 
48  p_v = create_sci_var(&param);
49  sci_set(p_dev, sci_param, p_v);
50  delete(p_v);
51 }
52 
54 template <class P >
55 P EMU_SCI_GET(sci_base *p_dev, int sci_param)
56 {
57  sci_var *p_v;
58  P y;
59 
60  p_v = sci_get(p_dev, sci_param);
61  sci_var_value_get(p_v, &y);
62  delete(p_v);
63 
64  return (y);
65 }
66 
68 template <class Y, class CE>
69 Y EMU_SCI_GEN(sci_base *p_dev, CE v_ce)
70 {
71  Y y;
72  sci_var *p_y, *p_v_ce;
73 
74  p_v_ce = create_sci_var(&v_ce);
75  p_y = sci_gen(p_dev, p_v_ce);
76  sci_var_value_get(p_y, &y);
77  delete(p_y);
78  delete(p_v_ce);
79 
80  return (y);
81 }
82 
84 template <class Y, class CE, class X>
85 Y EMU_SCI_PROC(sci_base *p_dev, CE v_ce, X v_x)
86 {
87  Y y;
88  sci_var *p_y, *p_v_ce, *p_v_x;
89 
90  p_v_ce = create_sci_var(&v_ce);
91  p_v_x = create_sci_var(&v_x);
92  p_y = sci_proc(p_dev, p_v_ce, p_v_x);
93  sci_var_value_get(p_y, &y);
94  delete(p_y);
95  delete(p_v_ce);
96  delete(p_v_x);
97 
98  return (y);
99 
100 }
101 
103 
104 }
105 
106 #endif
SCI layer implements SCI_API interface as wrappers for SIM layer models.
Definition: _sci_create_sci_var.cpp:8