public override void RemoveReference(ObjectReference @ref) { if (_newReferences.ReferenceForId(@ref.GetID()) != null) { _newReferences.RemoveReference(@ref); ReferenceCountChanged(-1); } if (_committedReferences.ReferenceForId(@ref.GetID()) != null) { _committedReferences.RemoveReference(@ref); ReferenceCountChanged(-1); } }
private FrozenObjectInfo(ObjectReference @ref, VirtualAttributes virtualAttributes ) : this(@ref == null ? null : @ref.GetObject(), @ref == null ? -1 : @ref.GetID( ), virtualAttributes == null ? null : virtualAttributes.i_database, virtualAttributes == null ? -1 : virtualAttributes.i_uuid, virtualAttributes == null ? 0 : virtualAttributes .i_version) { }
internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer buffer, bool isMigrating, bool isNew) { VirtualAttributes attr = @ref.VirtualAttributes(); ObjectContainerBase container = trans.Container(); bool doAddIndexEntry = isNew && container.MaintainsIndices(); int dbID = 0; bool linkToDatabase = (attr != null && attr.i_database == null) ? true : !isMigrating; if (linkToDatabase) { Db4oDatabase db = ((IInternalObjectContainer)container).Identity(); if (db == null) { // can happen on early classes like Metaxxx, no problem attr = null; } else { if (attr.i_database == null) { attr.i_database = db; // TODO: Should be check for ! client instead of instanceof if (container is LocalObjectContainer) { attr.i_uuid = container.GenerateTimeStampId(); doAddIndexEntry = true; } } db = attr.i_database; if (db != null) { dbID = db.GetID(trans); } } } else { if (attr != null) { dbID = attr.i_database.GetID(trans); } } buffer.WriteInt(dbID); if (attr == null) { buffer.WriteLong(0); return; } buffer.WriteLong(attr.i_uuid); if (doAddIndexEntry) { AddIndexEntry(trans, @ref.GetID(), attr.i_uuid); } }
private FrozenObjectInfo(ObjectReference @ref, VirtualAttributes virtualAttributes ) : this(@ref == null ? null : @ref.GetObject(), @ref == null ? -1 : @ref.GetID( ), virtualAttributes == null ? null : virtualAttributes.i_database, virtualAttributes == null ? -1 : virtualAttributes.i_uuid, virtualAttributes == null ? 0 : virtualAttributes .i_version) { }
private void IdAdd(ObjectReference @ref) { if (DTrace.enabled) { DTrace.IdTreeAdd.Log(@ref.GetID()); } if (_idTree == null) { _idTree = @ref; return; } _idTree = _idTree.Id_add(@ref); }
public object Get(Transaction trans, object onObject) { if (_containingClass == null) { return(null); } ObjectContainerBase container = Container(); if (container == null) { return(null); } lock (container.Lock()) { // FIXME: The following is not really transactional. // This will work OK for normal C/S and for // single local mode but the transaction will // be wrong for MTOC. if (trans == null) { trans = container.Transaction; } container.CheckClosed(); ObjectReference @ref = trans.ReferenceForObject(onObject); if (@ref == null) { return(null); } int id = @ref.GetID(); if (id <= 0) { return(null); } UnmarshallingContext context = new UnmarshallingContext(trans, @ref, Const4.AddToIdTree , false); context.ActivationDepth(new LegacyActivationDepth(1)); return(context.ReadFieldValue(this)); } }
public sealed override bool Delete4(Transaction transaction, ObjectReference @ref , object obj, int cascade, bool userCall) { int id = @ref.GetID(); StatefulBuffer reader = ReadStatefulBufferById(transaction, id); if (reader != null) { if (obj != null) { if ((!ShowInternalClasses()) && Const4.ClassInternal.IsAssignableFrom(obj.GetType ())) { return(false); } } reader.SetCascadeDeletes(cascade); transaction.IdSystem().NotifySlotDeleted(id, SlotChangeFactory.UserObjects); ClassMetadata classMetadata = @ref.ClassMetadata(); classMetadata.Delete(reader, obj); return(true); } return(false); }
public void Delete2(Transaction trans, ObjectReference @ref, object obj, int cascade , bool userCall) { // This check is performed twice, here and in delete3, intentionally. if (BreakDeleteForEnum(@ref, userCall)) { return; } if (obj is Entry) { if (!FlagForDelete(@ref)) { return; } Delete3(trans, @ref, obj, cascade, userCall); return; } trans.Delete(@ref, @ref.GetID(), cascade); }
public ObjectReference Bind2(Transaction trans, ObjectReference oldRef, object obj ) { int id = oldRef.GetID(); trans.RemoveReference(oldRef); ObjectReference newRef = new ObjectReference(ClassMetadataForObject(obj), id); newRef.SetObjectWeak(this, obj); newRef.SetStateDirty(); trans.ReferenceSystem().AddExistingReference(newRef); return newRef; }
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(); }
public virtual void ReadVirtualAttributes(Transaction trans, ObjectReference @ref , bool lastCommitted) { var id = @ref.GetID(); var container = trans.Container(); var buffer = container.ReadBufferById(trans, id, lastCommitted); var oh = new ObjectHeader(this, buffer); var context = new ObjectReferenceContext(trans, buffer, oh, @ref ); Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).ReadVirtualAttributes (context); }
public virtual int ObjectId() { return(_reference.GetID()); }
public virtual void RemoveReference(ObjectReference @ref) { if (DTrace.enabled) { DTrace.ReferenceRemoved.Log(@ref.GetID()); } if (_hashCodeTree != null) { _hashCodeTree = _hashCodeTree.Hc_remove(@ref); } if (_idTree != null) { _idTree = _idTree.Id_remove(@ref); } }
public sealed override bool Delete4(Transaction transaction, ObjectReference @ref , object obj, int cascade, bool userCall) { int id = @ref.GetID(); StatefulBuffer reader = ReadStatefulBufferById(transaction, id); if (reader != null) { if (obj != null) { if ((!ShowInternalClasses()) && Const4.ClassInternal.IsAssignableFrom(obj.GetType ())) { return false; } } reader.SetCascadeDeletes(cascade); transaction.IdSystem().NotifySlotDeleted(id, SlotChangeFactory.UserObjects); ClassMetadata classMetadata = @ref.ClassMetadata(); classMetadata.Delete(reader, obj); return true; } return false; }
internal void Delete3(Transaction trans, ObjectReference @ref, object obj, int cascade , bool userCall) { // The passed reference can be null, when calling from Transaction. if (@ref == null || [email protected]()) { return; } // This check is performed twice, here and in delete2, intentionally. if (BreakDeleteForEnum(@ref, userCall)) { @ref.EndProcessing(); return; } if ([email protected]()) { @ref.EndProcessing(); return; } ClassMetadata yc = @ref.ClassMetadata(); // We have to end processing temporarily here, otherwise the can delete callback // can't do anything at all with this object. @ref.EndProcessing(); ActivateForDeletionCallback(trans, yc, @ref, obj); if (!ObjectCanDelete(trans, yc, @ref)) { return; } @ref.BeginProcessing(); if (DTrace.enabled) { DTrace.Delete.Log(@ref.GetID()); } if (Delete4(trans, @ref, obj, cascade, userCall)) { ObjectOnDelete(trans, yc, @ref); if (ConfigImpl.MessageLevel() > Const4.State) { Message(string.Empty + @ref.GetID() + " delete " + @ref.ClassMetadata().GetName() ); } } @ref.EndProcessing(); }
public sealed override bool Delete4(Transaction ta, ObjectReference yo, object obj , int a_cascade, bool userCall) { MsgD msg = Msg.Delete.GetWriterForInts(_transaction, new int[] { yo.GetID(), userCall ? 1 : 0 }); WriteBatchedMessage(msg); return true; }
internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer buffer, bool isMigrating, bool isNew) { var attr = @ref.VirtualAttributes(); var container = trans.Container(); var doAddIndexEntry = isNew && container.MaintainsIndices(); var dbID = 0; var linkToDatabase = (attr != null && attr.i_database == null) ? true : !isMigrating; if (linkToDatabase) { var db = ((IInternalObjectContainer) container).Identity(); if (db == null) { // can happen on early classes like Metaxxx, no problem attr = null; } else { if (attr.i_database == null) { attr.i_database = db; // TODO: Should be check for ! client instead of instanceof if (container is LocalObjectContainer) { attr.i_uuid = container.GenerateTimeStampId(); doAddIndexEntry = true; } } db = attr.i_database; if (db != null) { dbID = db.GetID(trans); } } } else { if (attr != null) { dbID = attr.i_database.GetID(trans); } } buffer.WriteInt(dbID); if (attr == null) { buffer.WriteLong(0); return; } buffer.WriteLong(attr.i_uuid); if (doAddIndexEntry) { AddIndexEntry(trans, @ref.GetID(), attr.i_uuid); } }