matreshka_league_21.0.0_0c8f4d47/source/amf/mofext/amf-transformations-cmof_to_uml_mof.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
------------------------------------------------------------------------------
--                                                                          --
--                            Matreshka Project                             --
--                                                                          --
--                          Ada Modeling Framework                          --
--                                                                          --
--                        Runtime Library Component                         --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com>                     --
-- All rights reserved.                                                     --
--                                                                          --
-- Redistribution and use in source and binary forms, with or without       --
-- modification, are permitted provided that the following conditions       --
-- are met:                                                                 --
--                                                                          --
--  * Redistributions of source code must retain the above copyright        --
--    notice, this list of conditions and the following disclaimer.         --
--                                                                          --
--  * Redistributions in binary form must reproduce the above copyright     --
--    notice, this list of conditions and the following disclaimer in the   --
--    documentation and/or other materials provided with the distribution.  --
--                                                                          --
--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
--    contributors may be used to endorse or promote products derived from  --
--    this software without specific prior written permission.              --
--                                                                          --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 2991 $ $Date: 2012-05-16 11:34:35 +0400 (Ср, 16 мая 2012) $
------------------------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;

private with AMF.CMOF.Associations;
private with AMF.CMOF.Classes;
private with AMF.CMOF.Comments;
private with AMF.CMOF.Constraints;
private with AMF.CMOF.Data_Types;
private with AMF.CMOF.Element_Imports;
private with AMF.CMOF.Elements.Hash;
private with AMF.CMOF.Enumeration_Literals;
private with AMF.CMOF.Enumerations;
private with AMF.CMOF.Expressions;
private with AMF.CMOF.Opaque_Expressions;
private with AMF.CMOF.Operations;
private with AMF.CMOF.Package_Imports;
private with AMF.CMOF.Package_Merges;
private with AMF.CMOF.Packages;
private with AMF.CMOF.Parameters;
private with AMF.CMOF.Primitive_Types;
private with AMF.CMOF.Properties;
private with AMF.CMOF.Tags;
--private with AMF.Elements.Hash;
private with AMF.Factories.MOF_Factories;
private with AMF.Factories.UML_Factories;
private with AMF.UML.Elements;
with AMF.URI_Stores;
private with AMF.Visitors.CMOF_Visitors;

package AMF.Transformations.CMOF_To_UML_MOF is

   procedure Transform
    (Source : not null AMF.URI_Stores.URI_Store_Access;
     Target : not null AMF.URI_Stores.URI_Store_Access);
   --  Transforms UML+MOF model to equivalent CMOF model.

