]> rtime.felk.cvut.cz Git - orte.git/blob - orte/java/src/org/ocera/orte/Subscription.java
New ORTE version 0.3.0 committed
[orte.git] / orte / java / src / org / ocera / orte / Subscription.java
1 /* Subscription.java */
2 package org.ocera.orte;
3 import  org.ocera.orte.types.NtpTime;
4
5 /**
6   * Class JORTEPublisher provides methods for creating and working
7   * with the ORTE publisher.
8   *
9   * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
10   * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
11   * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
12   * @author dedication to Kj
13   * @version 0.1
14   *
15   * This program is free software; you can redistribute it and/or modify
16   * it under the terms of the GNU General Public License as published by
17   * the Free Software Foundation; either version 2 of the License, or
18   * (at your option) any later version.
19   *
20   * This program is distributed in the hope that it will be useful,
21   * but WITHOUT ANY WARRANTY; without even the implied warranty of
22   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23   * GNU General Public License for more details.
24   *
25   */
26
27
28 public class Subscription {
29
30    private int handle;
31    private int callbackContextHandle = 0;
32
33
34   /**
35    * getHandle - returns handler of the subscription
36    *tCommon: root updated, wakeup
37 1103482260.672 | WakeUpSendin
38    * @return handler of the subscription
39    */
40    public int getHandle()
41    {
42      return this.handle;
43    }
44
45
46   /**
47    * constructor
48    * PROC protected??? - aby sel volat jen z tridy Domain
49    */
50   protected Subscription(Domain d,
51                          int subsmode,
52                                  int substype,
53                          String topic,
54                                  String typeName,
55                                  int bufflength,
56                          NtpTime deadline,
57                                  NtpTime minSeparation,
58                          SubscriptionCallback cb,
59                           /* callBackParam */
60                                              long multicastIPAddress)
61   {
62     this.handle = jORTESubscriptionCreate(d.handle,
63                                               subsmode,
64                                                           substype,
65                                           topic,
66                                                               typeName,
67                                                               bufflength,
68                                           deadline,
69                                                               minSeparation,
70                                                               cb,
71                                        /* callBackParam */  
72                                                                                   multicastIPAddress);
73   }
74
75
76   /**
77    * destructor
78    *
79    */
80    protected void finalize()
81    {
82      destroy();
83    }
84
85
86  /**
87   * destroy - removes a publication
88   * @return boolean: False if bad publication handle, True if  succesful
89   */
90   protected
91   boolean destroy()
92   {
93     System.out.println(":j!: ORTEPublicationDestroy() called..");
94     if(jORTESubscriptionDestroy(this.handle)) return true;
95     System.out.println(":j!: ORTEPublicationDestroy() fault..");
96     return false;
97   }
98
99
100 /* ****************************************************************** *
101  *                                                                    *
102  *                         native methods                             *
103  *                                                                    *
104  * ****************************************************************** */
105
106   public native
107   int jORTESubscriptionCreate(int dhandle,
108                               int subsmode,  /*! union */
109                               int substype,  /*! union */
110                               String topic,
111                               String typeName,
112                               int bufflength,
113                               NtpTime deadline,
114                               NtpTime minSeparation,
115                               SubscriptionCallback cb,
116                             /* recvCallBackParam */
117                               long multicastIPAddress);
118
119  private native
120  boolean jORTESubscriptionDestroy(int dhandle);
121
122
123   /* native 'get' methods */
124   public static native String    getTopic();
125   public static native String    getTypeName();
126   public static native NtpTime   getDeadline();
127   public static native NtpTime   getMinSeparation();
128
129 }
130