1 26 27 package org.objectweb.corba.generator.cif_idl.lib; 28 29 import org.objectweb.openccm.ast.api.ModuleDecl; 31 import org.objectweb.openccm.ast.api.InterfaceList; 32 import org.objectweb.openccm.ast.api.InterfaceDecl; 33 import org.objectweb.openccm.ast.api.InterfacePortDecl; 34 import org.objectweb.openccm.ast.api.EventPortDecl; 35 import org.objectweb.openccm.ast.api.ComponentDecl; 36 import org.objectweb.openccm.ast.api.SegmentDecl; 37 import org.objectweb.openccm.ast.api.NativeDecl; 38 import org.objectweb.openccm.ast.api.OperationDecl; 39 40 47 48 public class SegmentMapping 49 implements org.objectweb.corba.generator.cif_idl.api.SegmentMapping 50 { 51 57 58 private SegmentDecl seg_; 59 60 66 69 public SegmentMapping(SegmentDecl seg) 70 { 71 seg_ = seg; 73 } 74 75 81 90 protected InterfaceDecl 91 create_seg_mapping(ModuleDecl module, 92 InterfaceDecl seg_base_mapping, 93 ComponentDecl comp) 94 { 95 InterfaceDecl seg_mapping = null; 96 InterfaceList list = null; 97 String [] facets = null; 98 String [] sinks = null; 99 100 seg_mapping = module.declareLocalInterface( "CIF_" + seg_.getName() ); 101 list = seg_mapping.getInheritedInterfaceList(); 102 103 list.add(seg_base_mapping); 105 106 facets = seg_.getFacetList().getStrings(); 109 for (int i=0; i<facets.length; i++) 110 { 111 InterfacePortDecl itf_port = null; 112 ComponentDecl current = null; 113 114 current = comp; 115 while ((current != null) && (itf_port == null)) 116 { 117 itf_port = (InterfacePortDecl) current.lookup(facets[i]); 118 current = comp.getBaseComponent(); 120 } 121 list.add( itf_port.getLocalMapping() ); 122 } 123 124 sinks = seg_.getSinkList().getStrings(); 127 for (int i=0; i<sinks.length; i++) 128 { 129 EventPortDecl event_port = null; 130 ComponentDecl current = null; 131 132 current = comp; 133 while ((current != null) && (event_port == null)) 134 { 135 event_port = (EventPortDecl) current.lookup(sinks[i]); 136 current = comp.getBaseComponent(); 138 } 139 list.add( event_port.getEvent().getLocalConsumerMapping() ); 140 } 141 142 seg_mapping.create(); 144 145 return seg_mapping; 146 } 147 148 153 protected void 154 add_seg_mapping_contents(InterfaceDecl seg_mapping) 155 { 156 157 if (seg_.getAbstractStorageHome() != null) 158 { 159 NativeDecl ast = null, 160 ash = null; 161 OperationDecl op = null; 162 163 ash = seg_.getAbstractStorageHome().getMapping(); 164 ast = seg_.getAbstractStorageHome().getAbstractStorageType().getMapping(); 165 166 op = seg_mapping.startOperation("get_state"); 167 op.setType(ast); 168 op.create(); 169 } 171 } 172 173 179 186 public void 187 declareCIF(ModuleDecl module, 188 InterfaceDecl seg_base_mapping, 189 ComponentDecl comp) 190 { 191 InterfaceDecl seg_mapping = null; 192 193 seg_mapping = create_seg_mapping(module, 194 seg_base_mapping, 195 comp); 196 add_seg_mapping_contents(seg_mapping); 197 } 198 199 205 } 206 | Popular Tags |