]> rtime.felk.cvut.cz Git - orte.git/blob - orte/java/src/org/ocera/orte/types/DomainProp.java
6db534092ee50e2aa013dc28dcd6710a0da62701
[orte.git] / orte / java / src / org / ocera / orte / types / DomainProp.java
1 /* DomainProp.java */
2
3 /**
4  * Class DomainProp. 
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.types;
25
26
27 public class DomainProp {
28
29  /* load native library 'libjorte.so' */
30   static {
31      System.loadLibrary("jorte");
32   }
33
34
35  /* handler to C struct with default domain properties  */
36   private long handle = 0;
37   private String mgrs = null;
38   
39   public long getHandle() {
40           return this.handle;
41   }
42
43  /**
44   *  setProps - sets DomainProp
45   */
46   public void setProps(String[] mgrs) {
47           this.mgrs = "";
48           for (String item : mgrs) {
49                   this.mgrs += item + ":";
50           }
51           this.mgrs = this.mgrs.substring(0, this.mgrs.length()-1);
52
53           if(!jORTEDomainPropSet(this.handle,this.mgrs))
54                   System.out.println(":j: DomainProp not set !!!");
55   }
56
57  /**
58   * defaultPropsCreate - create DomainProp with handle to default
59   * domain properties
60   *
61   * @return an object with handle to default domain properties
62   */
63   public static
64   DomainProp defaultPropsCreate() {
65      DomainProp prop = new DomainProp();
66      long handle = jORTEDomainPropDefaultGet();
67      prop.handle = handle;
68      return prop;
69   }
70
71   public boolean destroy() {
72     System.out.println(":j: DomainProp destroy called..");
73
74     if(!jORTEDomainPropDestroy(this.handle,this.mgrs)) {
75       System.out.println(":j: DomainProp destroy fault!");
76       return false;
77     }
78     else {
79       System.out.println(":j: DomainProp destroy successful..");
80       return true;
81     }
82   }
83
84
85  /* ****************************************************************** *
86   *                                                                    *
87   *                         native methods                             *
88   *                                                                    *
89   * ****************************************************************** */
90
91
92  /**
93   * jPropDefaultGet - returns handler to default properties of a domain,
94   * if occures some error return NULL.
95   *
96   * @return handler to default properties of a domain, NULL if error
97   */
98   private static native
99   long jORTEDomainPropDefaultGet();
100
101   private native
102   boolean jORTEDomainPropSet(long prophandle, String mgrs);
103
104   private native
105   boolean jORTEDomainPropDestroy(long prophandle, String mgrs);
106
107 }
108