Xcos MVC: slight improvements in Adapters
[scilab.git] / scilab / modules / scicos / src / cpp / view_scilab / StateAdapter.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 <memory>
15
16 #include "internal.hxx"
17 #include "types.hxx"
18 #include "user.hxx"
19
20 #include "Controller.hxx"
21 #include "StateAdapter.hxx"
22
23 namespace org_scilab_modules_scicos
24 {
25 namespace view_scilab
26 {
27 namespace
28 {
29
30 struct dummy_property
31 {
32
33     static types::InternalType* get(const StateAdapter& /*adaptor*/, const Controller& /*controller*/)
34     {
35         // Return a default empty matrix.
36         return types::Double::Empty();
37     }
38
39     static bool set(StateAdapter& /*adaptor*/, types::InternalType* /*v*/, Controller& /*controller*/)
40     {
41         // Everything should be right as the properties mapped using this adapter do not perform anything
42         return true;
43     }
44 };
45
46 } /* namespace */
47
48 template<> property<StateAdapter>::props_t property<StateAdapter>::fields = property<StateAdapter>::props_t();
49
50 StateAdapter::StateAdapter(std::shared_ptr<org_scilab_modules_scicos::model::Diagram> adaptee) :
51     BaseAdapter<StateAdapter, org_scilab_modules_scicos::model::Diagram>(adaptee)
52 {
53     if (property<StateAdapter>::properties_have_not_been_set())
54     {
55         property<StateAdapter>::fields.reserve(8);
56         property<StateAdapter>::add_property(L"x", &dummy_property::get, &dummy_property::set);
57         property<StateAdapter>::add_property(L"z", &dummy_property::get, &dummy_property::set);
58         property<StateAdapter>::add_property(L"oz", &dummy_property::get, &dummy_property::set);
59         property<StateAdapter>::add_property(L"iz", &dummy_property::get, &dummy_property::set);
60         property<StateAdapter>::add_property(L"tevts", &dummy_property::get, &dummy_property::set);
61         property<StateAdapter>::add_property(L"evtspt", &dummy_property::get, &dummy_property::set);
62         property<StateAdapter>::add_property(L"pointi", &dummy_property::get, &dummy_property::set);
63         property<StateAdapter>::add_property(L"outtb", &dummy_property::get, &dummy_property::set);
64     }
65 }
66
67 StateAdapter::StateAdapter(const StateAdapter& adapter) :
68     BaseAdapter<StateAdapter, org_scilab_modules_scicos::model::Diagram>(adapter)
69 {
70 }
71
72 StateAdapter::~StateAdapter()
73 {
74 }
75
76 std::wstring StateAdapter::getTypeStr()
77 {
78     return getSharedTypeStr();
79 }
80 std::wstring StateAdapter::getShortTypeStr()
81 {
82     return getSharedTypeStr();
83 }
84
85 } /* namespace view_scilab */
86 } /* namespace org_scilab_modules_scicos */