001: /*
002: * DDS (Data Distribution Service) for JacORB
003: *
004: * Copyright (C) 2005 , Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad
005: * allaoui <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Library General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU Library General Public License for more details.
016: *
017: * You should have received a copy of the GNU Library General Public
018: * License along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
020: * 02111-1307, USA.
021: *
022: * Coontact: Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad allaoui
023: * <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
024: * Contributor(s)
025: *
026: **/
027: package demo.dds.dcps.temperaturesample;
028:
029: import java.util.Iterator;
030: import java.util.Vector;
031:
032: import org.jacorb.dds.SubscriberImpl;
033: import org.omg.dds.DataReaderListener;
034: import org.omg.dds.DataReaderQos;
035: import org.omg.dds.DataReaderQosHolder;
036: import org.omg.dds.Duration_t;
037: import org.omg.dds.InstanceHandleSeqHolder;
038: import org.omg.dds.LivelinessChangedStatus;
039: import org.omg.dds.PublicationBuiltinTopicDataHolder;
040: import org.omg.dds.QueryCondition;
041: import org.omg.dds.RETCODE_OK;
042: import org.omg.dds.ReadCondition;
043: import org.omg.dds.RequestedDeadlineMissedStatus;
044: import org.omg.dds.RequestedIncompatibleQosStatus;
045: import org.omg.dds.SampleInfoHolder;
046: import org.omg.dds.SampleInfoSeqHolder;
047: import org.omg.dds.SampleLostStatus;
048: import org.omg.dds.SampleRejectedStatus;
049: import org.omg.dds.StatusCondition;
050: import org.omg.dds.Subscriber;
051: import org.omg.dds.SubscriptionMatchStatus;
052: import org.omg.dds.Topic;
053: import org.omg.dds.TopicDescription;
054:
055: public class MessageDataReaderImpl extends MessageDataReaderPOA {
056:
057: // represent the data stockage space of a dataReader
058: private Vector Vector_Message;
059: private DataReaderQos qos;
060: private DataReaderListener a_listener;
061: private Subscriber SubParent;
062: private Topic topic;
063: private org.omg.CORBA.ORB orb;
064: private org.omg.PortableServer.POA poa;
065: private DataReaderListener _listener;
066:
067: /**
068: * @param qos
069: * @param a_listener
070: * @param subParent
071: * @param topic_name
072: */
073: public MessageDataReaderImpl(DataReaderQos qos,
074: DataReaderListener a_listener, Subscriber subParent,
075: Topic topic, org.omg.CORBA.ORB orb,
076: org.omg.PortableServer.POA poa) {
077: this .qos = qos;
078: this .a_listener = a_listener;
079: SubParent = subParent;
080: this .topic = topic;
081: Vector_Message = new Vector();
082: this .orb = orb;
083: this .poa = poa;
084: }
085:
086: /**
087: * @param received_data
088: * @param info_seq
089: * @param max_samples
090: * @param sample_states
091: * @param view_states
092: * @param instance_states
093: * @return
094: */
095: public int read(MessageSeqHolder received_data,
096: SampleInfoSeqHolder info_seq, int max_samples,
097: int sample_states, int view_states, int instance_states) {
098:
099: try {
100: int i = 0;
101: Message tab[] = new Message[getVector_Message().size()];
102: Iterator it = getVector_Message().iterator();
103:
104: while (it.hasNext()) {
105: tab[i] = (Message) it.next();
106: i++;
107: }
108: received_data.value = tab;
109: } catch (Exception e) {
110: System.out.println("Error e = " + e);
111: e.printStackTrace();
112: }
113:
114: return RETCODE_OK.value;
115: }
116:
117: /**
118: * @param received_data
119: * @param info_seq
120: * @param max_samples
121: * @param sample_states
122: * @param view_states
123: * @param instance_states
124: * @return
125: */
126: public int take(MessageSeqHolder received_data,
127: SampleInfoSeqHolder info_seq, int max_samples,
128: int sample_states, int view_states, int instance_states) {
129:
130: int i = 0;
131: Message tab[] = new Message[getVector_Message().size()];
132: Iterator it = getVector_Message().iterator();
133:
134: while (it.hasNext()) {
135: tab[i] = (Message) it.next();
136: i++;
137: }
138: received_data.value = tab;
139: // remove all element from the vector
140: clear();
141:
142: return RETCODE_OK.value;
143: }
144:
145: /**
146: * Not Implemented
147: */
148: public int read_w_condition(MessageSeqHolder received_data,
149: SampleInfoSeqHolder info_seq, int max_samples,
150: ReadCondition a_condition) {
151: return 0;
152: }
153:
154: /**
155: * Not Implemented
156: */
157: public int take_w_condition(MessageSeqHolder received_data,
158: SampleInfoSeqHolder info_seq, int max_samples,
159: ReadCondition a_condition) {
160: return 0;
161: }
162:
163: /**
164: * Not Implemented
165: */
166: public int read_next_sample(MessageHolder received_data,
167: SampleInfoHolder sample_info) {
168: return 0;
169: }
170:
171: /**
172: * Not Implemented
173: */
174: public int take_next_sample(MessageHolder received_data,
175: SampleInfoHolder sample_info) {
176: return 0;
177: }
178:
179: /**
180: * Not Implemented
181: */
182: public int read_instance(MessageSeqHolder received_data,
183: SampleInfoSeqHolder info_seq, int max_samples,
184: int a_handle, int sample_states, int view_states,
185: int instance_states) {
186: return 0;
187: }
188:
189: /**
190: * Not Implemented
191: */
192: public int take_instance(MessageSeqHolder received_data,
193: SampleInfoSeqHolder info_seq, int max_samples,
194: int a_handle, int sample_states, int view_states,
195: int instance_states) {
196: return 0;
197: }
198:
199: /**
200: * Not Implemented
201: */
202: public int read_next_instance(MessageSeqHolder received_data,
203: SampleInfoSeqHolder info_seq, int max_samples,
204: int a_handle, int sample_states, int view_states,
205: int instance_states) {
206: return 0;
207: }
208:
209: /**
210: * Not Implemented
211: */
212: public int take_next_instance(MessageSeqHolder received_data,
213: SampleInfoSeqHolder info_seq, int max_samples,
214: int a_handle, int sample_states, int view_states,
215: int instance_states) {
216: return 0;
217: }
218:
219: /**
220: * Not Implemented
221: */
222: public int read_next_instance_w_condition(
223: MessageSeqHolder received_data,
224: SampleInfoSeqHolder info_seq, int max_samples,
225: int a_handle, ReadCondition a_condition) {
226: return 0;
227: }
228:
229: /**
230: * Not Implemented
231: */
232: public int take_next_instance_w_condition(
233: MessageSeqHolder received_data,
234: SampleInfoSeqHolder info_seq, int max_samples,
235: int a_handle, ReadCondition a_condition) {
236: return 0;
237: }
238:
239: /**
240: * Not Implemented
241: */
242: public int return_loan(MessageSeqHolder received_data,
243: SampleInfoSeqHolder info_seq) {
244: return 0;
245: }
246:
247: /**
248: * Not Implemented
249: */
250: public int get_key_value(MessageHolder key_holder, int handle) {
251: return 0;
252: }
253:
254: /**
255: * Not Implemented
256: */
257: public ReadCondition create_readcondition(int sample_states,
258: int view_states, int instance_states) {
259: return null;
260: }
261:
262: /**
263: * Not Implemented
264: */
265: public QueryCondition create_querycondition(int sample_states,
266: int view_states, int instance_states,
267: String query_expression, String[] query_parameters) {
268: return null;
269: }
270:
271: /**
272: * Not Implemented
273: */
274: public int delete_readcondition(ReadCondition a_condition) {
275: return 0;
276: }
277:
278: /**
279: * Not Implemented
280: */
281: public int delete_contained_entities() {
282: return 0;
283: }
284:
285: /**
286: * Not Implemented
287: */
288: public int set_qos(DataReaderQos qos) {
289: return 0;
290: }
291:
292: /**
293: * Not Implemented
294: */
295: public void get_qos(DataReaderQosHolder qos) {
296: }
297:
298: /**
299: * @param a_listener
300: * @param mask
301: * @return
302: */
303: public int set_listener(org.omg.dds.DataReaderListener a_listener,
304: int mask) {
305:
306: try {
307: this ._listener = a_listener;
308: } catch (Exception e) {
309: System.out.println(" Exception e :" + e);
310: e.printStackTrace();
311: }
312: return 0;
313: }
314:
315: /**
316: * @return _listener
317: */
318: public DataReaderListener get_listener() {
319: return _listener;
320: }
321:
322: /**
323: * @return _topic
324: */
325: public TopicDescription get_topicdescription() {
326: return topic;
327: }
328:
329: /**
330: * Not Implemented
331: */
332: public Subscriber get_subscriber() {
333: return null;
334: }
335:
336: /**
337: * Not Implemented
338: */
339: public SampleRejectedStatus get_sample_rejected_status() {
340: return null;
341: }
342:
343: /**
344: * Not Implemented
345: */
346: public LivelinessChangedStatus get_liveliness_changed_status() {
347:
348: return null;
349: }
350:
351: /**
352: * Not Implemented
353: */
354: public RequestedDeadlineMissedStatus get_requested_deadline_missed_status() {
355: return null;
356: }
357:
358: /**
359: * Not Implemented
360: */
361: public RequestedIncompatibleQosStatus get_requested_incompatible_qos_status() {
362: return null;
363: }
364:
365: /**
366: * Not Implemented
367: */
368: public SubscriptionMatchStatus get_subscription_match_status() {
369: return null;
370: }
371:
372: /**
373: * Not Implemented
374: */
375: public SampleLostStatus get_sample_lost_status() {
376: return null;
377: }
378:
379: /**
380: * Not Implemented
381: */
382: public int wait_for_historical_data(Duration_t max_wait) {
383: return 0;
384: }
385:
386: /**
387: * Not Implemented
388: */
389: public int get_matched_publications(
390: InstanceHandleSeqHolder publication_handles) {
391: return 0;
392: }
393:
394: /**
395: * Not Implemented
396: */
397: public int get_matched_publication_data(
398: PublicationBuiltinTopicDataHolder publication_data,
399: int publication_handle) {
400: return 0;
401: }
402:
403: /**
404: * Not Implemented
405: */
406: public int enable() {
407: return 0;
408: }
409:
410: /**
411: * Not Implemented
412: */
413: public StatusCondition get_statuscondition() {
414: return null;
415: }
416:
417: /**
418: * Not Implemented
419: */
420: public int get_status_changes() {
421: return 0;
422: }
423:
424: /**
425: * @param arg0
426: * @return
427: */
428: public boolean add(Object arg0) {
429: return Vector_Message.add(arg0);
430: }
431:
432: public void clear() {
433: Vector_Message.clear();
434: }
435:
436: /**
437: * @param arg0
438: * @return
439: */
440: public boolean remove(Object arg0) {
441: return Vector_Message.remove(arg0);
442: }
443:
444: /**
445: * @return Returns the vector_Message.
446: */
447: public Vector getVector_Message() {
448: return Vector_Message;
449: }
450:
451: /**
452: * @return Returns the a_listener.
453: */
454: public DataReaderListener getA_listener() {
455: return a_listener;
456: }
457:
458: /**
459: * @return Returns the qos.
460: */
461: public DataReaderQos getQos() {
462: return qos;
463: }
464:
465: /**
466: * @return Returns the subParent.
467: */
468: public Subscriber getSubParent() {
469: return SubParent;
470: }
471:
472: /**
473: * take instance of Message from suscriber
474: */
475: public void take_instance_from_subscriber() {
476: try {
477: SubscriberImpl Subscriber_Parent = (SubscriberImpl) _poa()
478: .reference_to_servant(getSubParent());
479: add((Message) Subscriber_Parent.getInstance());
480: }
481:
482: catch (Exception e) {
483:
484: }
485: }
486: }
|