1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--                          Ada Modeling Framework                          --
6--                                                                          --
7--                        Runtime Library Component                         --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com>                --
12-- All rights reserved.                                                     --
13--                                                                          --
14-- Redistribution and use in source and binary forms, with or without       --
15-- modification, are permitted provided that the following conditions       --
16-- are met:                                                                 --
17--                                                                          --
18--  * Redistributions of source code must retain the above copyright        --
19--    notice, this list of conditions and the following disclaimer.         --
20--                                                                          --
21--  * Redistributions in binary form must reproduce the above copyright     --
22--    notice, this list of conditions and the following disclaimer in the   --
23--    documentation and/or other materials provided with the distribution.  --
24--                                                                          --
25--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
26--    contributors may be used to endorse or promote products derived from  --
27--    this software without specific prior written permission.              --
28--                                                                          --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
40--                                                                          --
41------------------------------------------------------------------------------
42--  $Revision: 2973 $ $Date: 2012-05-13 10:51:25 +0400 (Sun, 13 May 2012) $
43------------------------------------------------------------------------------
44with AMF.Internals.Tables.CMOF_Attributes;
45with AMF.Internals.Element_Collections;
46with AMF.Internals.Helpers;
47with AMF.Visitors.CMOF_Iterators;
48with AMF.Visitors.CMOF_Visitors;
49
50package body AMF.Internals.CMOF_Operations is
51
52   use AMF.Internals.Tables.CMOF_Attributes;
53
54   -------------------
55   -- Enter_Element --
56   -------------------
57
58   overriding procedure Enter_Element
59    (Self    : not null access constant CMOF_Operation_Proxy;
60     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
61     Control : in out AMF.Visitors.Traverse_Control) is
62   begin
63      if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then
64         AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class
65          (Visitor).Enter_Operation
66            (AMF.CMOF.Operations.CMOF_Operation_Access (Self),
67           Control);
68      end if;
69   end Enter_Element;
70
71   ------------------------
72   -- Get_Body_Condition --
73   ------------------------
74
75   overriding function Get_Body_Condition
76    (Self : not null access constant CMOF_Operation_Proxy)
77       return AMF.CMOF.Constraints.CMOF_Constraint_Access is
78   begin
79      return
80        AMF.CMOF.Constraints.CMOF_Constraint_Access
81         (AMF.Internals.Helpers.To_Element
82           (Internal_Get_Body_Condition (Self.Element)));
83   end Get_Body_Condition;
84
85   ---------------
86   -- Get_Class --
87   ---------------
88
89   overriding function Get_Class
90    (Self : not null access constant CMOF_Operation_Proxy)
91       return AMF.CMOF.Classes.CMOF_Class_Access is
92   begin
93      return
94        AMF.CMOF.Classes.CMOF_Class_Access
95         (AMF.Internals.Helpers.To_Element (Internal_Get_Class (Self.Element)));
96   end Get_Class;
97
98   ------------------
99   -- Get_Datatype --
100   ------------------
101
102   overriding function Get_Datatype
103    (Self : not null access constant CMOF_Operation_Proxy)
104       return AMF.CMOF.Data_Types.CMOF_Data_Type_Access is
105   begin
106      return
107        AMF.CMOF.Data_Types.CMOF_Data_Type_Access
108         (AMF.Internals.Helpers.To_Element (Internal_Get_Datatype (Self.Element)));
109   end Get_Datatype;
110
111   ------------------
112   -- Get_Is_Query --
113   ------------------
114
115   overriding function Get_Is_Query
116    (Self : not null access constant CMOF_Operation_Proxy) return Boolean is
117   begin
118      return Internal_Get_Is_Query (Self.Element);
119   end Get_Is_Query;
120
121   -------------------------
122   -- Get_Owned_Parameter --
123   -------------------------
124
125   overriding function Get_Owned_Parameter
126    (Self : not null access constant CMOF_Operation_Proxy)
127       return AMF.CMOF.Parameters.Collections.Ordered_Set_Of_CMOF_Parameter is
128   begin
129      --  XXX This subprogram overrides Get_Owned_Parameter from
130      --  Behavioral_Feature. It ca be reasonable to move it to corresponding
131      --  package, but Behavioral_Feat is not used as superclass for other
132      --  classes of MOF.
133
134      return
135        AMF.CMOF.Parameters.Collections.Wrap
136         (AMF.Internals.Element_Collections.Wrap
137           (Internal_Get_Owned_Parameter (Self.Element)));
138   end Get_Owned_Parameter;
139
140   -----------------------
141   -- Get_Postcondition --
142   -----------------------
143
144   overriding function Get_Postcondition
145    (Self : not null access constant CMOF_Operation_Proxy)
146       return AMF.CMOF.Constraints.Collections.Set_Of_CMOF_Constraint is
147   begin
148      return
149        AMF.CMOF.Constraints.Collections.Wrap
150         (AMF.Internals.Element_Collections.Wrap
151           (Internal_Get_Postcondition (Self.Element)));
152   end Get_Postcondition;
153
154   ----------------------
155   -- Get_Precondition --
156   ----------------------
157
158   overriding function Get_Precondition
159    (Self : not null access constant CMOF_Operation_Proxy)
160       return AMF.CMOF.Constraints.Collections.Set_Of_CMOF_Constraint is
161   begin
162      return
163        AMF.CMOF.Constraints.Collections.Wrap
164         (AMF.Internals.Element_Collections.Wrap
165           (Internal_Get_Precondition (Self.Element)));
166   end Get_Precondition;
167
168   --------------------------
169   -- Get_Raised_Exception --
170   --------------------------
171
172   overriding function Get_Raised_Exception
173    (Self : not null access constant CMOF_Operation_Proxy)
174       return AMF.CMOF.Types.Collections.Set_Of_CMOF_Type is
175   begin
176      return
177        AMF.CMOF.Types.Collections.Wrap
178         (AMF.Internals.Element_Collections.Wrap
179           (Internal_Get_Raised_Exception (Self.Element)));
180   end Get_Raised_Exception;
181
182   -----------------------------
183   -- Get_Redefined_Operation --
184   -----------------------------
185
186   overriding function Get_Redefined_Operation
187    (Self : not null access constant CMOF_Operation_Proxy)
188       return AMF.CMOF.Operations.Collections.Set_Of_CMOF_Operation is
189   begin
190      return
191        AMF.CMOF.Operations.Collections.Wrap
192         (AMF.Internals.Element_Collections.Wrap
193           (Internal_Get_Redefined_Operation (Self.Element)));
194   end Get_Redefined_Operation;
195
196   --------------
197   -- Get_Type --
198   --------------
199
200   overriding function Get_Type
201    (Self : not null access constant CMOF_Operation_Proxy)
202       return AMF.CMOF.Types.CMOF_Type_Access is
203   begin
204      return
205        AMF.CMOF.Types.CMOF_Type_Access
206         (AMF.Internals.Helpers.To_Element (Internal_Get_Type (Self.Element)));
207   end Get_Type;
208
209   -------------------
210   -- Leave_Element --
211   -------------------
212
213   overriding procedure Leave_Element
214    (Self    : not null access constant CMOF_Operation_Proxy;
215     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
216     Control : in out AMF.Visitors.Traverse_Control) is
217   begin
218      if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then
219         AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class
220          (Visitor).Leave_Operation
221            (AMF.CMOF.Operations.CMOF_Operation_Access (Self),
222           Control);
223      end if;
224   end Leave_Element;
225
226   ------------------
227   -- Set_Is_Query --
228   ------------------
229
230   overriding procedure Set_Is_Query
231    (Self : not null access CMOF_Operation_Proxy;
232     To   : Boolean) is
233   begin
234      Internal_Set_Is_Query (Self.Element, To);
235   end Set_Is_Query;
236
237   -------------------
238   -- Visit_Element --
239   -------------------
240
241   overriding procedure Visit_Element
242    (Self     : not null access constant CMOF_Operation_Proxy;
243     Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
244     Visitor  : in out AMF.Visitors.Abstract_Visitor'Class;
245     Control  : in out AMF.Visitors.Traverse_Control) is
246   begin
247      if Iterator in AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class then
248         AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class
249          (Iterator).Visit_Operation
250            (Visitor,
251             AMF.CMOF.Operations.CMOF_Operation_Access (Self),
252             Control);
253      end if;
254   end Visit_Element;
255
256   ------------------------
257   -- All_Owned_Elements --
258   ------------------------
259
260   overriding function All_Owned_Elements
261     (Self : not null access constant CMOF_Operation_Proxy)
262      return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element
263   is
264   begin
265      --  Generated stub: replace with real body!
266      pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented");
267      raise Program_Error;
268      return All_Owned_Elements (Self);
269   end All_Owned_Elements;
270
271   ------------------------
272   -- Get_Qualified_Name --
273   ------------------------
274
275   overriding function Get_Qualified_Name
276     (Self : not null access constant CMOF_Operation_Proxy)
277      return Optional_String
278   is
279   begin
280      --  Generated stub: replace with real body!
281      pragma Compile_Time_Warning (Standard.True, "Get_Qualified_Name unimplemented");
282      raise Program_Error;
283      return Get_Qualified_Name (Self);
284   end Get_Qualified_Name;
285
286   -----------------------------
287   -- Is_Distinguishable_From --
288   -----------------------------
289
290   overriding function Is_Distinguishable_From
291     (Self : not null access constant CMOF_Operation_Proxy;
292      N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access;
293      Ns : AMF.CMOF.Namespaces.CMOF_Namespace_Access)
294      return Boolean
295   is
296   begin
297      --  Generated stub: replace with real body!
298      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
299      raise Program_Error;
300      return Is_Distinguishable_From (Self, N, Ns);
301   end Is_Distinguishable_From;
302
303   ---------------------
304   -- Imported_Member --
305   ---------------------
306
307   overriding function Imported_Member
308     (Self : not null access constant CMOF_Operation_Proxy)
309      return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element
310   is
311   begin
312      --  Generated stub: replace with real body!
313      pragma Compile_Time_Warning (Standard.True, "Imported_Member unimplemented");
314      raise Program_Error;
315      return Imported_Member (Self);
316   end Imported_Member;
317
318   -------------------------
319   -- Get_Names_Of_Member --
320   -------------------------
321
322   overriding function Get_Names_Of_Member
323    (Self : not null access constant CMOF_Operation_Proxy;
324     Element : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access)
325       return AMF.String_Collections.Set_Of_String is
326   begin
327      --  Generated stub: replace with real body!
328      pragma Compile_Time_Warning (Standard.True, "Get_Names_Of_Member unimplemented");
329      raise Program_Error;
330      return Get_Names_Of_Member (Self, Element);
331   end Get_Names_Of_Member;
332
333   --------------------
334   -- Import_Members --
335   --------------------
336
337   overriding function Import_Members
338     (Self : not null access constant CMOF_Operation_Proxy;
339      Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element)
340      return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element
341   is
342   begin
343      --  Generated stub: replace with real body!
344      pragma Compile_Time_Warning (Standard.True, "Import_Members unimplemented");
345      raise Program_Error;
346      return Import_Members (Self, Imps);
347   end Import_Members;
348
349   ------------------------
350   -- Exclude_Collisions --
351   ------------------------
352
353   overriding function Exclude_Collisions
354     (Self : not null access constant CMOF_Operation_Proxy;
355      Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element)
356      return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element
357   is
358   begin
359      --  Generated stub: replace with real body!
360      pragma Compile_Time_Warning (Standard.True, "Exclude_Collisions unimplemented");
361      raise Program_Error;
362      return Exclude_Collisions (Self, Imps);
363   end Exclude_Collisions;
364
365   ---------------------------------
366   -- Members_Are_Distinguishable --
367   ---------------------------------
368
369   overriding function Members_Are_Distinguishable
370     (Self : not null access constant CMOF_Operation_Proxy)
371      return Boolean
372   is
373   begin
374      --  Generated stub: replace with real body!
375      pragma Compile_Time_Warning (Standard.True, "Members_Are_Distinguishable unimplemented");
376      raise Program_Error;
377      return Members_Are_Distinguishable (Self);
378   end Members_Are_Distinguishable;
379
380   -----------------
381   -- Set_Is_Leaf --
382   -----------------
383
384   overriding procedure Set_Is_Leaf
385     (Self : not null access CMOF_Operation_Proxy;
386      To   : Boolean)
387   is
388   begin
389      --  Generated stub: replace with real body!
390      pragma Compile_Time_Warning (Standard.True, "Set_Is_Leaf unimplemented");
391      raise Program_Error;
392   end Set_Is_Leaf;
393
394   -----------------------------------
395   -- Is_Redefinition_Context_Valid --
396   -----------------------------------
397
398   overriding function Is_Redefinition_Context_Valid
399     (Self : not null access constant CMOF_Operation_Proxy;
400      Redefined : AMF.CMOF.Redefinable_Elements.CMOF_Redefinable_Element_Access)
401      return Boolean
402   is
403   begin
404      --  Generated stub: replace with real body!
405      pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
406      raise Program_Error;
407      return Is_Redefinition_Context_Valid (Self, Redefined);
408   end Is_Redefinition_Context_Valid;
409
410   --------------------
411   -- Get_Is_Ordered --
412   --------------------
413
414   overriding function Get_Is_Ordered
415     (Self : not null access constant CMOF_Operation_Proxy)
416      return Boolean
417   is
418   begin
419      --  Generated stub: replace with real body!
420      pragma Compile_Time_Warning (Standard.True, "Get_Is_Ordered unimplemented");
421      raise Program_Error;
422      return Get_Is_Ordered (Self);
423   end Get_Is_Ordered;
424
425   --------------------
426   -- Set_Is_Ordered --
427   --------------------
428
429   overriding procedure Set_Is_Ordered
430     (Self : not null access CMOF_Operation_Proxy;
431      To   : Boolean)
432   is
433   begin
434      --  Generated stub: replace with real body!
435      pragma Compile_Time_Warning (Standard.True, "Set_Is_Ordered unimplemented");
436      raise Program_Error;
437   end Set_Is_Ordered;
438
439   -------------------
440   -- Get_Is_Unique --
441   -------------------
442
443   overriding function Get_Is_Unique
444     (Self : not null access constant CMOF_Operation_Proxy)
445      return Boolean
446   is
447   begin
448      --  Generated stub: replace with real body!
449      pragma Compile_Time_Warning (Standard.True, "Get_Is_Unique unimplemented");
450      raise Program_Error;
451      return Get_Is_Unique (Self);
452   end Get_Is_Unique;
453
454   -------------------
455   -- Set_Is_Unique --
456   -------------------
457
458   overriding procedure Set_Is_Unique
459     (Self : not null access CMOF_Operation_Proxy;
460      To   : Boolean)
461   is
462   begin
463      --  Generated stub: replace with real body!
464      pragma Compile_Time_Warning (Standard.True, "Set_Is_Unique unimplemented");
465      raise Program_Error;
466   end Set_Is_Unique;
467
468   ---------------
469   -- Get_Lower --
470   ---------------
471
472   overriding function Get_Lower
473     (Self : not null access constant CMOF_Operation_Proxy)
474      return Optional_Integer
475   is
476   begin
477      --  Generated stub: replace with real body!
478      pragma Compile_Time_Warning (Standard.True, "Get_Lower unimplemented");
479      raise Program_Error;
480      return Get_Lower (Self);
481   end Get_Lower;
482
483   ---------------
484   -- Set_Lower --
485   ---------------
486
487   overriding procedure Set_Lower
488     (Self : not null access CMOF_Operation_Proxy;
489      To   : Optional_Integer)
490   is
491   begin
492      --  Generated stub: replace with real body!
493      pragma Compile_Time_Warning (Standard.True, "Set_Lower unimplemented");
494      raise Program_Error;
495   end Set_Lower;
496
497   ---------------
498   -- Get_Upper --
499   ---------------
500
501   overriding function Get_Upper
502     (Self : not null access constant CMOF_Operation_Proxy)
503      return Optional_Unlimited_Natural
504   is
505   begin
506      --  Generated stub: replace with real body!
507      pragma Compile_Time_Warning (Standard.True, "Get_Upper unimplemented");
508      raise Program_Error;
509      return Get_Upper (Self);
510   end Get_Upper;
511
512   ---------------
513   -- Set_Upper --
514   ---------------
515
516   overriding procedure Set_Upper
517     (Self : not null access CMOF_Operation_Proxy;
518      To   : Optional_Unlimited_Natural)
519   is
520   begin
521      --  Generated stub: replace with real body!
522      pragma Compile_Time_Warning (Standard.True, "Set_Upper unimplemented");
523      raise Program_Error;
524   end Set_Upper;
525
526   ---------------
527   -- Set_Class --
528   ---------------
529
530   overriding procedure Set_Class
531     (Self : not null access CMOF_Operation_Proxy;
532      To   : AMF.CMOF.Classes.CMOF_Class_Access)
533   is
534   begin
535      --  Generated stub: replace with real body!
536      pragma Compile_Time_Warning (Standard.True, "Set_Class unimplemented");
537      raise Program_Error;
538   end Set_Class;
539
540   ------------------
541   -- Set_Datatype --
542   ------------------
543
544   overriding procedure Set_Datatype
545     (Self : not null access CMOF_Operation_Proxy;
546      To   : AMF.CMOF.Data_Types.CMOF_Data_Type_Access)
547   is
548   begin
549      --  Generated stub: replace with real body!
550      pragma Compile_Time_Warning (Standard.True, "Set_Datatype unimplemented");
551      raise Program_Error;
552   end Set_Datatype;
553
554   --------------
555   -- Set_Type --
556   --------------
557
558   overriding procedure Set_Type
559     (Self : not null access CMOF_Operation_Proxy;
560      To   : AMF.CMOF.Types.CMOF_Type_Access)
561   is
562   begin
563      --  Generated stub: replace with real body!
564      pragma Compile_Time_Warning (Standard.True, "Set_Type unimplemented");
565      raise Program_Error;
566   end Set_Type;
567
568   ------------------------
569   -- Set_Body_Condition --
570   ------------------------
571
572   overriding procedure Set_Body_Condition
573     (Self : not null access CMOF_Operation_Proxy;
574      To   : AMF.CMOF.Constraints.CMOF_Constraint_Access)
575   is
576   begin
577      --  Generated stub: replace with real body!
578      pragma Compile_Time_Warning (Standard.True, "Set_Body_Condition unimplemented");
579      raise Program_Error;
580   end Set_Body_Condition;
581
582   ----------------
583   -- Is_Ordered --
584   ----------------
585
586   overriding function Is_Ordered
587     (Self : not null access constant CMOF_Operation_Proxy)
588      return Boolean
589   is
590   begin
591      --  Generated stub: replace with real body!
592      pragma Compile_Time_Warning (Standard.True, "Is_Ordered unimplemented");
593      raise Program_Error;
594      return Is_Ordered (Self);
595   end Is_Ordered;
596
597   ---------------
598   -- Is_Unique --
599   ---------------
600
601   overriding function Is_Unique
602     (Self : not null access constant CMOF_Operation_Proxy)
603      return Boolean
604   is
605   begin
606      --  Generated stub: replace with real body!
607      pragma Compile_Time_Warning (Standard.True, "Is_Unique unimplemented");
608      raise Program_Error;
609      return Is_Unique (Self);
610   end Is_Unique;
611
612   -----------
613   -- Lower --
614   -----------
615
616   overriding function Lower
617     (Self : not null access constant CMOF_Operation_Proxy)
618      return Integer
619   is
620   begin
621      --  Generated stub: replace with real body!
622      pragma Compile_Time_Warning (Standard.True, "Lower unimplemented");
623      raise Program_Error;
624      return Lower (Self);
625   end Lower;
626
627   -----------
628   -- Upper --
629   -----------
630
631   overriding function Upper
632     (Self : not null access constant CMOF_Operation_Proxy)
633      return Unlimited_Natural
634   is
635   begin
636      --  Generated stub: replace with real body!
637      pragma Compile_Time_Warning (Standard.True, "Upper unimplemented");
638      raise Program_Error;
639      return Upper (Self);
640   end Upper;
641
642   ------------------------
643   -- Is_Consistent_With --
644   ------------------------
645
646   overriding function Is_Consistent_With
647     (Self : not null access constant CMOF_Operation_Proxy;
648      Redefinee : AMF.CMOF.Redefinable_Elements.CMOF_Redefinable_Element_Access)
649      return Boolean
650   is
651   begin
652      --  Generated stub: replace with real body!
653      pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
654      raise Program_Error;
655      return Is_Consistent_With (Self, Redefinee);
656   end Is_Consistent_With;
657
658   -------------------
659   -- Return_Result --
660   -------------------
661
662   overriding function Return_Result
663     (Self : not null access constant CMOF_Operation_Proxy)
664      return AMF.CMOF.Parameters.Collections.Set_Of_CMOF_Parameter
665   is
666   begin
667      --  Generated stub: replace with real body!
668      pragma Compile_Time_Warning (Standard.True, "Return_Result unimplemented");
669      raise Program_Error;
670      return Return_Result (Self);
671   end Return_Result;
672
673   -----------
674   -- Types --
675   -----------
676
677   overriding function Types
678    (Self : not null access constant CMOF_Operation_Proxy)
679       return AMF.CMOF.Types.CMOF_Type_Access
680   is
681   begin
682      --  Generated stub: replace with real body!
683      pragma Compile_Time_Warning (Standard.True, "Types unimplemented");
684      raise Program_Error;
685      return Types (Self);
686   end Types;
687
688end AMF.Internals.CMOF_Operations;
689