Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add doc to surf java
[simgrid.git] / src / bindings / java / org / simgrid / surf / Cpu.java
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 2.0.11
4  *
5  * Do not make changes to this file unless you know what you are doing--modify
6  * the SWIG interface file instead.
7  * ----------------------------------------------------------------------------- */
8
9 package org.simgrid.surf;
10
11 /**
12   * A generic resource for the cpu component
13   * @see CpuModel
14   * @see CpuAction
15   */
16 public class Cpu extends Resource {
17   private long swigCPtr;
18
19   protected Cpu(long cPtr, boolean cMemoryOwn) {
20     super(SurfJNI.Cpu_SWIGUpcast(cPtr), cMemoryOwn);
21     swigCPtr = cPtr;
22   }
23
24   protected static long getCPtr(Cpu obj) {
25     return (obj == null) ? 0 : obj.swigCPtr;
26   }
27
28   protected void finalize() {
29     delete();
30   }
31
32   public synchronized void delete() {
33     if (swigCPtr != 0) {
34       if (swigCMemOwn) {
35         swigCMemOwn = false;
36         SurfJNI.delete_Cpu(swigCPtr);
37       }
38       swigCPtr = 0;
39     }
40     super.delete();
41   }
42
43   protected void swigDirectorDisconnect() {
44     swigCMemOwn = false;
45     delete();
46   }
47
48   public void swigReleaseOwnership() {
49     swigCMemOwn = false;
50     SurfJNI.Cpu_change_ownership(this, swigCPtr, false);
51   }
52
53   public void swigTakeOwnership() {
54     swigCMemOwn = true;
55     SurfJNI.Cpu_change_ownership(this, swigCPtr, true);
56   }
57
58   
59   /**
60     * A cpu constructor (using LMM)
61     * @param model
62     * @param name
63     * @param properties
64     * @param constraint
65     * @param core
66     * @param powerPeak
67     * @param powerScale
68     */
69   public Cpu(Model model, String name, XbtDict props, LmmConstraint constraint, int core, double powerPeak, double powerScale) {
70     this(SurfJNI.new_Cpu__SWIG_0(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, LmmConstraint.getCPtr(constraint), constraint, core, powerPeak, powerScale), true);
71     SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true);
72   }
73
74   
75   /**
76     * A cpu constructor
77     * @param model
78     * @param name
79     * @param properties
80     * @param core
81     * @param powerPeak
82     * @param powerScale
83     */
84   public Cpu(Model model, String name, XbtDict props, int core, double powerPeak, double powerScale) {
85     this(SurfJNI.new_Cpu__SWIG_1(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, core, powerPeak, powerScale), true);
86     SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true);
87   }
88
89   
90   /**
91     * @return The current power peak
92     */
93   public double getCurrentPowerPeak() {
94     return (getClass() == Cpu.class) ? SurfJNI.Cpu_getCurrentPowerPeak(swigCPtr, this) : SurfJNI.Cpu_getCurrentPowerPeakSwigExplicitCpu(swigCPtr, this);
95   }
96
97   
98   /**
99     * Execute some quantity of computation
100     * @param size The processing amount (in flop) needed to process
101     * @return A cpu action representing code execution
102     */
103   public CpuAction execute(double size) {
104   long cPtr = SurfJNI.Cpu_execute(swigCPtr, this, size);
105   return (CpuAction)Surf.getCpuDirector(cPtr);
106 }
107
108   
109   /**
110     * Make a process sleep for duration
111     * @param duration The number of seconds to sleep
112     * @return A cpu action representing sleeping
113     */
114   public CpuAction sleep(double duration) {
115   long cPtr = SurfJNI.Cpu_sleep(swigCPtr, this, duration);
116   return (CpuAction)Surf.getCpuDirector(cPtr);
117 }
118
119   
120   /**
121     * @return The number of cores on the cpu
122     */
123   public int getCore() {
124     return (getClass() == Cpu.class) ? SurfJNI.Cpu_getCore(swigCPtr, this) : SurfJNI.Cpu_getCoreSwigExplicitCpu(swigCPtr, this);
125   }
126
127   
128   /**
129     * TODO
130     * @param load
131     */
132   public double getSpeed(double load) {
133     return (getClass() == Cpu.class) ? SurfJNI.Cpu_getSpeed(swigCPtr, this, load) : SurfJNI.Cpu_getSpeedSwigExplicitCpu(swigCPtr, this, load);
134   }
135
136   
137   /**
138     * TODO
139     */
140   public double getAvailableSpeed() {
141     return (getClass() == Cpu.class) ? SurfJNI.Cpu_getAvailableSpeed(swigCPtr, this) : SurfJNI.Cpu_getAvailableSpeedSwigExplicitCpu(swigCPtr, this);
142   }
143
144   
145   /**
146     * @param pstate_index index of power peak to get
147     * @return Power peak at index
148     */
149   public double getPowerPeakAt(int pstate_index) {
150     return SurfJNI.Cpu_getPowerPeakAt(swigCPtr, this, pstate_index);
151   }
152
153   
154   /**
155     * @return Number of power peak
156     */
157   public int getNbPstates() {
158     return SurfJNI.Cpu_getNbPstates(swigCPtr, this);
159   }
160
161   
162   /**
163     * @param  index of power peak to set
164     */
165   public void setPowerPeakAt(int pstate_index) {
166     SurfJNI.Cpu_setPowerPeakAt(swigCPtr, this, pstate_index);
167   }
168
169   
170   /**
171     * @param The new state of the cpu
172     */
173   public void setState(ResourceState state) {
174     SurfJNI.Cpu_setState(swigCPtr, this, state.swigValue());
175   }
176
177 }