Xcos: "Region to superblock" fixed
[scilab.git] / scilab / modules / scicos / includes / 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  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15
16 #ifndef ADAPTERS_HXX_
17 #define ADAPTERS_HXX_
18
19 #include <utility>
20 #include <vector>
21 #include <string>
22
23 #include "internal.hxx"
24 #include "utilities.hxx"
25 #include "Controller.hxx"
26 #include "model/BaseObject.hxx"
27
28 extern "C"
29 {
30 #include "dynlib_scicos.h"
31 }
32 namespace org_scilab_modules_scicos
33 {
34 namespace view_scilab
35 {
36
37 /*
38  * Shared data between adapters
39  */
40 class SCICOS_IMPEXP Adapters
41 {
42 public:
43     typedef enum
44     {
45         BLOCK_ADAPTER = 0,  //!< \see view_scilab::BlockAdapter
46         CPR_ADAPTER,        //!< \see view_scilab::CprAdapter
47         DIAGRAM_ADAPTER,    //!< \see view_scilab::DiagramAdapter
48         GRAPHIC_ADAPTER,    //!< \see view_scilab::GraphicAdapter
49         LINK_ADAPTER,       //!< \see view_scilab::LinkAdapter
50         MODEL_ADAPTER,      //!< \see view_scilab::ModelAdapter
51         PARAMS_ADAPTER,    //!< \see view_scilab::ParamsAdapter
52         SCS_ADAPTER,        //!< \see view_scilab::ScsAdapter
53         STATE_ADAPTER,      //!< \see view_scilab::StateAdapter
54         TEXT_ADAPTER,       //!< \see view_scilab::TextAdapter
55
56         INVALID_ADAPTER     //!< length of the enum is used to report error
57     } adapters_index_t;
58
59     static Adapters& instance();
60
61     adapters_index_t lookup_by_typename(const std::wstring& name);
62     std::wstring get_typename(adapters_index_t index);
63     model::BaseObject* descriptor(types::InternalType* v);
64     model::BaseObject* descriptor(adapters_index_t index, types::InternalType* v);
65     types::InternalType* allocate_view(ScicosID id, kind_t kind);
66     types::InternalType* allocate_view(Controller& controller, model::BaseObject* o);
67
68 private:
69
70     struct adapter_t
71     {
72         adapter_t(const std::wstring& n, adapters_index_t k) : name(n), kind(k) {};
73
74         inline bool operator<(const adapter_t& v) const
75         {
76             return name < v.name;
77         }
78
79         inline bool operator<(const std::wstring& v) const
80         {
81             return name < v;
82         }
83
84         std::wstring name;
85         adapters_index_t kind;
86     };
87     typedef std::vector<adapter_t> adapters_t;
88
89     Adapters();
90     ~Adapters();
91
92     static Adapters m_instance;
93     adapters_t adapters;
94 };
95
96 } /* namespace view_scilab */
97 } /* namespace org_scilab_modules_scicos */
98
99 #endif /* ADAPTERS_HXX_ */