private

   package Element_Maps is
     new Ada.Containers.Hashed_Maps
          (AMF.CMOF.Elements.CMOF_Element_Access,
           AMF.UML.Elements.UML_Element_Access,
           AMF.CMOF.Elements.Hash,
           AMF.CMOF.Elements."=",
           AMF.UML.Elements."=");

   type CMOF_To_UML_MOF_Transformer is tagged limited record
      Source         : AMF.URI_Stores.URI_Store_Access;
      Target         : AMF.URI_Stores.URI_Store_Access;
      UML_Factory    : AMF.Factories.UML_Factories.UML_Factory_Access;
      MOF_Factory    : AMF.Factories.MOF_Factories.MOF_Factory_Access;
      To_UML_Element : Element_Maps.Map;
   end record;

   procedure Initialize
    (Self   : not null access CMOF_To_UML_MOF_Transformer'Class;
     Source : not null AMF.URI_Stores.URI_Store_Access;
     Target : not null AMF.URI_Stores.URI_Store_Access);

   type First_Pass_Visitor
    (Transformer : not null access CMOF_To_UML_MOF_Transformer'Class) is
       limited new AMF.Visitors.CMOF_Visitors.CMOF_Visitor with null record;

   procedure Register
    (Self         : in out First_Pass_Visitor'Class;
     CMOF_Element : not null access AMF.CMOF.Elements.CMOF_Element'Class;
     UML_Element  : not null access AMF.UML.Elements.UML_Element'Class);
   --  Register CMOF to UML+MOF element mapping and set identifier of the UML
   --  element inside target extent.

   overriding procedure Enter_Association
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Associations.CMOF_Association_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Class
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Classes.CMOF_Class_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Comment
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Comments.CMOF_Comment_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Constraint
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Constraints.CMOF_Constraint_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Data_Type
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Data_Types.CMOF_Data_Type_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Element_Import
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Element_Imports.CMOF_Element_Import_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Enumeration
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Enumerations.CMOF_Enumeration_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Enumeration_Literal
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Expression
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Expressions.CMOF_Expression_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Opaque_Expression
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Operation
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Operations.CMOF_Operation_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Package
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Packages.CMOF_Package_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Package_Import
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Package_Imports.CMOF_Package_Import_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Package_Merge
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Package_Merges.CMOF_Package_Merge_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Parameter
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Parameters.CMOF_Parameter_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Primitive_Type
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Property
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Properties.CMOF_Property_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Tag
    (Self    : in out First_Pass_Visitor;
     Element : not null AMF.CMOF.Tags.CMOF_Tag_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   type Second_Pass_Visitor
    (Transformer : not null access CMOF_To_UML_MOF_Transformer'Class) is
       limited new AMF.Visitors.CMOF_Visitors.CMOF_Visitor with null record;

   function Resolve
    (Self    : in out Second_Pass_Visitor'Class;
     Element : not null access AMF.CMOF.Elements.CMOF_Element'Class)
       return not null AMF.UML.Elements.UML_Element_Access;

   overriding procedure Enter_Association
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Associations.CMOF_Association_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Class
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Classes.CMOF_Class_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Comment
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Comments.CMOF_Comment_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Constraint
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Constraints.CMOF_Constraint_Access;
     Control : in out AMF.Visitors.Traverse_Control);

--   overriding procedure Enter_Data_Type
--    (Self    : in out Second_Pass_Visitor;
--     Element : not null AMF.CMOF.Data_Types.CMOF_Data_Type_Access;
--     Control : in out AMF.Visitors.Traverse_Control);
--
--   overriding procedure Enter_Element_Import
--    (Self    : in out Second_Pass_Visitor;
--     Element : not null AMF.CMOF.Element_Imports.CMOF_Element_Import_Access;
--     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Enumeration
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Enumerations.CMOF_Enumeration_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Enumeration_Literal
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access;
     Control : in out AMF.Visitors.Traverse_Control);

--   overriding procedure Enter_Expression
--    (Self    : in out Second_Pass_Visitor;
--     Element : not null AMF.CMOF.Expressions.CMOF_Expression_Access;
--     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Opaque_Expression
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Operation
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Operations.CMOF_Operation_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Package
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Packages.CMOF_Package_Access;
     Control : in out AMF.Visitors.Traverse_Control);

--   overriding procedure Enter_Package_Import
--    (Self    : in out Second_Pass_Visitor;
--     Element : not null AMF.CMOF.Package_Imports.CMOF_Package_Import_Access;
--     Control : in out AMF.Visitors.Traverse_Control);
--
--   overriding procedure Enter_Package_Merge
--    (Self    : in out Second_Pass_Visitor;
--     Element : not null AMF.CMOF.Package_Merges.CMOF_Package_Merge_Access;
--     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Parameter
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Parameters.CMOF_Parameter_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Primitive_Type
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Property
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Properties.CMOF_Property_Access;
     Control : in out AMF.Visitors.Traverse_Control);

   overriding procedure Enter_Tag
    (Self    : in out Second_Pass_Visitor;
     Element : not null AMF.CMOF.Tags.CMOF_Tag_Access;
     Control : in out AMF.Visitors.Traverse_Control);

end AMF.Transformations.CMOF_To_UML_MOF;