]> rtime.felk.cvut.cz Git - orte.git/blob - orte/java/src/org/ocera/orte/DomainMgr.java
0919db80e09b1267ab5f0c570e8aaf8b7d3dddc8
[orte.git] / orte / java / src / org / ocera / orte / DomainMgr.java
1 /* DomainMgr.java */
2
3 /**
4  * Class DomainMgr provides methods for work with the ORTE manager domain.
5  *
6  * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
7  * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
8  * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
9  * @author dedication to Kj
10  * @version 0.1
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  */
23
24 package org.ocera.orte;
25 import org.ocera.orte.types.DomainEvents;
26 import org.ocera.orte.types.DomainProp;
27 import org.ocera.orte.types.ORTEConstant;
28
29
30 public class DomainMgr extends Domain 
31 {
32
33    /**
34         * Default constructor. Creates default Manager domain.
35         * (domain = ORTE_DEFAULT_DOMAI, suspended thread = false)
36         **/
37    public DomainMgr()
38    {
39          super();
40      handle = jORTEDomainDefaultMgrCreate(ORTEConstant.ORTE_DEFAULT_DOMAIN,
41                                               false);
42    }
43
44
45    /**
46         * User constructor. Creates manager domain with user parameters.
47         * @param given domain
48         * @param domain properties
49         * @param domain events
50         * @param specifies whether threads of thiss manager should be started as well (False) or stay suspended (True) 
51         **/
52     /* TODO dodelat instance 'props', 'events' */
53     public DomainMgr(int domain,
54                          DomainProp props,
55                          DomainEvents events,
56                          boolean suspend)
57     {
58      super();    // set Default Domain Properties
59      if(props == null) {
60          this.props = DomainProp.defaultPropsCreate();
61      }
62      else {
63          this.props = props;
64      }
65      // init Domain Events
66      if(events == null) {
67          this.events.init();
68      }
69      else {
70          this.events = events;
71      }
72            handle = jORTEDomainMgrCreate(domain,
73                                          props.handle,
74                                              events==null ? 0 : events.getHandle(),
75                                                                  suspend);
76     }
77
78          /*
79      public void create()
80      {}
81          */
82      
83          /**
84           * destroy - destroy manager object
85           * @return boolean: False if bad publication handle, True if  succesful
86           */
87           public
88           boolean destroy()
89           {
90             if(jORTEDomainMgrDestroy(this.handle) && this.props.destroy()) return true;
91             System.out.println(":j!: ORTEDomainMgrDestroy() fault..");
92             return false;
93           }
94   
95
96   /* ****************************************************************** *
97    *                                                                    *
98    *                         native methods                             *
99    *                                                                    *
100    * ****************************************************************** */
101   /**
102    * jORTEDomainMgrCreate - creates default Manager
103    * @param handle of the domain
104    * @return handle of the Manager
105    **/
106    private static native
107    long jORTEDomainDefaultMgrCreate(int dhandle,boolean suspend);
108
109
110   /**
111    * jORTEDomainMgrCreate - creates the Manager
112    * @param handle of the domain
113    * @param handle of the domain properties
114    * @param handle of the domain events
115    * @return handle of the Manager
116    **/
117    private static native
118    long jORTEDomainMgrCreate(int dhandle,
119                              long propsHandle,
120                              long eventsHandle,
121                              boolean suspend);
122
123   /**
124    * jORTEDomainMgrDestroy - destroy manager object
125    * @param hadle of the domain
126    * @return if some error occures return False, otherwise True
127    **/
128    private static native
129    boolean jORTEDomainMgrDestroy(long dhandle);  
130         
131 }