Xcos MVC: implement clone / delete on the Model side
[scilab.git] / scilab / modules / scicos / src / cpp / view_scilab / ModelAdapter.cpp
1 /*
2  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  *  Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
4  *
5  *  This file must be used under the terms of the CeCILL.
6  *  This source file is licensed as described in the file COPYING, which
7  *  you should have received as part of this distribution.  The terms
8  *  are also available at
9  *  http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
10  *
11  */
12
13 #include <string>
14 #include <vector>
15 #include <algorithm>
16 #include <sstream>
17
18 #include "list.hxx"
19 #include "mlist.hxx"
20 #include "double.hxx"
21 #include "string.hxx"
22
23 #include "Controller.hxx"
24 #include "ModelAdapter.hxx"
25 #include "ports_management.hxx"
26
27 extern "C" {
28 #include "sci_malloc.h"
29 #include "charEncoding.h"
30 }
31
32 namespace org_scilab_modules_scicos
33 {
34 namespace view_scilab
35 {
36 namespace
37 {
38
39 const std::wstring diagram (L"diagram");
40
41 struct sim
42 {
43
44     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
45     {
46         model::Block* adaptee = adaptor.getAdaptee();
47
48         // First, extract the function Name
49         std::string name;
50         controller.getObjectProperty(adaptee->id(), adaptee->kind(), SIM_FUNCTION_NAME, name);
51         types::String* Name = new types::String(1, 1);
52         Name->set(0, name.data());
53
54         // Then the Api. If it is zero, then just return the Name. Otherwise, return a list containing both.
55         int api;
56         controller.getObjectProperty(adaptee->id(), adaptee->kind(), SIM_FUNCTION_API, api);
57
58         if (api == 0)
59         {
60             return Name;
61         }
62         else
63         {
64             types::Double* Api = new types::Double(static_cast<double>(api));
65             types::List* o = new types::List();
66             o->set(0, Name);
67             o->set(1, Api);
68             return o;
69         }
70     }
71
72     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
73     {
74         model::Block* adaptee = adaptor.getAdaptee();
75
76         if (v->getType() == types::InternalType::ScilabString)
77         {
78             types::String* current = v->getAs<types::String>();
79             if (current->getSize() != 1)
80             {
81                 return false;
82             }
83
84             char* c_str = wide_string_to_UTF8(current->get(0));
85             std::string name = std::string(c_str);
86             FREE(c_str);
87
88             // If the input is a scalar string, then the functionApi is 0.
89             int api = 0;
90
91             controller.setObjectProperty(adaptee->id(), adaptee->kind(), SIM_FUNCTION_NAME, name);
92             controller.setObjectProperty(adaptee->id(), adaptee->kind(), SIM_FUNCTION_API, api);
93         }
94         else if (v->getType() == types::InternalType::ScilabList)
95         {
96             // If the input is a 2-sized list, then it must be string and positive integer.
97             types::List* current = v->getAs<types::List>();
98             if (current->getSize() != 2)
99             {
100                 return false;
101             }
102             if (current->get(0)->getType() != types::InternalType::ScilabString || current->get(1)->getType() != types::InternalType::ScilabDouble)
103             {
104                 return false;
105             }
106
107             types::String* Name = current->get(0)->getAs<types::String>();
108             if (Name->getSize() != 1)
109             {
110                 return false;
111             }
112             char* c_str = wide_string_to_UTF8(Name->get(0));
113             std::string name = std::string(c_str);
114             FREE(c_str);
115
116             types::Double* Api = current->get(1)->getAs<types::Double>();
117             if (Api->getSize() != 1)
118             {
119                 return false;
120             }
121             double api = Api->get(0);
122             if (floor(api) != api)
123             {
124                 return false;
125             }
126             int api_int = static_cast<int>(api);
127
128             controller.setObjectProperty(adaptee->id(), adaptee->kind(), SIM_FUNCTION_NAME, name);
129             controller.setObjectProperty(adaptee->id(), adaptee->kind(), SIM_FUNCTION_API, api_int);
130         }
131         else
132         {
133             return false;
134         }
135         return true;
136     }
137 };
138
139 struct in
140 {
141
142     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
143     {
144         return get_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, INPUTS, controller);
145     }
146
147     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
148     {
149         return update_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, INPUTS, controller, v);
150     }
151 };
152
153 struct in2
154 {
155
156     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
157     {
158         return get_ports_property<ModelAdapter, DATATYPE_COLS>(adaptor, INPUTS, controller);
159     }
160
161     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
162     {
163         return set_ports_property<ModelAdapter, DATATYPE_COLS>(adaptor, INPUTS, controller, v);
164     }
165 };
166
167 struct intyp
168 {
169
170     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
171     {
172         return get_ports_property<ModelAdapter, DATATYPE_TYPE>(adaptor, INPUTS, controller);
173     }
174
175     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
176     {
177         return set_ports_property<ModelAdapter, DATATYPE_TYPE>(adaptor, INPUTS, controller, v);
178     }
179 };
180
181 struct out
182 {
183
184     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
185     {
186         return get_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, OUTPUTS, controller);
187     }
188
189     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
190     {
191         return update_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, OUTPUTS, controller, v);
192     }
193 };
194
195 struct out2
196 {
197
198     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
199     {
200         return get_ports_property<ModelAdapter, DATATYPE_COLS>(adaptor, OUTPUTS, controller);
201     }
202
203     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
204     {
205         return set_ports_property<ModelAdapter, DATATYPE_COLS>(adaptor, OUTPUTS, controller, v);
206     }
207 };
208
209 struct outtyp
210 {
211
212     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
213     {
214         return get_ports_property<ModelAdapter, DATATYPE_TYPE>(adaptor, OUTPUTS, controller);
215     }
216
217     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
218     {
219         return set_ports_property<ModelAdapter, DATATYPE_TYPE>(adaptor, OUTPUTS, controller, v);
220     }
221 };
222
223 struct evtin
224 {
225
226     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
227     {
228         return get_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, EVENT_INPUTS, controller);
229     }
230
231     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
232     {
233         return update_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, EVENT_INPUTS, controller, v);
234     }
235 };
236
237 struct evtout
238 {
239
240     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
241     {
242         return get_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, EVENT_OUTPUTS, controller);
243     }
244
245     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
246     {
247         return update_ports_property<ModelAdapter, DATATYPE_ROWS>(adaptor, EVENT_OUTPUTS, controller, v);
248     }
249 };
250
251 struct state
252 {
253
254     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
255     {
256         model::Block* adaptee = adaptor.getAdaptee();
257
258         std::vector<double> state;
259         controller.getObjectProperty(adaptee->id(), adaptee->kind(), STATE, state);
260
261         double* data;
262         types::Double* o = new types::Double((int)state.size(), 1, &data);
263
264 #ifdef _MSC_VER
265         std::copy(state.begin(), state.end(), stdext::checked_array_iterator<double*>(data, state.size()));
266 #else
267         std::copy(state.begin(), state.end(), data);
268 #endif
269         return o;
270     }
271
272     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
273     {
274
275         if (v->getType() != types::InternalType::ScilabDouble)
276         {
277             return false;
278         }
279
280         types::Double* current = v->getAs<types::Double>();
281         if (current->getCols() != 0 && current->getCols() != 1)
282         {
283             return false;
284         }
285
286         model::Block* adaptee = adaptor.getAdaptee();
287
288         std::vector<double> state (current->getSize());
289         std::copy(current->getReal(), current->getReal() + current->getSize(), state.begin());
290
291         controller.setObjectProperty(adaptee->id(), adaptee->kind(), STATE, state);
292         return true;
293     }
294 };
295
296 struct dstate
297 {
298
299     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
300     {
301         model::Block* adaptee = adaptor.getAdaptee();
302
303         std::vector<double> dstate;
304         controller.getObjectProperty(adaptee->id(), adaptee->kind(), DSTATE, dstate);
305
306         double* data;
307         types::Double* o = new types::Double((int)dstate.size(), 1, &data);
308
309 #ifdef _MSC_VER
310         std::copy(dstate.begin(), dstate.end(), stdext::checked_array_iterator<double*>(data, dstate.size()));
311 #else
312         std::copy(dstate.begin(), dstate.end(), data);
313 #endif
314         return o;
315     }
316
317     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
318     {
319
320         if (v->getType() != types::InternalType::ScilabDouble)
321         {
322             return false;
323         }
324
325         types::Double* current = v->getAs<types::Double>();
326         if (current->getCols() != 0 && current->getCols() != 1)
327         {
328             return false;
329         }
330
331         model::Block* adaptee = adaptor.getAdaptee();
332
333         std::vector<double> dstate (current->getSize());
334         std::copy(current->getReal(), current->getReal() + current->getSize(), dstate.begin());
335
336         controller.setObjectProperty(adaptee->id(), adaptee->kind(), DSTATE, dstate);
337         return true;
338     }
339 };
340
341 struct odstate
342 {
343
344     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
345     {
346         // silent unused parameter warnings
347         (void) adaptor;
348         (void) controller;
349
350         // FIXME: implement as a scicos encoded list of values
351
352         // Return a default empty list.
353         return new types::List();
354     }
355
356     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
357     {
358         if (v->getType() != types::InternalType::ScilabList)
359         {
360             return false;
361         }
362
363         types::List* current = v->getAs<types::List>();
364
365         if (current->getSize() == 0)
366         {
367             return true;
368         }
369         else
370         {
371             // silent unused parameter warnings
372             (void) adaptor;
373             (void) v;
374             (void) controller;
375
376             // FIXME: implement as a scicos encoded list of values
377             return false;
378         }
379     }
380 };
381
382 struct rpar
383 {
384
385     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
386     {
387         model::Block* adaptee = adaptor.getAdaptee();
388
389         std::vector<ScicosID> children;
390         controller.getObjectProperty(adaptee->id(), adaptee->kind(), CHILDREN, children);
391
392         if (children.empty())
393         {
394             std::vector<double> rpar;
395             controller.getObjectProperty(adaptee->id(), adaptee->kind(), RPAR, rpar);
396
397             double *data;
398             types::Double* o = new types::Double((int)rpar.size(), 1, &data);
399 #ifdef _MSC_VER
400             std::copy(rpar.begin(), rpar.end(), stdext::checked_array_iterator<double*>(data, rpar.size()));
401 #else
402             std::copy(rpar.begin(), rpar.end(), data);
403 #endif
404             return o;
405         }
406         else
407         {
408             types::MList* o = new types::MList();
409             types::String* Diagram = new types::String(diagram.c_str());
410             o->set(0, Diagram);
411
412             // FIXME: return the full diagram contained in children
413             return o;
414         }
415     }
416
417     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
418     {
419         model::Block* adaptee = adaptor.getAdaptee();
420
421         if (v->getType() == types::InternalType::ScilabDouble)
422         {
423             types::Double* current = v->getAs<types::Double>();
424             if (current->getCols() != 0 && current->getCols() != 1)
425             {
426                 return false;
427             }
428
429             std::vector<double> rpar (current->getSize());
430             for (int i = 0; i < current->getSize(); ++i)
431             {
432                 rpar[i] = current->get(i);
433             }
434
435             controller.setObjectProperty(adaptee->id(), adaptee->kind(), RPAR, rpar);
436             return true;
437         }
438         else if (v->getType() == types::InternalType::ScilabString)
439         {
440             // Allow Text blocs to define strings in rpar
441             return true;
442         }
443         else
444         {
445             // FIXME: set rpar when input is a diagram (MList)
446             return false;
447         }
448     }
449 };
450
451 static double toDouble(const int a)
452 {
453     return static_cast<double>(a);
454 }
455
456 struct ipar
457 {
458
459     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
460     {
461         model::Block* adaptee = adaptor.getAdaptee();
462
463         std::vector<int> ipar;
464         controller.getObjectProperty(adaptee->id(), adaptee->kind(), IPAR, ipar);
465
466         double *data;
467         types::Double* o = new types::Double((int)ipar.size(), 1, &data);
468
469 #ifdef _MSC_VER
470         std::transform(ipar.begin(), ipar.end(), stdext::checked_array_iterator<double*>(data, ipar.size()), toDouble);
471 #else
472         std::transform(ipar.begin(), ipar.end(), data, toDouble);
473 #endif
474         return o;
475     }
476
477     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
478     {
479
480         if (v->getType() != types::InternalType::ScilabDouble)
481         {
482             return false;
483         }
484
485         types::Double* current = v->getAs<types::Double>();
486         if (current->getCols() != 0 && current->getCols() != 1)
487         {
488             return false;
489         }
490
491         model::Block* adaptee = adaptor.getAdaptee();
492
493         std::vector<int> ipar (current->getSize());
494         for (int i = 0; i < current->getSize(); ++i)
495         {
496             if (floor(current->get(i)) != current->get(i))
497             {
498                 return false;
499             }
500             ipar[i] = static_cast<int>(current->get(i));
501         }
502
503         controller.setObjectProperty(adaptee->id(), adaptee->kind(), IPAR, ipar);
504         return true;
505     }
506 };
507
508 struct opar
509 {
510
511     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
512     {
513         // silent unused parameter warnings
514         (void) adaptor;
515         (void) controller;
516
517         // FIXME: implement as a scicos encoded list of values
518
519         // Return a default empty list.
520         return new types::List();
521     }
522
523     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
524     {
525         if (v->getType() != types::InternalType::ScilabList)
526         {
527             return false;
528         }
529
530         types::List* current = v->getAs<types::List>();
531
532         if (current->getSize() == 0)
533         {
534             return true;
535         }
536         else
537         {
538             // silent unused parameter warnings
539             (void) adaptor;
540             (void) v;
541             (void) controller;
542
543             // FIXME: implement as a scicos encoded list of values
544             return false;
545         }
546     }
547 };
548
549 struct blocktype
550 {
551
552     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
553     {
554         model::Block* adaptee = adaptor.getAdaptee();
555
556         std::string type;
557         controller.getObjectProperty(adaptee->id(), adaptee->kind(), SIM_BLOCKTYPE, type);
558
559         types::String* o = new types::String(type.c_str());
560         return o;
561     }
562
563     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
564     {
565         model::Block* adaptee = adaptor.getAdaptee();
566
567         if (v->getType() != types::InternalType::ScilabString)
568         {
569             return false;
570         }
571
572         types::String* current = v->getAs<types::String>();
573         if (current->getSize() != 1)
574         {
575             return false;
576         }
577
578         char* c_str = wide_string_to_UTF8(current->get(0));
579         std::string type (c_str);
580         FREE(c_str);
581
582         // the value validation is performed on the model
583         return controller.setObjectProperty(adaptee->id(), adaptee->kind(), SIM_BLOCKTYPE, type) != FAIL;
584     }
585 };
586
587 struct firing
588 {
589
590     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
591     {
592         return get_ports_property<ModelAdapter, FIRING>(adaptor, EVENT_OUTPUTS, controller);
593     }
594
595     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
596     {
597         return set_ports_property<ModelAdapter, FIRING>(adaptor, EVENT_OUTPUTS, controller, v);
598     }
599 };
600
601 struct dep_ut
602 {
603
604     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
605     {
606         model::Block* adaptee = adaptor.getAdaptee();
607
608         std::vector<int> dep_ut;
609         controller.getObjectProperty(adaptee->id(), adaptee->kind(), SIM_DEP_UT, dep_ut);
610
611         int* dep;
612         types::Bool* o = new types::Bool(1, 2, &dep);
613
614         dep[0] = dep_ut[0];
615         dep[1] = dep_ut[1];
616
617         return o;
618     }
619
620     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
621     {
622         model::Block* adaptee = adaptor.getAdaptee();
623
624         if (v->getType() != types::InternalType::ScilabBool)
625         {
626             return false;
627         }
628
629         types::Bool* current = v->getAs<types::Bool>();
630         if (current->getRows() != 1 || current->getCols() != 2)
631         {
632             return false;
633         }
634
635         std::vector<int> dep_ut (2);
636         dep_ut[0] = current->get(0);
637         dep_ut[1] = current->get(1);
638
639         controller.setObjectProperty(adaptee->id(), adaptee->kind(), SIM_DEP_UT, dep_ut);
640         return true;
641     }
642 };
643
644 struct label
645 {
646
647     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
648     {
649         model::Block* adaptee = adaptor.getAdaptee();
650
651         std::string label;
652         controller.getObjectProperty(adaptee->id(), adaptee->kind(), LABEL, label);
653
654         types::String* o = new types::String(1, 1);
655         o->set(0, label.data());
656
657         return o;
658     }
659
660     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
661     {
662         if (v->getType() != types::InternalType::ScilabString)
663         {
664             return false;
665         }
666
667         types::String* current = v->getAs<types::String>();
668         if (current->getSize() != 1)
669         {
670             return false;
671         }
672
673         model::Block* adaptee = adaptor.getAdaptee();
674
675         std::string label;
676         char* c_str = wide_string_to_UTF8(current->get(0));
677         label = std::string(c_str);
678         FREE(c_str);
679
680         controller.setObjectProperty(adaptee->id(), adaptee->kind(), LABEL, label);
681         return true;
682     }
683 };
684
685 struct nzcross
686 {
687
688     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
689     {
690         model::Block* adaptee = adaptor.getAdaptee();
691
692         int nzcross;
693         controller.getObjectProperty(adaptee->id(), adaptee->kind(), NZCROSS, nzcross);
694
695         types::Double* o = new types::Double(static_cast<double>(nzcross));
696
697         return o;
698     }
699
700     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
701     {
702
703         if (v->getType() != types::InternalType::ScilabDouble)
704         {
705             return false;
706         }
707
708         types::Double* current = v->getAs<types::Double>();
709         if (current->getSize() != 1)
710         {
711             return false;
712         }
713         if (floor(current->get(0)) != current->get(0))
714         {
715             return false;
716         }
717
718         model::Block* adaptee = adaptor.getAdaptee();
719
720         int nzcross = static_cast<int>(current->get(0));
721
722         controller.setObjectProperty(adaptee->id(), adaptee->kind(), NZCROSS, nzcross);
723         return true;
724     }
725 };
726
727 struct nmode
728 {
729
730     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
731     {
732         model::Block* adaptee = adaptor.getAdaptee();
733
734         int nmode;
735         controller.getObjectProperty(adaptee->id(), adaptee->kind(), NMODE, nmode);
736
737         types::Double* o = new types::Double(static_cast<double>(nmode));
738
739         return o;
740     }
741
742     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
743     {
744
745         if (v->getType() != types::InternalType::ScilabDouble)
746         {
747             return false;
748         }
749
750         types::Double* current = v->getAs<types::Double>();
751         if (current->getSize() != 1)
752         {
753             return false;
754         }
755         if (floor(current->get(0)) != current->get(0))
756         {
757             return false;
758         }
759
760         model::Block* adaptee = adaptor.getAdaptee();
761
762         int nmode = static_cast<int>(current->get(0));
763
764         controller.setObjectProperty(adaptee->id(), adaptee->kind(), NMODE, nmode);
765         return true;
766     }
767 };
768
769 struct equations
770 {
771
772     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
773     {
774         // silent unused parameter warnings
775         (void) adaptor;
776         (void) controller;
777
778         // FIXME: implement as a stored modelica equations
779
780         // Return a default empty list.
781         return new types::List();
782     }
783
784     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
785     {
786         if (v->getType() != types::InternalType::ScilabList)
787         {
788             return false;
789         }
790
791         types::List* current = v->getAs<types::List>();
792
793         if (current->getSize() == 0)
794         {
795             return true;
796         }
797         else
798         {
799             // silent unused parameter warnings
800             (void) adaptor;
801             (void) v;
802             (void) controller;
803
804             // FIXME: implement as a stored modelica equations
805             // FIXME: get the input list and store it in the equations field
806             return false;
807         }
808     }
809 };
810
811 struct uid
812 {
813
814     static types::InternalType* get(const ModelAdapter& adaptor, const Controller& controller)
815     {
816         model::Block* adaptee = adaptor.getAdaptee();
817
818         std::string uid;
819         controller.getObjectProperty(adaptee->id(), adaptee->kind(), UID, uid);
820
821         types::String* o = new types::String(1, 1);
822         o->set(0, uid.data());
823
824         return o;
825     }
826
827     static bool set(ModelAdapter& adaptor, types::InternalType* v, Controller& controller)
828     {
829         if (v->getType() != types::InternalType::ScilabString)
830         {
831             return false;
832         }
833
834         types::String* current = v->getAs<types::String>();
835         if (current->getSize() != 1)
836         {
837             return false;
838         }
839
840         model::Block* adaptee = adaptor.getAdaptee();
841
842         std::string uid;
843         char* c_str = wide_string_to_UTF8(current->get(0));
844         uid = std::string(c_str);
845         FREE(c_str);
846
847         controller.setObjectProperty(adaptee->id(), adaptee->kind(), UID, uid);
848         return true;
849     }
850 };
851
852 } /* namespace */
853
854 template<> property<ModelAdapter>::props_t property<ModelAdapter>::fields = property<ModelAdapter>::props_t();
855
856 ModelAdapter::ModelAdapter(bool ownAdaptee, org_scilab_modules_scicos::model::Block* adaptee) :
857     BaseAdapter<ModelAdapter, org_scilab_modules_scicos::model::Block>(ownAdaptee, adaptee)
858 {
859     if (property<ModelAdapter>::properties_have_not_been_set())
860     {
861         property<ModelAdapter>::fields.reserve(23);
862         property<ModelAdapter>::add_property(L"sim", &sim::get, &sim::set);
863         property<ModelAdapter>::add_property(L"in", &in::get, &in::set);
864         property<ModelAdapter>::add_property(L"in2", &in2::get, &in2::set);
865         property<ModelAdapter>::add_property(L"intyp", &intyp::get, &intyp::set);
866         property<ModelAdapter>::add_property(L"out", &out::get, &out::set);
867         property<ModelAdapter>::add_property(L"out2", &out2::get, &out2::set);
868         property<ModelAdapter>::add_property(L"outtyp", &outtyp::get, &outtyp::set);
869         property<ModelAdapter>::add_property(L"evtin", &evtin::get, &evtin::set);
870         property<ModelAdapter>::add_property(L"evtout", &evtout::get, &evtout::set);
871         property<ModelAdapter>::add_property(L"state", &state::get, &state::set);
872         property<ModelAdapter>::add_property(L"dstate", &dstate::get, &dstate::set);
873         property<ModelAdapter>::add_property(L"odstate", &odstate::get, &odstate::set);
874         property<ModelAdapter>::add_property(L"rpar", &rpar::get, &rpar::set);
875         property<ModelAdapter>::add_property(L"ipar", &ipar::get, &ipar::set);
876         property<ModelAdapter>::add_property(L"opar", &opar::get, &opar::set);
877         property<ModelAdapter>::add_property(L"blocktype", &blocktype::get, &blocktype::set);
878         property<ModelAdapter>::add_property(L"firing", &firing::get, &firing::set);
879         property<ModelAdapter>::add_property(L"dep_ut", &dep_ut::get, &dep_ut::set);
880         property<ModelAdapter>::add_property(L"label", &label::get, &label::set);
881         property<ModelAdapter>::add_property(L"nzcross", &nzcross::get, &nzcross::set);
882         property<ModelAdapter>::add_property(L"nmode", &nmode::get, &nmode::set);
883         property<ModelAdapter>::add_property(L"equations", &equations::get, &equations::set);
884         property<ModelAdapter>::add_property(L"uid", &uid::get, &uid::set);
885     }
886 }
887
888 ModelAdapter::~ModelAdapter()
889 {
890 }
891
892 std::wstring ModelAdapter::getTypeStr()
893 {
894     return getSharedTypeStr();
895 }
896
897 std::wstring ModelAdapter::getShortTypeStr()
898 {
899     return getSharedTypeStr();
900 }
901
902 } /* namespace view_scilab */
903 } /* namespace org_scilab_modules_scicos */