1 2 package SOFA.SOFAnode.Made.TIR.Impl; 3 import java.io.IOException ; 4 import java.rmi.RemoteException ; 5 import java.rmi.server.UnicastRemoteObject ; 6 7 import SOFA.SOFAnode.Made.TIR.Container; 8 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 9 import SOFA.SOFAnode.Made.TIR.ExprFloat; 10 import SOFA.SOFAnode.Made.TIR.ExprOperDef; 11 import SOFA.SOFAnode.Made.TIR.ExprOperKind; 12 import SOFA.SOFAnode.Made.TIR.Repository; 13 import SOFA.SOFAnode.Made.TIR.StateKind; 14 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 15 16 public class ExprFloatImpl extends UnicastRemoteObject implements ExprFloat, TIRImplObject { 17 float v; 18 ExprOperKindImpl eok; 19 DefinitionKindImpl defKindImpl; 20 StateKindImpl stKindImpl; 21 22 public ExprFloatImpl(float value) throws RemoteException { 23 v = value; 24 eok = new ExprOperKindImpl(ExprOperKind.eok_float); 25 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 26 stKindImpl = new StateKindImpl(StateKind.sk_work); 27 } 28 29 public ExprFloatImpl() throws RemoteException { 30 v = 0.0f; 31 eok = new ExprOperKindImpl(ExprOperKind.eok_float); 32 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 33 stKindImpl = new StateKindImpl(StateKind.sk_normal); 34 } 35 36 37 public DefinitionKind get_def_kind() throws RemoteException { 38 return (DefinitionKind) defKindImpl; 39 } 40 41 42 public StateKind get_state() throws RemoteException { 43 return (StateKind) stKindImpl; 44 } 45 46 public float value() throws RemoteException { 47 return v; 48 } 49 50 public void value(float value) { 51 v = value; 52 } 53 54 public ExprOperKind get_eok_kind() throws RemoteException { 55 return (ExprOperKind) eok; 56 } 57 58 public ExprOperDef calculate() throws RemoteException { 59 return this; 60 } 61 62 public void save(Storage st) throws RemoteException , TIRExceptStorage { 63 try { 64 st.curOutFile.writeInt(eok.value()); 65 st.curOutFile.writeFloat(v); 66 } catch (IOException e) { 67 throw new TIRExceptStorage("Can't write in directory "+st.current+"."); 68 } 69 } 70 71 public void load(Storage st) throws RemoteException , TIRExceptStorage { 72 try { 73 v = st.curInFile.readFloat(); 74 } catch (IOException e) { 75 throw new TIRExceptStorage("Can't read in directory "+st.current+"."); 76 } 77 } 78 79 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage { 80 ; 81 } 82 83 public boolean isNew() { 84 return (stKindImpl.value()==StateKind.sk_work); 85 } 86 87 public void canCommit() throws RemoteException , TIRExceptCommit {;} 88 89 public void doCommit(Container in, Repository rep) throws RemoteException { 90 if (stKindImpl.value()==StateKind.sk_work) 91 stKindImpl.toNormal(); 92 } 93 94 public void doAbort(long workId) throws RemoteException {} 95 } 96 | Popular Tags |