Example #1
0
            public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth
                                             )
            {
                if (!this._firstUpdate)
                {
                    base.WriteUpdate(transaction, updatedepth);
                    return;
                }
                this._firstUpdate = false;
                ObjectContainerBase container = transaction.Container();

                this.SetStateClean();
                MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
                                                                    , false);

                Handlers4.Write(this.ClassMetadata().TypeHandler(), context, this.GetObject());
                int length = this.Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength
                                                                                     ());
                Slot            slot    = context.AllocateNewSlot(length);
                Pointer4        pointer = new Pointer4(this.GetID(), slot);
                ByteArrayBuffer buffer  = context.ToWriteBuffer(pointer);

                container.WriteUpdate(transaction, pointer, this.ClassMetadata(), ArrayType.None,
                                      buffer);
                if (this.IsActive())
                {
                    this.SetStateClean();
                }
            }
Example #2
0
            public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth
                                             )
            {
                if (!_firstUpdate)
                {
                    base.WriteUpdate(transaction, updatedepth);
                    return;
                }
                _firstUpdate = false;
                var container = transaction.Container();

                SetStateClean();
                var context = new MarshallingContext(transaction, this, updatedepth
                                                     , false);

                Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
                var length = Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength
                                                                                ());
                var slot    = context.AllocateNewSlot(length);
                var pointer = new Pointer4(GetID(), slot);
                var buffer  = context.ToWriteBuffer(pointer);

                container.WriteUpdate(transaction, pointer, ClassMetadata(), ArrayType.None,
                                      buffer);
                if (IsActive())
                {
                    SetStateClean();
                }
            }
Example #3
0
        /// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
        /// <exception cref="Db4objects.Db4o.Ext.DatabaseReadOnlyException"></exception>
        public override int StoreInternal(Transaction trans, object obj, IUpdateDepth depth
                                          , bool checkJustSet)
        {
            int id = _parent.GetID(null, obj);

            if (id > 0)
            {
                return(base.StoreInternal(trans, new TransportObjectContainer.KnownObjectIdentity
                                              (id), depth, checkJustSet));
            }
            return(base.StoreInternal(trans, obj, depth, checkJustSet));
        }
Example #4
0
        public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction,
                                        IUpdateDepth updatedepth)
        {
            ContinueSet(transaction, updatedepth);
            // make sure, a concurrent new, possibly triggered by objectOnNew
            // is written to the file
            // preventing recursive
            if (!BeginProcessing())
            {
                return;
            }
            object obj = GetObject();

            if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata
                    ().IsModified(obj))
            {
                EndProcessing();
                return;
            }
            MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
                                                                , false);

            if (context.UpdateDepth().Negative())
            {
                EndProcessing();
                return;
            }
            ObjectContainerBase container = transaction.Container();

            LogEvent(container, "update", Const4.State);
            SetStateClean();
            context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType
                                                       (obj));
            Handlers4.Write(_class.TypeHandler(), context, obj);
            if (context.UpdateDepth().CanSkip(this))
            {
                EndProcessing();
                return;
            }
            Pointer4        pointer = context.AllocateSlot();
            ByteArrayBuffer buffer  = context.ToWriteBuffer(pointer);

            container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType
                                      (obj), buffer);
            if (IsActive())
            {
                SetStateClean();
            }
            EndProcessing();
            container.Callbacks().ObjectOnUpdate(transaction, this);
            ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update);
        }
 public MarshallingContext(Db4objects.Db4o.Internal.Transaction trans, ObjectReference
                           @ref, IUpdateDepth updateDepth, bool isNew)
 {
     // YapClass ID
     // Marshaller Version
     // number of fields
     _transaction   = trans;
     _reference     = @ref;
     _nullBitMap    = new BitMap4(AspectCount());
     _updateDepth   = ClassMetadata().AdjustUpdateDepth(trans, updateDepth);
     _isNew         = isNew;
     _writeBuffer   = new MarshallingBuffer();
     _currentBuffer = _writeBuffer;
 }
		public MarshallingContext(Db4objects.Db4o.Internal.Transaction trans, ObjectReference
			 @ref, IUpdateDepth updateDepth, bool isNew)
		{
			// YapClass ID
			// Marshaller Version
			// number of fields
			_transaction = trans;
			_reference = @ref;
			_nullBitMap = new BitMap4(AspectCount());
			_updateDepth = ClassMetadata().AdjustUpdateDepth(trans, updateDepth);
			_isNew = isNew;
			_writeBuffer = new MarshallingBuffer();
			_currentBuffer = _writeBuffer;
		}
        public override void Marshall(MarshallingContext context, object obj)
        {
            // alive needs to be checked by all callers: Done
            IUpdateDepth updateDepth = context.UpdateDepth();

            if (obj != null && CascadeOnUpdate(context.ClassConfiguration()))
            {
                context.UpdateDepth(AdjustUpdateDepthForCascade(obj, updateDepth));
            }
            context.WriteObjectWithCurrentState(GetHandler(), obj);
            context.UpdateDepth(updateDepth);
            if (HasIndex())
            {
                context.AddIndexEntry(this, obj);
            }
        }
