KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > EmitsDeclImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** Used to access AST DeclarationKind. */
30 import org.objectweb.openccm.ast.api.DeclarationKind;
31
32 /** Used to access AST InterfaceDecl. */
33 import org.objectweb.openccm.ast.api.InterfaceDecl;
34
35 /** Used to access AST OperationDecl. */
36 import org.objectweb.openccm.ast.api.OperationDecl;
37
38 /** Used to access AST ComponentDecl. */
39 import org.objectweb.openccm.ast.api.ComponentDecl;
40
41 /** To use CORBA::ComponentIR::EmitsDef. */
42 import org.omg.CORBA.ComponentIR.EmitsDef;
43 import org.omg.CORBA.ComponentIR.EmitsDefHelper;
44
45 /**
46  * EmitsDeclImpl is a wrapper class for IDL emits port declarations.
47  *
48  * Inherits from:
49  * - EventPortDeclImpl as consumes are event ports,
50  * - LocalContextOperationMapping
51  * to obtain the local context operation mapping.
52  *
53  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
54  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
55  *
56  * @version 0.3
57  */

58
59 public class EmitsDeclImpl
60        extends EventPortDeclImpl
61        implements org.objectweb.openccm.ast.api.EmitsDecl
62 {
63     // ==================================================================
64
//
65
// Internal state.
66
//
67
// ==================================================================
68

69     /** Reference to the CORBA 3.0 EmitsDef. */
70     private EmitsDef emits_def_;
71
72     /** Local context operation mapping. */
73     private OperationDecl[] local_context_mapping_;
74
75     // ==================================================================
76
//
77
// Constructor.
78
//
79
// ==================================================================
80

81     /**
82      * The constructor with the parent scope.
83      *
84      * @param rep The repository of the declaration.
85      * @param parent The parent scope of the declaration.
86      */

87     protected
88     EmitsDeclImpl(Repository rep,
89                   ScopeImpl parent)
90     {
91         // Call the EventPortDeclImpl constructor.
92
super(rep, parent);
93
94         // Init internal state.
95
emits_def_ = null;
96         local_context_mapping_ = null;
97     }
98
99     // ==================================================================
100
//
101
// Internal methods.
102
//
103
// ==================================================================
104

105     // ==================================================================
106
//
107
// Internal methods for DeclarationImpl.
108
//
109
// ==================================================================
110

111     /**
112      * Loads infos of the CORBA 3.0 EmitsDef.
113      *
114      * @param contained The EmitsDef to load.
115      */

116     protected void
117     load(org.omg.CORBA.Contained JavaDoc contained)
118     {
119         emits_def_ = EmitsDefHelper.narrow(contained);
120         super.load(contained);
121     }
122
123     /**
124      * Obtain its CORBA 3.0 Contained reference.
125      *
126      * @return The Contained object associated with the emits declaration.
127      */

128     protected org.omg.CORBA.Contained JavaDoc
129     getContained()
130     {
131        return emits_def_;
132     }
133
134     // ==================================================================
135
//
136
// Public methods.
137
//
138
// ==================================================================
139

140     // ==================================================================
141
//
142
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
143
//
144
// ==================================================================
145

146     // ==================================================================
147
//
148
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
149
//
150
// ==================================================================
151

152     /**
153      * Obtain its DeclarationKind.
154      *
155      * @return The DeclarationKind of the object.
156      */

157     public long
158     getDeclKind()
159     {
160         return DeclarationKind.dk_emits;
161     }
162
163     /**
164      * Create the emits declaration into the IFR.
165      */

166     public void
167     create()
168     {
169         emits_def_ = the_parent_.getComponentDef().
170                      create_emits(getId(), getName(), getVersion(),
171                                   event_.getEventDef());
172         super.create();
173    }
174
175     // ==================================================================
176
//
177
// Methods for OMG IDL org.objectweb.openccm.ast.api.ClientOperationMapping
178
//
179
// ==================================================================
180

181     /**
182      * Obtain the client operation mapping.
183      *
184      * @return The client operation mapping.
185      */

186     public OperationDecl[]
187     getClientMapping()
188     {
189         if (client_mapping_!=null)
190             return client_mapping_;
191
192         // retrieve the client mapping interface.
193
InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping();
194         client.getContents(true, DeclarationKind.dk_null);
195
196         client_mapping_ = new OperationDecl[2];
197         client_mapping_[0] = (OperationDecl)
198                              client.find("connect_"+getName());
199         client_mapping_[1] = (OperationDecl)
200                              client.find("disconnect_"+getName());
201         return client_mapping_;
202     }
203
204     // ==================================================================
205
//
206
// Methods for OMG IDL org.objectweb.openccm.ast.api.EventPortDecl
207
//
208
// ==================================================================
209

210     // ==================================================================
211
//
212
// Methods for OMG IDL org.objectweb.openccm.ast.api.LocalContextOperationMapping
213
//
214
// ==================================================================
215

216     /**
217      * Obtain the local context operation mapping.
218      *
219      * @return The local context operation mapping.
220      */

221     public OperationDecl[]
222     getLocalContextMapping()
223     {
224         if (local_context_mapping_!=null)
225             return local_context_mapping_;
226
227         // retrieve the context mapping local interface.
228
InterfaceDecl context = ((ComponentDecl)the_parent_).
229                                 getLocalContextMapping();
230         context.getContents(true, DeclarationKind.dk_null);
231
232         local_context_mapping_ = new OperationDecl[1];
233         local_context_mapping_[0] = (OperationDecl)
234                                     context.find("push_"+getName());
235         return local_context_mapping_;
236     }
237 }
238
Popular Tags