1------------------------------------------------------------------------------ 2-- -- 3-- Matreshka Project -- 4-- -- 5-- Ada Modeling Framework -- 6-- -- 7-- Runtime Library Component -- 8-- -- 9------------------------------------------------------------------------------ 10-- -- 11-- Copyright © 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: 2964 $ $Date: 2012-05-09 08:35:12 +0400 (Wed, 09 May 2012) $ 43------------------------------------------------------------------------------ 44with AMF.Internals.Element_Collections; 45with AMF.Internals.Tables.OCL_Attribute_Mappings; 46with AMF.Internals.Tables.OCL_Element_Table; 47with AMF.Internals.Tables.OCL_Metamodel; 48with AMF.Internals.Tables.UML_Metamodel; 49 50package body AMF.Internals.Factories.OCL_Module_Factory is 51 52 procedure Construct_Union 53 (Element : AMF.Internals.AMF_Element; 54 Property : AMF.Internals.CMOF_Element; 55 Link : AMF.Internals.AMF_Link); 56 57 -------------------- 58 -- Connect_Extent -- 59 -------------------- 60 61 overriding procedure Connect_Extent 62 (Self : not null access constant OCL_Module_Factory; 63 Element : AMF.Internals.AMF_Element; 64 Extent : AMF.Internals.AMF_Extent) 65 is 66 pragma Unreferenced (Self); 67 68 begin 69 AMF.Internals.Tables.OCL_Element_Table.Table (Element).Extent := Extent; 70 end Connect_Extent; 71 72 ---------------------- 73 -- Connect_Link_End -- 74 ---------------------- 75 76 overriding procedure Connect_Link_End 77 (Self : not null access constant OCL_Module_Factory; 78 Element : AMF.Internals.AMF_Element; 79 Property : AMF.Internals.CMOF_Element; 80 Link : AMF.Internals.AMF_Link; 81 Other : AMF.Internals.AMF_Element) 82 is 83 pragma Unreferenced (Self); 84 85 use AMF.Internals.Tables; 86 use AMF.Internals.Tables.OCL_Attribute_Mappings; 87 use AMF.Internals.Tables.OCL_Metamodel; 88 use AMF.Internals.Tables.UML_Metamodel; 89 90 begin 91 -- Properties which comes from UML metamodel. 92 93 if Property in MB_UML .. ML_UML then 94 declare 95 PO : constant AMF.Internals.CMOF_Element := Property - MB_UML; 96 97 begin 98 if PO in UML_Collection_Offset'Range (2) then 99 AMF.Internals.Element_Collections.Internal_Append 100 (OCL_Element_Table.Table (Element).Member (0).Collection 101 + UML_Collection_Offset 102 (OCL_Element_Table.Table (Element).Kind, PO), 103 Other, 104 Link); 105 106 elsif PO in UML_Member_Offset'Range (2) 107 and then UML_Member_Offset 108 (OCL_Element_Table.Table (Element).Kind, PO) /= 0 109 then 110 OCL_Element_Table.Table (Element).Member 111 (UML_Member_Offset 112 (OCL_Element_Table.Table (Element).Kind, PO)).Link := Link; 113 114 else 115 AMF.Internals.Element_Collections.Internal_Append 116 (OCL_Element_Table.Table (Element).Member (0).Collection, 117 Other, 118 Link); 119 end if; 120 end; 121 122 elsif Property in MB_OCL .. ML_OCL then 123 declare 124 PO : constant AMF.Internals.CMOF_Element := Property - MB_OCL; 125 126 begin 127 if PO in OCL_Collection_Offset'Range (2) then 128 AMF.Internals.Element_Collections.Internal_Append 129 (OCL_Element_Table.Table (Element).Member (0).Collection 130 + OCL_Collection_Offset 131 (OCL_Element_Table.Table (Element).Kind, PO), 132 Other, 133 Link); 134 135 elsif PO in OCL_Member_Offset'Range (2) 136 and then OCL_Member_Offset 137 (OCL_Element_Table.Table (Element).Kind, PO) /= 0 138 then 139 OCL_Element_Table.Table (Element).Member 140 (OCL_Member_Offset 141 (OCL_Element_Table.Table (Element).Kind, PO)).Link := Link; 142 143 else 144 AMF.Internals.Element_Collections.Internal_Append 145 (OCL_Element_Table.Table (Element).Member (0).Collection, 146 Other, 147 Link); 148 end if; 149 end; 150 end if; 151 end Connect_Link_End; 152 153 --------------------- 154 -- Construct_Union -- 155 --------------------- 156 157 procedure Construct_Union 158 (Element : AMF.Internals.AMF_Element; 159 Property : AMF.Internals.CMOF_Element; 160 Link : AMF.Internals.AMF_Link) is separate; 161 162 -------------------------- 163 -- Synchronize_Link_Set -- 164 -------------------------- 165 166 overriding procedure Synchronize_Link_Set 167 (Self : not null access constant OCL_Module_Factory; 168 Element : AMF.Internals.AMF_Element; 169 Property : AMF.Internals.CMOF_Element; 170 Link : AMF.Internals.AMF_Link) 171 is 172 pragma Unreferenced (Self); 173 174 begin 175 -- Construct derived unions. 176 177 Construct_Union (Element, Property, Link); 178 end Synchronize_Link_Set; 179 180 ---------------- 181 -- To_Element -- 182 ---------------- 183 184 overriding function To_Element 185 (Self : not null access constant OCL_Module_Factory; 186 Element : AMF.Internals.AMF_Element) return AMF.Elements.Element_Access 187 is 188 pragma Unreferenced (Self); 189 190 begin 191 return AMF.Internals.Tables.OCL_Element_Table.Table (Element).Proxy; 192 end To_Element; 193 194end AMF.Internals.Factories.OCL_Module_Factory; 195