Xcos MVC: partial implementation of a model.
[scilab.git] / scilab / modules / scicos / src / cpp / view_scilab / Adapters.hxx
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-en.txt
10  *
11  */
12
13 #ifndef ADAPTERS_H_
14 #define ADAPTERS_H_
15
16 #include <vector>
17 #include <utility>
18 #include <string>
19
20 namespace org_scilab_modules_scicos
21 {
22 namespace view_scilab
23 {
24
25 /*
26  * Shared data between adapters
27  */
28 class Adapters
29 {
30 public:
31     typedef enum
32     {
33         BLOCK_ADAPTER = 0,  //!< \see view_scilab::BlockAdapter
34         CPR_ADAPTER,        //!< \see view_scilab::CprAdapter
35         DELETED_ADAPTER,    //!< \see view_scilab::DeletedAdapter
36         DIAGRAM_ADAPTER,    //!< \see view_scilab::DiagramAdapter
37         GRAPHIC_ADAPTER,    //!< \see view_scilab::GraphicAdapter
38         LINK_ADAPTER,       //!< \see view_scilab::LinkAdapter
39         MODEL_ADAPTER,      //!< \see view_scilab::ModelAdapter
40         SCS_ADAPTER,        //!< \see view_scilab::ScsAdapter
41         STATE_ADAPTER,      //!< \see view_scilab::StateAdapter
42         TEXT_ADAPTER,       //!< \see view_scilab::TextAdapter
43
44         INVALID_ADAPTER     //!< length of the enum is used to report error
45     } adapters_index_t;
46
47     static Adapters& instance();
48
49     adapters_index_t lookup_by_typename(const std::wstring& name);
50
51 private:
52
53     struct adapter_t
54     {
55         adapter_t(std::wstring n, adapters_index_t k) : name(n), kind(k) {};
56
57         inline bool operator<(const adapter_t& v) const
58         {
59             return name < v.name;
60         }
61
62         inline bool operator<(const std::wstring& v) const
63         {
64             return name < v;
65         }
66
67         std::wstring name;
68         adapters_index_t kind;
69     };
70     typedef std::vector<adapter_t> adapters_t;
71
72     Adapters();
73     ~Adapters();
74
75     static Adapters m_instance;
76     adapters_t adapters;
77 };
78
79 } /* namespace view_scilab */
80 } /* namespace org_scilab_modules_scicos */
81
82 #endif /* ADAPTERS_H_ */