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: 2672 $ $Date: 2012-03-23 00:58:07 +0400 (Fri, 23 Mar 2012) $ 43------------------------------------------------------------------------------ 44with AMF.Internals.Tables.UML_Attributes; 45with AMF.UML.Generalizations.Collections; 46 47package body AMF.Internals.UML_Classifiers is 48 49 ----------------- 50 -- All_Parents -- 51 ----------------- 52 53 overriding function All_Parents 54 (Self : not null access constant UML_Classifier_Proxy) 55 return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier 56 is 57 -- [UML241] 7.3.8 Classifier 58 -- 59 -- [3] The query allParents() gives all of the direct and indirect 60 -- ancestors of a generalized Classifier. 61 -- 62 -- Classifier::allParents(): Set(Classifier); 63 -- 64 -- allParents = 65 -- self.parents()->union(self.parents()->collect(p | p.allParents())) 66 67 P : constant AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier 68 := Self.Parents; 69 70 begin 71 return Result : AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier 72 := P 73 do 74 for J in 1 .. P.Length loop 75 Result.Union (P.Element (J).All_Parents); 76 end loop; 77 end return; 78 end All_Parents; 79 80 ------------- 81 -- Parents -- 82 ------------- 83 84 overriding function Parents 85 (Self : not null access constant UML_Classifier_Proxy) 86 return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier 87 is 88 -- [UML241] 7.3.8 Classifier 89 -- 90 -- [2] The query parents() gives all of the immediate ancestors of a 91 -- generalized Classifier. 92 -- 93 -- Classifier::parents(): Set(Classifier); 94 -- 95 -- parents = generalization.general 96 97 begin 98 return Result : AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier do 99 declare 100 G : constant 101 AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization 102 := UML_Classifier_Proxy'Class (Self.all).Get_Generalization; 103 X : AMF.UML.Classifiers.UML_Classifier_Access; 104 -- GNAT FSF 4.6: X is used to workaround crash of compiler. 105 106 begin 107 for J in 1 .. G.Length loop 108 X := G.Element (J).Get_General; 109 Result.Add (X); 110 end loop; 111 end; 112 end return; 113 end Parents; 114 115 --------------------- 116 -- Set_Is_Abstract -- 117 --------------------- 118 119 overriding procedure Set_Is_Abstract 120 (Self : not null access UML_Classifier_Proxy; 121 To : Boolean) is 122 begin 123 AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Abstract 124 (Self.Element, To); 125 end Set_Is_Abstract; 126 127end AMF.Internals.UML_Classifiers; 128