Example #8
0
        /// <summary>return false if class not completely initialized, otherwise true</summary>
        internal virtual bool ContinueSet(Transaction trans, IUpdateDepth
                                          updateDepth)
        {
            if (!BitIsTrue(Const4.Continue))
            {
                return(true);
            }
            if (!_class.StateOK())
            {
                return(false);
            }
            if (!_class.AspectsAreInitialized())
            {
                return(false);
            }
            if (DTrace.enabled)
            {
                DTrace.Continueset.Log(GetID());
            }
            BitFalse(Const4.Continue);
            var context = new MarshallingContext(trans, this, updateDepth, true
                                                 );

            Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
            var pointer   = context.AllocateSlot();
            var buffer    = context.ToWriteBuffer(pointer);
            var container = trans.Container();

            container.WriteNew(trans, pointer, _class, buffer);
            var obj = _object;

            ObjectOnNew(trans, obj);
            if (_class.HasIdentity())
            {
                _object = container.NewWeakReference(this, obj);
            }
            SetStateClean();
            EndProcessing();
            return(true);
        }
Example #9
0
			public PendingSet(Transaction transaction_, ObjectReference ref_, IUpdateDepth depth_
				)
			{
				this.transaction = transaction_;
				this.@ref = ref_;
				this.depth = depth_;
			}
Example #10
0
		public int StoreAfterReplication(Transaction trans, object obj, IUpdateDepth depth
			, bool checkJust)
		{
			if (obj is IDb4oType)
			{
				IDb4oType db4oType = Db4oTypeStored(trans, obj);
				if (db4oType != null)
				{
					return GetID(trans, db4oType);
				}
			}
			return Store2(trans, obj, depth, checkJust);
		}
Example #11
0
		public int Store2(Transaction trans, object obj, IUpdateDepth updateDepth, bool checkJustSet
			)
		{
			if (obj == null || (obj is ITransientClass))
			{
				return 0;
			}
			ObjectAnalyzer analyzer = new ObjectAnalyzer(this, obj);
			analyzer.Analyze(trans);
			if (analyzer.NotStorable())
			{
				return 0;
			}
			ObjectReference @ref = analyzer.ObjectReference();
			if (@ref == null)
			{
				ClassMetadata classMetadata = analyzer.ClassMetadata();
				if (!ObjectCanNew(trans, classMetadata, obj))
				{
					return 0;
				}
				@ref = new ObjectReference();
				@ref.Store(trans, classMetadata, obj);
				trans.AddNewReference(@ref);
				if (obj is IDb4oTypeImpl)
				{
					((IDb4oTypeImpl)obj).SetTrans(trans);
				}
				if (ConfigImpl.MessageLevel() > Const4.State)
				{
					Message(string.Empty + @ref.GetID() + " new " + @ref.ClassMetadata().GetName());
				}
				FlagAsHandled(@ref);
				StillToSet(trans, @ref, updateDepth);
			}
			else
			{
				if (@ref.IsFlaggedAsHandled(_topLevelCallId))
				{
					AssertNotInCallback();
				}
				if (CanUpdate())
				{
					if (checkJustSet)
					{
						if (([email protected]()) && HandledInCurrentTopLevelCall(@ref))
						{
							return @ref.GetID();
						}
					}
					if (updateDepth.SufficientDepth())
					{
						FlagAsHandled(@ref);
						@ref.WriteUpdate(trans, updateDepth);
					}
				}
			}
			ProcessPendingClassUpdates();
			return @ref.GetID();
		}
