1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2014-2016 - 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 UTILITIES_HXX_
17 #define UTILITIES_HXX_
18
19 /**
20 * A unique ID is used to represent a reference to any object in the model.
21 *
22 * The 'ScicosID()' zero initialization value is used indicate that BaseObject is not handled by the controller.
23 */
24 typedef long long ScicosID;
25
26 /**
27 * Return status of get and set
28 */
29 enum update_status_t
30 {
31 SUCCESS, //!< Property updated with new values
32 NO_CHANGES, //!< Property unchanged
33 FAIL //!< Update failed
34 };
35
36 /**
37 * Kind of model object.
38 *
39 * All model::BaseObject sub-classes should be listed there. This enum is used to emulate RTTI per Model object.
40 */
41 enum kind_t
42 {
43 BLOCK, //!< model::Block object
44 DIAGRAM, //!< model::Diagram object
45 LINK, //!< model::Link object
46 ANNOTATION, //!< model::Annotation object
47 PORT //!< model::Port object
48 };
49
50 /**
51 * Set / Get identifier
52 *
53 * For each fields of any model::BaseObject, a corresponding identifier exists and is used on the Controller to store and view-dispatch any modification. This field value will be then used by each view to filter out / in important event per-view.
54 */
55 enum object_properties_t
56 {
57 PARENT_DIAGRAM, //!< model::*::parentDiagram value (used to locate the diagram layer)
58 PARENT_BLOCK, //!< model::*::parentBlock value (used to locate the upper layer in case of SuperBlocks hierarchy)
59 GEOMETRY, //!< model::Annotation::geometry or model::Block::geometry value
60 DESCRIPTION, //!< model::Annotation::description text
61 FONT, //!< model::Annotation::description font
62 FONT_SIZE, //!< model::Annotation::description font size
63 RELATED_TO, //!< model::Annotation::relatedTo
64 INTERFACE_FUNCTION, //!< model::Block::interfaceFunction value
65 SIM_FUNCTION_NAME, //!< model::Descriptor::functionName value (stored into model::Block::sim)
66 SIM_FUNCTION_API, //!< model::Descriptor::functionApi value (stored into model::Block::sim)
67 SIM_SCHEDULE, //!< model::Descriptor::schedulingProperties value (stored into model::Block::sim)
68 SIM_BLOCKTYPE, //!< model::Descriptor::blocktype value (stored into model::Block::sim)
69 SIM_DEP_UT, //!< model::Descriptor::dep_ut value (stored into model::Block::sim)
70 EXPRS, //!< model::Block::exprs value
71 INPUTS, //!< model::Block::in value
72 OUTPUTS, //!< model::Block::out value
73 EVENT_INPUTS, //!< model::Block::ein value
74 EVENT_OUTPUTS, //!< model::Block::eout value
75 STATE, //!< model::Block::state value
76 DSTATE, //!< model::Block::dstate value
77 ODSTATE, //!< model::Block::odstate value
78 NZCROSS, //!< model::Block::nzcross value
79 NMODE, //!< model::Block::nmode value
80 RPAR, //!< model::Block::rpar value
81 IPAR, //!< model::Block::ipar value
82 OPAR, //!< model::Block::opar value
83 EQUATIONS, //!< model::Block::equations value
84 UID, //!< model::Block::uid value
85 CHILDREN, //!< model::Block::children for superblocks or model::Diagram::children value
86 PORT_REFERENCE, //!< model::Block::portReference value
87 STYLE, //!< model::Block & Port::style value
88 LABEL, //!< model::Block & Port & Link::label or id value
89 DESTINATION_PORT, //!< model::Link::destinationPort value
90 SOURCE_PORT, //!< model::Link::sourcePort value
91 CONTROL_POINTS, //!< model::Link::controlPoints value
92 THICK, //!< model::Link::thick value
93 COLOR, //!< model::Link & Block & Diagram::color value
94 KIND, //!< model::Link::kind value
95 DATATYPE, //!< model::Port::dataType value
96 DATATYPE_ROWS, //!< model::Port::dataType adapter helper
97 DATATYPE_COLS, //!< model::Port::dataType adapter helper
98 DATATYPE_TYPE, //!< model::Port::dataType adapter helper
99 FIRING, //!< model::Port::firing value
100 SOURCE_BLOCK, //!< model::Port::sourceBlock value
101 PORT_KIND, //!< model::Port::kind value
102 IMPLICIT, //!< model::Port::implicit value
103 PORT_NUMBER, //!< model::Port::portNumber value
104 CONNECTED_SIGNALS, //!< model::Port::connectedSignals value
105 TITLE, //!< model::Diagram::title file name value
106 PATH, //!< model::Diagram::title file path value
107 PROPERTIES, //!< model::Diagram::tol & tf values
108 DEBUG_LEVEL, //!< model::Diagram::debug_level value
109 DIAGRAM_CONTEXT, //!< model::Diagram::context value
110 VERSION_NUMBER, //!< model::Diagram::version value
111 MAX_OBJECT_PROPERTIES //!< last valid value of the object_properties_t enum
112 };
113
114 /**
115 * PORT_KIND valid values
116 */
117 enum portKind
118 {
119 PORT_UNDEF,
120 PORT_IN,
121 PORT_OUT,
122 PORT_EIN,
123 PORT_EOUT
124 };
125
126 /**
127 * Helper to convert a Property to a Port kind.
128 */
port_from_property(object_properties_t p)129 inline int port_from_property(object_properties_t p)
130 {
131 switch (p)
132 {
133 case INPUTS:
134 return PORT_IN;
135 case OUTPUTS:
136 return PORT_OUT;
137 case EVENT_INPUTS:
138 return PORT_EIN;
139 case EVENT_OUTPUTS:
140 return PORT_EOUT;
141 default:
142 return PORT_UNDEF;
143 }
144 }
145
146
147 /**
148 * Helper to convert a Port kind to a Property.
149 */
property_from_port(int p)150 inline object_properties_t property_from_port(int p)
151 {
152 switch (p)
153 {
154 case PORT_IN:
155 return INPUTS;
156 case PORT_OUT:
157 return OUTPUTS;
158 case PORT_EIN:
159 return EVENT_INPUTS;
160 case PORT_EOUT:
161 return EVENT_OUTPUTS;
162 default:
163 return MAX_OBJECT_PROPERTIES;
164 }
165 }
166
167
168 #endif /* UTILITIES_HXX_ */
169