protected override State AccountFactory(Spacetime st, IHTimestamp stamp, int index) { var firstId = TStateId.DebugCreate(111ul); var secondId = TStateId.DebugCreate(222ul); var ret = new MonitoredAccount(TStateId.DebugCreate(111ul * ((ulong)index + 1)), stamp); if (index == 0) { ret.RegisterInlineTrigger((s) => { StateRef from = new ScopedStateRef(firstId, typeof(MonitoredAccount).Name), to = new ScopedStateRef(secondId, typeof(MonitoredAccount).Name); WithIn.GetWithin().DeferExecute("Transfer", Utils.MakeArgList("fromAcc", from, "toAcc", to), 100.0f); }, (s) => (s as MonitoredAccount).Balance > 100 ); } else { ret.RegisterInlineTrigger((s) => { StateRef from = new ScopedStateRef(secondId, typeof(MonitoredAccount).Name), to = new ScopedStateRef(firstId, typeof(MonitoredAccount).Name); WithIn.GetWithin().DeferExecute("Transfer", Utils.MakeArgList("fromAcc", from, "toAcc", to), 100.0f); }, (s) => (s as MonitoredAccount).Balance > 100 ); } return ret; }
public VMState( IHTimestamp stamp) : base(new TStateId(19830602), stamp.ID, stamp.Event, StatePatchMethod.Customized) { m_interpreter = new LangVM(); //< we don't really need one interpreter per VMstate //< interpreter instances can be shared by copy-on-write m_interpreter.DeclareAndLink("Cocktail.DeclareAndLink", typeof(LangVM).GetMethod("DeclareAndLink_cocktail")); LoadStdLib(); }
public IHTimestamp Join(IHTimestamp rhs) { var itcRight = rhs as ITCTimestamp; if (m_IdCache.GetCausalParent() == itcRight.m_IdCache.GetCausalParent()) { var newStamp = itc.TimeStamp.Join(m_impl, itcRight.m_impl); return new ITCTimestamp(new ITCIdentity(newStamp.ID, m_IdCache.GetCausalParent()), new ITCEvent(newStamp.Event)); } throw new ApplicationException("Not supported"); }
public SpacetimeStorage(IHTimestamp stamp, IEnumerable<State> initialStates, IEnumerable<ExternalSTEntry> initialExternalSTs) :base(stamp, StatePatchMethod.Customized) { foreach (var s in initialStates) AddNativeState(s); // add itself m_nativeStates.Add(this.StateId, this); foreach (var st in initialExternalSTs) AddSpacetime(st); }
internal void AddSpacetime(IHTimestamp foreignStamp, IEnumerable<State> newStates) { ExternalSTEntry entry; entry.IsListeningTo = false; entry.SpacetimeId = foreignStamp.ID; entry.LatestUpateTime = foreignStamp.Event; entry.LocalStates = newStates.Where(v => v.SpacetimeID == foreignStamp.ID).ToDictionary(s => s.StateId); AddSpacetime(entry); }
public Account(TStateId sid, IHTimestamp stamp) : base(sid, stamp.ID, stamp.Event, StatePatchMethod.Auto) { }
public Account( IHTimestamp stamp) : base(stamp) { }
protected override State AccountFactory(Spacetime st, IHTimestamp stamp, int index) { return new Account(TStateId.DebugCreate(111ul * ((ulong)index + 1)), stamp); }
//public object Clone() //{ // return new State(LatestUpdate); //} public bool IsCompatible(IHTimestamp stamp) { return LatestUpdate.KnownBy(stamp.Event); }
public State(IHTimestamp stamp, StatePatchMethod patchMethod) : this(new TStateId(m_seed), stamp.ID, stamp.Event, patchMethod) { }
public State(IHTimestamp stamp) : this(stamp, StatePatchMethod.Auto) { }
public StateSnapshot Snapshot( IHTimestamp overridingTS) { var retval = new StateSnapshot(StateId, GetType().AssemblyQualifiedName, overridingTS, Rev); if (m_patchMethod == StatePatchMethod.Customized) { return DoSnapshot(retval); } foreach (var fi in GetFields()) { var fval = fi.GetValue(this); retval.Fields.Add(new StateSnapshot.FieldEntry() { Name = fi.Name, Value = fval, Type = fi.FieldType, Attrib = fi.GetCustomAttributes(typeof(StateFieldAttribute), false).FirstOrDefault() as StateFieldAttribute }); } return retval; }
protected abstract State AccountFactory(Spacetime st, IHTimestamp stamp, int index);
public Particle( IHTimestamp creationStamp) : base( creationStamp) { }
public MonitoredAccount(IHTimestamp stamp) : base(stamp) { }