Example #12
0
		/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
		/// <exception cref="Db4objects.Db4o.Ext.DatabaseReadOnlyException"></exception>
		public virtual int StoreInternal(Transaction trans, object obj, IUpdateDepth depth
			, bool checkJustSet)
		{
			CheckReadOnly();
			return (((int)AsTopLevelStore(new _IFunction4_1599(this, obj, depth, checkJustSet
				), trans)));
		}
Example #13
0
			public _IFunction4_1599(ObjectContainerBase _enclosing, object obj, IUpdateDepth 
				depth, bool checkJustSet)
			{
				this._enclosing = _enclosing;
				this.obj = obj;
				this.depth = depth;
				this.checkJustSet = checkJustSet;
			}
Example #14
0
 private IUpdateDepth AdjustUpdateDepthForCascade(object obj, IUpdateDepth updateDepth
                                                  )
 {
     return(updateDepth.AdjustUpdateDepthForCascade(_containingClass.IsCollection(obj)
                                                    ));
 }
Example #15
0
		/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
		/// <exception cref="Db4objects.Db4o.Ext.DatabaseReadOnlyException"></exception>
		public int Store(Transaction trans, object obj, IUpdateDepth depth)
		{
			lock (_lock)
			{
				try
				{
					ShowInternalClasses(true);
					return StoreInternal(trans, obj, depth, true);
				}
				finally
				{
					ShowInternalClasses(false);
				}
			}
		}
Example #16
0
			public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth
				)
			{
				if (!this._firstUpdate)
				{
					base.WriteUpdate(transaction, updatedepth);
					return;
				}
				this._firstUpdate = false;
				ObjectContainerBase container = transaction.Container();
				this.SetStateClean();
				MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
					, false);
				Handlers4.Write(this.ClassMetadata().TypeHandler(), context, this.GetObject());
				int length = this.Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength
					());
				Slot slot = context.AllocateNewSlot(length);
				Pointer4 pointer = new Pointer4(this.GetID(), slot);
				ByteArrayBuffer buffer = context.ToWriteBuffer(pointer);
				container.WriteUpdate(transaction, pointer, this.ClassMetadata(), ArrayType.None, 
					buffer);
				if (this.IsActive())
				{
					this.SetStateClean();
				}
			}
		public virtual void UpdateDepth(IUpdateDepth depth)
		{
			_updateDepth = depth;
		}
Example #18
0
 public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth
     )
 {
     if (!_firstUpdate)
     {
         base.WriteUpdate(transaction, updatedepth);
         return;
     }
     _firstUpdate = false;
     var container = transaction.Container();
     SetStateClean();
     var context = new MarshallingContext(transaction, this, updatedepth
         , false);
     Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
     var length = Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength
         ());
     var slot = context.AllocateNewSlot(length);
     var pointer = new Pointer4(GetID(), slot);
     var buffer = context.ToWriteBuffer(pointer);
     container.WriteUpdate(transaction, pointer, ClassMetadata(), ArrayType.None,
         buffer);
     if (IsActive())
     {
         SetStateClean();
     }
 }
