示例#1
0
		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;
		}
示例#2
0
		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();
		}
示例#3
0
		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");
		}
示例#4
0
		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);
		}
示例#5
0
		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);
		}
示例#6
0
		public Account(TStateId sid, IHTimestamp stamp) : base(sid, stamp.ID, stamp.Event, StatePatchMethod.Auto) { }
示例#7
0
 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);
		}
示例#9
0
		//public object Clone()
		//{
		//    return new State(LatestUpdate);
		//}

		public bool IsCompatible(IHTimestamp stamp)
		{
			return LatestUpdate.KnownBy(stamp.Event);
		}
示例#10
0
		public State(IHTimestamp stamp, StatePatchMethod patchMethod)
			: this(new TStateId(m_seed), stamp.ID, stamp.Event, patchMethod)
		{
		}
示例#11
0
		public State(IHTimestamp stamp)
			: this(stamp, StatePatchMethod.Auto)
		{
		}
示例#12
0
		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;
		}
示例#13
0
		protected abstract State AccountFactory(Spacetime st, IHTimestamp stamp, int index);
示例#14
0
        public Particle( IHTimestamp creationStamp)
            : base( creationStamp)
        {

        }
示例#15
0
		public MonitoredAccount(IHTimestamp stamp) : base(stamp) { }