Exemplo n.º 1
0
        /// <summary>
        /// Merge the changed members based on the timestamps.
        /// <para/>
        /// All members of the given entity that are marked as changed will be merged into the
        /// current entity object in the pool given that the top member has a timestamp that is "newer" than
        /// the corresponding timestamp in the Dob.
        /// </summary>
        /// <param name="entity">Entity to create or update.</param>
        /// <param name="instanceId">Instance id.</param>
        /// <param name="timestamp">Timestamp valid for the top members that are marked as changed.</param>
        /// <param name="handlerId">Handler id.</param>
        public void InjectChanges(Entity entity,
                                  Typesystem.InstanceId instanceId,
                                  System.Int64 timestamp,
                                  Typesystem.HandlerId handlerId)
        {
            byte success;

            //TODO: serialize directly to shared memory
            System.Int32  blobSize = entity.CalculateBlobSize();
            System.IntPtr blob     = Marshal.AllocHGlobal(blobSize); //allocate blob
            System.IntPtr beginningOfUnused;
            Typesystem.Internal.InternalOperations.FormatBlob(blob, blobSize, entity.GetTypeId(), out beginningOfUnused);
            entity.WriteToBlob(blob, ref beginningOfUnused);

            System.IntPtr instanceIdStr = Dob.Typesystem.Internal.InternalOperations.CStringOf(instanceId.RawString);
            System.IntPtr handlerIdStr  = Dob.Typesystem.Internal.InternalOperations.CStringOf(handlerId.RawString);

            Interface.DoseC_InjectEntity(ControllerId,
                                         blob,
                                         instanceId.RawValue,
                                         instanceIdStr,
                                         handlerId.RawValue,
                                         handlerIdStr,
                                         timestamp,
                                         out success);

            Marshal.FreeHGlobal(instanceIdStr);
            Marshal.FreeHGlobal(handlerIdStr);

            if (!Interface.BoolOf(success))
            {
                Typesystem.LibraryExceptions.Instance.Throw();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete the given instance based on the timestamp.
        /// <para/>
        /// The given instance is deleted if the timestamp is "newer" than all top member timestamps
        /// for the current instance.
        /// </summary>
        /// <param name="entityId">Entity id of the instance to delete.</param>
        /// <param name="timestamp">Timestamp Time of deletion.</param>
        /// <param name="handlerId">Handler id.</param>
        public void InjectDelete(Typesystem.EntityId entityId,
                                 System.Int64 timestamp,
                                 Typesystem.HandlerId handlerId)
        {
            byte success;

            System.IntPtr instanceIdStr = Dob.Typesystem.Internal.InternalOperations.CStringOf(entityId.InstanceId.RawString);
            System.IntPtr handlerIdStr  = Dob.Typesystem.Internal.InternalOperations.CStringOf(handlerId.RawString);

            Interface.DoseC_InjectDeletedEntity(ControllerId,
                                                entityId.TypeId,
                                                entityId.InstanceId.RawValue,
                                                instanceIdStr,
                                                handlerId.RawValue,
                                                handlerIdStr,
                                                timestamp,
                                                out success);

            Marshal.FreeHGlobal(instanceIdStr);
            Marshal.FreeHGlobal(handlerIdStr);

            if (!Interface.BoolOf(success))
            {
                Typesystem.LibraryExceptions.Instance.Throw();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Allows an application to inject an initial entity state.
        /// </summary>
        /// <param name="entity">Entity to create.</param>
        /// <param name="instanceId">Instance id of entity to inject.</param>
        /// <param name="handlerId">The handler id to inject to.</param>
        public void InitialSet(Entity entity,
                               Typesystem.InstanceId instanceId,
                               Typesystem.HandlerId handlerId)
        {
            byte success;

            //TODO: serialize directly to shared memory
            System.Int32  blobSize = entity.CalculateBlobSize();
            System.IntPtr blob     = Marshal.AllocHGlobal(blobSize); //allocate blob
            System.IntPtr beginningOfUnused;
            Typesystem.Internal.InternalOperations.FormatBlob(blob, blobSize, entity.GetTypeId(), out beginningOfUnused);
            entity.WriteToBlob(blob, ref beginningOfUnused);

            System.IntPtr instanceIdStr = Dob.Typesystem.Internal.InternalOperations.CStringOf(instanceId.RawString);
            System.IntPtr handlerIdStr  = Dob.Typesystem.Internal.InternalOperations.CStringOf(handlerId.RawString);

            Interface.DoseC_SetEntity(ControllerId,
                                      blob,
                                      instanceId.RawValue,
                                      instanceIdStr,
                                      handlerId.RawValue,
                                      handlerIdStr,
                                      Interface.ByteOf(false),   // false => don't consider change flags
                                      Interface.ByteOf(true),    // true => this is an initial injection
                                      out success);

            Marshal.FreeHGlobal(instanceIdStr);
            Marshal.FreeHGlobal(handlerIdStr);

            if (!Interface.BoolOf(success))
            {
                Typesystem.LibraryExceptions.Instance.Throw();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Equality operator.
        /// </summary>
        /// <param name="obj">The HandlerId to compare with.</param>
        /// <returns>True if equal.</returns>
        public override bool Equals(object obj)
        {
            HandlerId other = obj as HandlerId;

            if (other == null)
            {
                return(false);
            }
            else
            {
                return(m_handlerId == other.m_handlerId);
            }
        }
Exemplo n.º 5
0
Arquivo: Player.cs Projeto: bjowes/cwg
 public void OnRevokedRegistration(long typeId, Safir.Dob.Typesystem.HandlerId handlerId)
 {
     System.Console.WriteLine("Revoked by handler " + handlerId.ToString());
 }