Example #19
0
 /// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
 /// <exception cref="Db4objects.Db4o.Ext.DatabaseReadOnlyException"></exception>
 public override int StoreInternal(Transaction trans, object obj, IUpdateDepth depth
     , bool checkJustSet)
 {
     var id = _parent.GetID(null, obj);
     if (id > 0)
     {
         return base.StoreInternal(trans, new KnownObjectIdentity
             (id), depth, checkJustSet);
     }
     return base.StoreInternal(trans, obj, depth, checkJustSet);
 }
Example #20
0
 public IUpdateDepth AdjustUpdateDepth(Transaction trans, IUpdateDepth depth)
 {
     return depth.Adjust(this);
 }
Example #21
0
		public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction, 
			IUpdateDepth updatedepth)
		{
			ContinueSet(transaction, updatedepth);
			// make sure, a concurrent new, possibly triggered by objectOnNew
			// is written to the file
			// preventing recursive
			if (!BeginProcessing())
			{
				return;
			}
			object obj = GetObject();
			if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata
				().IsModified(obj))
			{
				EndProcessing();
				return;
			}
			MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
				, false);
			if (context.UpdateDepth().Negative())
			{
				EndProcessing();
				return;
			}
			ObjectContainerBase container = transaction.Container();
			LogEvent(container, "update", Const4.State);
			SetStateClean();
			context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType
				(obj));
			Handlers4.Write(_class.TypeHandler(), context, obj);
			if (context.UpdateDepth().CanSkip(this))
			{
				EndProcessing();
				return;
			}
			Pointer4 pointer = context.AllocateSlot();
			ByteArrayBuffer buffer = context.ToWriteBuffer(pointer);
			container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType
				(obj), buffer);
			if (IsActive())
			{
				SetStateClean();
			}
			EndProcessing();
			container.Callbacks().ObjectOnUpdate(transaction, this);
			ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update);
		}
Example #22
0
		/// <summary>return false if class not completely initialized, otherwise true</summary>
		internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth
			 updateDepth)
		{
			if (!BitIsTrue(Const4.Continue))
			{
				return true;
			}
			if (!_class.StateOK())
			{
				return false;
			}
			if (!_class.AspectsAreInitialized())
			{
				return false;
			}
			if (DTrace.enabled)
			{
				DTrace.Continueset.Log(GetID());
			}
			BitFalse(Const4.Continue);
			MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true
				);
			Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
			Pointer4 pointer = context.AllocateSlot();
			ByteArrayBuffer buffer = context.ToWriteBuffer(pointer);
			ObjectContainerBase container = trans.Container();
			container.WriteNew(trans, pointer, _class, buffer);
			object obj = _object;
			ObjectOnNew(trans, obj);
			if (_class.HasIdentity())
			{
				_object = container.NewWeakReference(this, obj);
			}
			SetStateClean();
			EndProcessing();
			return true;
		}
Example #23
0
		internal virtual void StillToSet(Transaction transaction, ObjectReference @ref, IUpdateDepth
			 updateDepth)
		{
			if (StackIsSmall())
			{
				if (@ref.ContinueSet(transaction, updateDepth))
				{
					return;
				}
			}
			_stillToSet = new List4(_stillToSet, new ObjectContainerBase.PendingSet(transaction
				, @ref, updateDepth));
		}
		private IUpdateDepth AdjustUpdateDepthForCascade(object obj, IUpdateDepth updateDepth
			)
		{
			return updateDepth.AdjustUpdateDepthForCascade(_containingClass.IsCollection(obj)
				);
		}
Example #25
0
		public virtual void StoreAll(Transaction transaction, IEnumerator objects, IUpdateDepth
			 depth)
		{
			while (objects.MoveNext())
			{
				Store(transaction, objects.Current, depth);
			}
		}
 public virtual void UpdateDepth(IUpdateDepth depth)
 {
     _updateDepth = depth;
 }