Opened;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+
+namespace Db4objects.Db4o.Events
+{
+ /// Arguments for container related events.
+ /// Arguments for container related events.
+ /// IEventRegistry
+ public class ObjectContainerEventArgs : EventArgs
+ {
+ private readonly IObjectContainer _container;
+
+ public ObjectContainerEventArgs(IObjectContainer container)
+ {
+ _container = container;
+ }
+
+ public virtual IObjectContainer ObjectContainer
+ {
+ get
+ {
+ return _container;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Events;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Events
+{
+ /// Arguments for object related events.
+ /// Arguments for object related events.
+ /// IEventRegistry
+ public abstract class ObjectEventArgs : TransactionalEventArgs
+ {
+ /// Creates a new instance for the specified object.
+ /// Creates a new instance for the specified object.
+ protected ObjectEventArgs(Transaction transaction) : base(transaction)
+ {
+ }
+
+ /// The object that triggered this event.
+ /// The object that triggered this event.
+ public abstract object Object
+ {
+ get;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,35 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Events;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Events
+{
+ public class ObjectInfoEventArgs : ObjectEventArgs
+ {
+ private readonly IObjectInfo _info;
+
+ public ObjectInfoEventArgs(Transaction transaction, IObjectInfo info) : base(transaction
+ )
+ {
+ _info = info;
+ }
+
+ public override object Object
+ {
+ get
+ {
+ return _info.GetObject();
+ }
+ }
+
+ public virtual IObjectInfo Info
+ {
+ get
+ {
+ return _info;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,42 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Events;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Query;
+
+namespace Db4objects.Db4o.Events
+{
+ ///
+ /// Arguments for
+ /// Db4objects.Db4o.Query.IQuery
+ /// related events.
+ ///
+ /// IEventRegistry
+ public class QueryEventArgs : TransactionalEventArgs
+ {
+ private IQuery _query;
+
+ ///
+ /// Creates a new instance for the specified
+ /// Db4objects.Db4o.Query.IQuery
+ /// instance.
+ ///
+ public QueryEventArgs(Transaction transaction, IQuery q) : base(transaction)
+ {
+ _query = q;
+ }
+
+ ///
+ /// The
+ /// Db4objects.Db4o.Query.IQuery
+ /// which triggered the event.
+ ///
+ public virtual IQuery Query
+ {
+ get
+ {
+ return _query;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Events
+{
+ /// 7.12
+ public class StringEventArgs : EventArgs
+ {
+ public StringEventArgs(string message)
+ {
+ _message = message;
+ }
+
+ public virtual string Message
+ {
+ get
+ {
+ return _message;
+ }
+ }
+
+ private readonly string _message;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+
+namespace Db4objects.Db4o.Events
+{
+ public class TransactionalEventArgs : EventArgs
+ {
+ private readonly Db4objects.Db4o.Internal.Transaction _transaction;
+
+ public TransactionalEventArgs(Db4objects.Db4o.Internal.Transaction transaction)
+ {
+ _transaction = transaction;
+ }
+
+ public virtual object Transaction()
+ {
+ return _transaction;
+ }
+
+ public virtual IObjectContainer ObjectContainer()
+ {
+ return _transaction.ObjectContainer();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// db4o-specific exception.
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the current
+ /// backup
+ /// process encounters another backup process already running.
+ ///
+ [System.Serializable]
+ public class BackupInProgressException : Db4oRecoverableException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,17 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Ext
+{
+ [System.Serializable]
+ public partial class CompositeDb4oException : Exception
+ {
+ public readonly Exception[] _exceptions;
+
+ public CompositeDb4oException(Exception[] exceptions)
+ {
+ _exceptions = exceptions;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// db4o-specific exception.
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the object container required for
+ /// the current operation was closed or failed to open.
+ ///
+ /// Db4objects.Db4o.Db4oFactory.OpenFile(string)
+ ///
+ /// Db4objects.Db4o.IObjectContainer.Close()
+ ///
+ [System.Serializable]
+ public class DatabaseClosedException : Db4oFatalException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,39 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// this Exception is thrown during any of the db4o open calls
+ /// if the database file is locked by another process.
+ ///
+ ///
+ /// db4o-specific exception.
+ /// this Exception is thrown during any of the db4o open calls
+ /// if the database file is locked by another process.
+ ///
+ /// Db4objects.Db4o.Db4oFactory.OpenFile(string)
+ ///
+ [System.Serializable]
+ public class DatabaseFileLockedException : Db4oFatalException
+ {
+ /// Constructor with a database description message
+ /// message, which can help to identify the database
+ ///
+ public DatabaseFileLockedException(string databaseDescription) : base(databaseDescription
+ )
+ {
+ }
+
+ /// Constructor with a database description and cause exception
+ /// database description
+ /// previous exception caused DatabaseFileLockedException
+ public DatabaseFileLockedException(string databaseDescription, Exception cause) :
+ base(databaseDescription, cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the database file reaches the
+ /// maximum allowed size.
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the database file reaches the
+ /// maximum allowed size. Upon throwing the exception the database is
+ /// switched to the read-only mode.
+ /// The maximum database size is configurable
+ /// and can reach up to 254GB.
+ ///
+ /// Db4objects.Db4o.Config.IConfiguration.BlockSize(int)
+ ///
+ [System.Serializable]
+ public class DatabaseMaximumSizeReachedException : Db4oRecoverableException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,22 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when a write operation is attempted
+ /// on a database in a read-only mode.
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when a write operation is attempted
+ /// on a database in a read-only mode.
+ ///
+ ///
+ [System.Serializable]
+ public class DatabaseReadOnlyException : Db4oRecoverableException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,255 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Query;
+using Db4objects.Db4o.Types;
+using Sharpen;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// Class to identify a database by it's signature.
+ ///
+ /// Class to identify a database by it's signature.
+ ///
db4o UUID handling uses a reference to the Db4oDatabase object, that
+ /// represents the database an object was created on.
+ ///
+ ///
+ ///
+ public class Db4oDatabase : IDb4oType, IInternal4
+ {
+ public static readonly Db4objects.Db4o.Ext.Db4oDatabase StaticIdentity = Debug4.staticIdentity
+ ? new Db4objects.Db4o.Ext.Db4oDatabase(new byte[] { (byte)'d', (byte)'e', (byte
+ )'b', (byte)'u', (byte)'g' }, 1) : null;
+
+ public const int StaticId = -1;
+
+ /// Field is public for implementation reasons, DO NOT TOUCH!
+ public byte[] i_signature;
+
+ ///
+ /// Field is public for implementation reasons, DO NOT TOUCH!
+ /// This field is badly named, it really is the creation time.
+ ///
+ ///
+ /// Field is public for implementation reasons, DO NOT TOUCH!
+ /// This field is badly named, it really is the creation time.
+ ///
+ public long i_uuid;
+
+ private static readonly string CreationtimeField = "i_uuid";
+
+ /// cached ObjectContainer for getting the own ID.
+ /// cached ObjectContainer for getting the own ID.
+ [System.NonSerialized]
+ private ObjectContainerBase i_stream;
+
+ /// cached ID, only valid in combination with i_objectContainer
+ [System.NonSerialized]
+ private int i_id;
+
+ /// constructor for persistence
+ public Db4oDatabase()
+ {
+ }
+
+ /// constructor for comparison and to store new ones
+ public Db4oDatabase(byte[] signature, long creationTime)
+ {
+ // TODO: change to _creationTime with PersistentFormatUpdater
+ // FIXME: make sure signature is null
+ i_signature = signature;
+ i_uuid = creationTime;
+ }
+
+ /// generates a new Db4oDatabase object with a unique signature.
+ /// generates a new Db4oDatabase object with a unique signature.
+ public static Db4objects.Db4o.Ext.Db4oDatabase Generate()
+ {
+ StatefulBuffer writer = new StatefulBuffer(null, 300);
+ new LatinStringIO().Write(writer, SignatureGenerator.GenerateSignature());
+ return new Db4objects.Db4o.Ext.Db4oDatabase(writer.GetWrittenBytes(), Runtime.CurrentTimeMillis
+ ());
+ }
+
+ /// comparison by signature.
+ /// comparison by signature.
+ public override bool Equals(object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj == null || this.GetType() != obj.GetType())
+ {
+ return false;
+ }
+ Db4objects.Db4o.Ext.Db4oDatabase other = (Db4objects.Db4o.Ext.Db4oDatabase)obj;
+ if (null == other.i_signature || null == this.i_signature)
+ {
+ return false;
+ }
+ return Arrays4.Equals(other.i_signature, this.i_signature);
+ }
+
+ public override int GetHashCode()
+ {
+ return i_signature.GetHashCode();
+ }
+
+ /// gets the db4o ID, and may cache it for performance reasons.
+ /// gets the db4o ID, and may cache it for performance reasons.
+ /// the db4o ID for the ObjectContainer
+ public virtual int GetID(Transaction trans)
+ {
+ ObjectContainerBase stream = trans.Container();
+ if (stream != i_stream)
+ {
+ i_stream = stream;
+ i_id = Bind(trans);
+ }
+ return i_id;
+ }
+
+ public virtual long GetCreationTime()
+ {
+ return i_uuid;
+ }
+
+ /// returns the unique signature
+ public virtual byte[] GetSignature()
+ {
+ return i_signature;
+ }
+
+ public override string ToString()
+ {
+ return "db " + i_signature;
+ }
+
+ public virtual bool IsOlderThan(Db4objects.Db4o.Ext.Db4oDatabase peer)
+ {
+ if (peer == this)
+ {
+ throw new ArgumentException();
+ }
+ if (i_uuid != peer.i_uuid)
+ {
+ return i_uuid < peer.i_uuid;
+ }
+ // the above logic has failed, both are the same
+ // age but we still want to distinguish in some
+ // way, to have an order in the ReplicationRecord
+ // The following is arbitrary, it only needs to
+ // be repeatable.
+ // Let's distinguish by signature length
+ if (i_signature.Length != peer.i_signature.Length)
+ {
+ return i_signature.Length < peer.i_signature.Length;
+ }
+ for (int i = 0; i < i_signature.Length; i++)
+ {
+ if (i_signature[i] != peer.i_signature[i])
+ {
+ return i_signature[i] < peer.i_signature[i];
+ }
+ }
+ // This should never happen.
+ // FIXME: Add a message and move to Messages.
+ //
+ throw new Exception();
+ }
+
+ /// make sure this Db4oDatabase is stored.
+ /// make sure this Db4oDatabase is stored. Return the ID.
+ public virtual int Bind(Transaction trans)
+ {
+ ObjectContainerBase stream = trans.Container();
+ Db4objects.Db4o.Ext.Db4oDatabase stored = (Db4objects.Db4o.Ext.Db4oDatabase)stream
+ .Db4oTypeStored(trans, this);
+ if (stored == null)
+ {
+ return StoreAndGetId(trans);
+ }
+ if (stored == this)
+ {
+ return stream.GetID(trans, this);
+ }
+ if (i_uuid == 0)
+ {
+ i_uuid = stored.i_uuid;
+ }
+ stream.ShowInternalClasses(true);
+ try
+ {
+ int id = stream.GetID(trans, stored);
+ stream.Bind(trans, this, id);
+ return id;
+ }
+ finally
+ {
+ stream.ShowInternalClasses(false);
+ }
+ }
+
+ private int StoreAndGetId(Transaction trans)
+ {
+ ObjectContainerBase stream = trans.Container();
+ stream.ShowInternalClasses(true);
+ try
+ {
+ stream.Store2(trans, this, stream.UpdateDepthProvider().ForDepth(2), false);
+ return stream.GetID(trans, this);
+ }
+ finally
+ {
+ stream.ShowInternalClasses(false);
+ }
+ }
+
+ /// find a Db4oDatabase with the same signature as this one
+ public virtual Db4objects.Db4o.Ext.Db4oDatabase Query(Transaction trans)
+ {
+ // showInternalClasses(true); has to be set for this method to be successful
+ if (i_uuid > 0)
+ {
+ // try fast query over uuid (creation time) first
+ Db4objects.Db4o.Ext.Db4oDatabase res = Query(trans, true);
+ if (res != null)
+ {
+ return res;
+ }
+ }
+ // if not found, try to find with signature
+ return Query(trans, false);
+ }
+
+ private Db4objects.Db4o.Ext.Db4oDatabase Query(Transaction trans, bool constrainByUUID
+ )
+ {
+ ObjectContainerBase stream = trans.Container();
+ IQuery q = stream.Query(trans);
+ q.Constrain(GetType());
+ if (constrainByUUID)
+ {
+ q.Descend(CreationtimeField).Constrain(i_uuid);
+ }
+ IObjectSet objectSet = q.Execute();
+ while (objectSet.HasNext())
+ {
+ Db4objects.Db4o.Ext.Db4oDatabase storedDatabase = (Db4objects.Db4o.Ext.Db4oDatabase
+ )objectSet.Next();
+ stream.Activate(null, storedDatabase, new FixedActivationDepth(4));
+ if (storedDatabase.Equals(this))
+ {
+ return storedDatabase;
+ }
+ }
+ return null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,59 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o exception wrapper: Exceptions occurring during internal processing
+ /// will be proliferated to the client calling code encapsulated in an exception
+ /// of this type.
+ ///
+ ///
+ /// db4o exception wrapper: Exceptions occurring during internal processing
+ /// will be proliferated to the client calling code encapsulated in an exception
+ /// of this type. The original exception, if any, is available through
+ /// Db4oException#getCause().
+ ///
+ [System.Serializable]
+ public class Db4oException : Exception
+ {
+ /// Simple constructor
+ public Db4oException() : this(null, null)
+ {
+ }
+
+ /// Constructor with an exception message specified
+ /// exception message
+ public Db4oException(string msg) : this(msg, null)
+ {
+ }
+
+ /// Constructor with an exception cause specified
+ /// exception cause
+ public Db4oException(Exception cause) : this(null, cause)
+ {
+ }
+
+ ///
+ /// Constructor with an exception message selected
+ /// from the internal message collection.
+ ///
+ ///
+ /// Constructor with an exception message selected
+ /// from the internal message collection.
+ ///
+ /// internal db4o message number
+ public Db4oException(int messageConstant) : this(Db4objects.Db4o.Internal.Messages
+ .Get(messageConstant))
+ {
+ }
+
+ /// Constructor with an exception message and cause specified
+ /// exception message
+ /// exception cause
+ public Db4oException(string msg, Exception cause) : base(msg, cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,31 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ [System.Serializable]
+ public class Db4oFatalException : Db4oException
+ {
+ public Db4oFatalException() : base()
+ {
+ }
+
+ public Db4oFatalException(int messageConstant) : base(messageConstant)
+ {
+ }
+
+ public Db4oFatalException(string msg, Exception cause) : base(msg, cause)
+ {
+ }
+
+ public Db4oFatalException(string msg) : base(msg)
+ {
+ }
+
+ public Db4oFatalException(Exception cause) : base(cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ [System.Serializable]
+ public class Db4oFileHeaderCorruptionException : Db4oFatalException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// The requested operation is not valid in the current state but the database
+ /// continues to operate.
+ ///
+ ///
+ /// The requested operation is not valid in the current state but the database
+ /// continues to operate.
+ ///
+ [System.Serializable]
+ public class Db4oIllegalStateException : Db4oRecoverableException
+ {
+ public Db4oIllegalStateException(string message) : base(message)
+ {
+ }
+
+ public Db4oIllegalStateException(Exception cause) : base(cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,37 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when a system IO exception
+ /// is encounted by db4o process.
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when a system IO exception
+ /// is encounted by db4o process.
+ ///
+ [System.Serializable]
+ public class Db4oIOException : Db4oFatalException
+ {
+ /// Constructor.
+ /// Constructor.
+ public Db4oIOException() : base()
+ {
+ }
+
+ public Db4oIOException(string message) : base(message)
+ {
+ }
+
+ /// Constructor allowing to specify the causing exception
+ /// exception cause
+ public Db4oIOException(Exception cause) : base(cause.Message, cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,31 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ [System.Serializable]
+ public class Db4oRecoverableException : Db4oException
+ {
+ public Db4oRecoverableException() : base()
+ {
+ }
+
+ public Db4oRecoverableException(int messageConstant) : base(messageConstant)
+ {
+ }
+
+ public Db4oRecoverableException(string msg, Exception cause) : base(msg, cause)
+ {
+ }
+
+ public Db4oRecoverableException(string msg) : base(msg)
+ {
+ }
+
+ public Db4oRecoverableException(Exception cause) : base(cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,16 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// Unexpected fatal error is encountered.
+ /// Unexpected fatal error is encountered.
+ [System.Serializable]
+ public class Db4oUnexpectedException : Exception
+ {
+ public Db4oUnexpectedException(Exception cause) : base(cause.Message, cause)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,112 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Text;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// a unique universal identify for an object.
+ ///
+ /// a unique universal identify for an object.
The db4o UUID consists of
+ /// two parts:
- an indexed long for fast access,
- the signature of the
+ /// IObjectContainer
+ /// the object was created with.
+ ///
Db4oUUIDs are valid representations of objects over multiple
+ /// ObjectContainers
+ ///
+ public class Db4oUUID
+ {
+ private readonly long longPart;
+
+ private readonly byte[] signaturePart;
+
+ /// constructs a Db4oUUID from a long part and a signature part
+ /// the long part
+ /// the signature part
+ public Db4oUUID(long longPart_, byte[] signaturePart_)
+ {
+ longPart = longPart_;
+ signaturePart = signaturePart_;
+ }
+
+ /// returns the long part of this UUID.
+ ///
+ /// returns the long part of this UUID.
To uniquely identify an object
+ /// universally, db4o uses an indexed long and a reference to the
+ /// Db4oDatabase object it was created on.
+ ///
+ /// the long part of this UUID.
+ public virtual long GetLongPart()
+ {
+ return longPart;
+ }
+
+ /// returns the signature part of this UUID.
+ ///
+ /// returns the signature part of this UUID.
To uniquely
+ /// identify an object universally, db4o uses an indexed long and a reference to
+ /// the Db4oDatabase singleton object of the
+ /// IObjectContainer
+ /// it was created on. This method
+ /// returns the signature of the Db4oDatabase object of the ObjectContainer: the
+ /// signature of the origin ObjectContainer.
+ ///
+ /// the signature of the Db4oDatabase for this UUID.
+ public virtual byte[] GetSignaturePart()
+ {
+ return signaturePart;
+ }
+
+ public override bool Equals(object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || GetType() != o.GetType())
+ {
+ return false;
+ }
+ Db4objects.Db4o.Ext.Db4oUUID other = (Db4objects.Db4o.Ext.Db4oUUID)o;
+ if (longPart != other.longPart)
+ {
+ return false;
+ }
+ if (signaturePart == null)
+ {
+ return other.signaturePart == null;
+ }
+ if (signaturePart.Length != other.signaturePart.Length)
+ {
+ return false;
+ }
+ for (int i = 0; i < signaturePart.Length; i++)
+ {
+ if (signaturePart[i] != other.signaturePart[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return (int)(longPart ^ ((longPart) >> (32 & 0x1f)));
+ }
+
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(GetType().FullName);
+ sb.Append(" sig: ");
+ for (int i = 0; i < signaturePart.Length; i++)
+ {
+ char c = (char)signaturePart[i];
+ sb.Append(c);
+ }
+ sb.Append(" long: ");
+ sb.Append(longPart);
+ return sb.ToString();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// A previous IO exception has switched the database file
+ /// to read-only mode for controlled shutdown.
+ ///
+ ///
+ /// A previous IO exception has switched the database file
+ /// to read-only mode for controlled shutdown.
+ ///
+ [System.Serializable]
+ public class EmergencyShutdownReadOnlyException : Db4oIOException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,13 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Ext
+{
+ /// generic callback interface.
+ /// generic callback interface.
+ public interface IDb4oCallback
+ {
+ /// the callback method
+ /// the object passed to the callback method
+ void Callback(object obj);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// extended client functionality for the
+ /// IExtObjectContainer
+ /// interface.
+ ///
Both
+ /// Db4o.openClient()
+ ///
+ /// methods always
+ /// return an ExtClient
object so a cast is possible.
+ /// The ObjectContainer functionality is split into multiple interfaces to allow newcomers to
+ /// focus on the essential methods.
+ ///
+ public interface IExtClient : IExtObjectContainer
+ {
+ /// checks if the client is currently connected to a server.
+ /// checks if the client is currently connected to a server.
+ /// true if the client is alive.
+ bool IsAlive();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,572 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.IO;
+using Db4objects.Db4o.Reflect;
+using Db4objects.Db4o.Reflect.Generic;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// extended functionality for the
+ /// IObjectContainer
+ /// interface.
+ ///
Every db4o
+ /// IObjectContainer
+ /// always is an ExtObjectContainer
so a cast is possible.
+ /// ObjectContainer.ext()
+ /// is a convenient method to perform the cast.
+ /// The ObjectContainer functionality is split to two interfaces to allow newcomers to
+ /// focus on the essential methods.
+ ///
+ public partial interface IExtObjectContainer : IObjectContainer
+ {
+ /// activates an object with the current activation strategy.
+ ///
+ /// activates an object with the current activation strategy.
+ /// In regular activation mode the object will be activated to the
+ /// global activation depth, ( see
+ /// Db4objects.Db4o.Config.IConfiguration.ActivationDepth()
+ ///
+ /// )
+ /// and all configured settings for
+ /// Db4objects.Db4o.Config.IObjectClass.MaximumActivationDepth(int)
+ ///
+ ///
+ /// and
+ /// Db4objects.Db4o.Config.IObjectClass.MaximumActivationDepth(int)
+ ///
+ /// will be respected.
+ /// In Transparent Activation Mode ( see
+ /// Db4objects.Db4o.TA.TransparentActivationSupport
+ ///
+ /// )
+ /// the parameter object will only be activated, if it does not implement
+ /// Db4objects.Db4o.TA.IActivatable
+ /// . All referenced members that do not implement
+ /// Db4objects.Db4o.TA.IActivatable
+ /// will also be activated. Any
+ /// Db4objects.Db4o.TA.IActivatable
+ /// objects
+ /// along the referenced graph will break cascading activation.
+ ///
+ ///
+ ///
+ void Activate(object obj);
+
+ /// deactivates an object.
+ ///
+ /// deactivates an object.
+ /// Only the passed object will be deactivated, i.e, no object referenced by this
+ /// object will be deactivated.
+ ///
+ /// the object to be deactivated.
+ void Deactivate(object obj);
+
+ /// backs up a database file of an open ObjectContainer.
+ ///
+ /// backs up a database file of an open ObjectContainer.
+ ///
While the backup is running, the ObjectContainer can continue to be
+ /// used. Changes that are made while the backup is in progress, will be applied to
+ /// the open ObjectContainer and to the backup.
+ /// While the backup is running, the ObjectContainer should not be closed.
+ /// If a file already exists at the specified path, it will be overwritten.
+ /// The
+ /// Db4objects.Db4o.IO.IStorage
+ /// used for backup is the one configured for this container.
+ ///
+ /// a fully qualified path
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ /// is thrown when the operation is not supported in current
+ /// configuration/environment
+ ///
+ /// I/O operation failed or was unexpectedly interrupted.
+ ///
+ ///
+ ///
+ void Backup(string path);
+
+ /// backs up a database file of an open ObjectContainer.
+ ///
+ /// backs up a database file of an open ObjectContainer.
+ ///
While the backup is running, the ObjectContainer can continue to be
+ /// used. Changes that are made while the backup is in progress, will be applied to
+ /// the open ObjectContainer and to the backup.
+ /// While the backup is running, the ObjectContainer should not be closed.
+ /// If a file already exists at the specified path, it will be overwritten.
+ /// This method is intended for cross-storage backups, i.e. backup from an in-memory
+ /// database to a file.
+ ///
+ ///
+ /// the
+ /// Db4objects.Db4o.IO.IStorage
+ /// to be used for backup
+ ///
+ /// a fully qualified path
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ /// is thrown when the operation is not supported in current
+ /// configuration/environment
+ ///
+ /// I/O operation failed or was unexpectedly interrupted.
+ ///
+ ///
+ ///
+ void Backup(IStorage targetStorage, string path);
+
+ /// binds an object to an internal object ID.
+ ///
+ /// binds an object to an internal object ID.
+ ///
This method uses the ID parameter to load the
+ /// corresponding stored object into memory and replaces this memory
+ /// reference with the object parameter. The method may be used to replace
+ /// objects or to reassociate an object with it's stored instance
+ /// after closing and opening a database file. A subsequent call to
+ /// set(Object)
+ /// is
+ /// necessary to update the stored object.
+ /// Requirements:
- The ID needs to be a valid internal object ID,
+ /// previously retrieved with
+ /// getID(Object)
+ /// .
+ /// - The object parameter needs to be of the same class as the stored object.
+ ///
+ /// GetID(object)
+ /// the object that is to be bound
+ /// the internal id the object is to be bound to
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ /// when the provided id is outside the scope of the
+ /// database IDs.
+ ///
+ ///
+ ///
+ void Bind(object obj, long id);
+
+ /// returns the Configuration context for this ObjectContainer.
+ ///
+ /// returns the Configuration context for this ObjectContainer.
+ ///
+ /// Upon opening an ObjectContainer with any of the factory methods in the
+ /// Db4o class
+ /// , the global
+ /// IConfiguration
+ /// context
+ /// is copied into the ObjectContainer. The
+ /// IConfiguration
+ /// can be modified individually for
+ /// each ObjectContainer without any effects on the global settings.
+ ///
+ ///
+ ///
+ /// IConfiguration
+ /// the Configuration
+ /// context for this ObjectContainer
+ ///
+ /// Db4objects.Db4o.Db4oFactory.Configure()
+ ///
+ IConfiguration Configure();
+
+ /// returns a member at the specific path without activating intermediate objects.
+ ///
+ ///
+ /// returns a member at the specific path without activating intermediate objects.
+ ///
+ /// This method allows navigating from a persistent object to it's members in a
+ /// performant way without activating or instantiating intermediate objects.
+ ///
+ /// the parent object that is to be used as the starting point.
+ /// an array of field names to navigate by
+ /// the object at the specified path or null if no object is found
+ object Descend(object obj, string[] path);
+
+ /// returns the stored object for an internal ID.
+ ///
+ /// returns the stored object for an internal ID.
+ ///
This is the fastest method for direct access to objects. Internal
+ /// IDs can be obtained with
+ /// getID(Object)
+ /// .
+ /// Objects will not be activated by this method. They will be returned in the
+ /// activation state they are currently in, in the local cache.
+ /// Passing invalid id values to this method may result in all kinds of
+ /// exceptions being thrown. OutOfMemoryError and arithmetic exceptions
+ /// may occur. If an application is known to use invalid IDs, it is
+ /// recommended to call this method within a catch-all block.
+ ///
+ /// the internal ID
+ ///
+ /// the object associated with the passed ID or null
,
+ /// if no object is associated with this ID in this ObjectContainer
.
+ ///
+ /// Why activation?
+ ///
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ /// when the provided id is outside the scope of the
+ /// file length.
+ ///
+ ///
+ ///
+ object GetByID(long Id);
+
+ ///
+ /// returns a stored object for a
+ /// Db4oUUID
+ /// .
+ ///
+ /// This method is intended for replication and for long-term
+ /// external references to objects. To get a
+ /// Db4oUUID
+ /// for an
+ /// object use
+ /// GetObjectInfo(object)
+ /// and
+ /// IObjectInfo.GetUUID()
+ /// .
+ /// Objects will not be activated by this method. They will be returned in the
+ /// activation state they are currently in, in the local cache.
+ ///
+ /// the UUID
+ /// the object for the UUID
+ /// Why activation?
+ ///
+ /// I/O operation failed or was unexpectedly interrupted.
+ ///
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ ///
+ object GetByUUID(Db4oUUID uuid);
+
+ /// returns the internal unique object ID.
+ ///
+ /// returns the internal unique object ID.
+ ///
db4o assigns an internal ID to every object that is stored. IDs are
+ /// guaranteed to be unique within one ObjectContainer
.
+ /// An object carries the same ID in every db4o session. Internal IDs can
+ /// be used to look up objects with the very fast
+ /// getByID
+ /// method.
+ /// Internal IDs will change when a database is defragmented. Use
+ /// GetObjectInfo(object)
+ /// ,
+ /// IObjectInfo.GetUUID()
+ /// and
+ /// GetByUUID(Db4oUUID)
+ /// for long-term external references to
+ /// objects.
+ ///
+ /// any object
+ ///
+ /// the associated internal ID or 0
, if the passed
+ /// object is not stored in this ObjectContainer
.
+ ///
+ long GetID(object obj);
+
+ ///
+ /// returns the
+ /// IObjectInfo
+ /// for a stored object.
+ ///
This method will return null, if the passed
+ /// object is not stored to this ObjectContainer
.
+ ///
+ /// the stored object
+ ///
+ /// the
+ /// IObjectInfo
+ ///
+ ///
+ IObjectInfo GetObjectInfo(object obj);
+
+ /// returns the Db4oDatabase object for this ObjectContainer.
+ /// returns the Db4oDatabase object for this ObjectContainer.
+ /// the Db4oDatabase identity object for this ObjectContainer.
+ Db4oDatabase Identity();
+
+ /// tests if an object is activated.
+ ///
+ /// tests if an object is activated.
+ ///
isActive
returns false
if an object is not
+ /// stored within the ObjectContainer
.
+ ///
+ /// to be tested
+ /// true
if the passed object is active.
+ bool IsActive(object obj);
+
+ /// tests if an object with this ID is currently cached.
+ ///
+ /// tests if an object with this ID is currently cached.
+ ///
+ ///
+ /// the internal ID
+ bool IsCached(long Id);
+
+ /// tests if this ObjectContainer
is closed.
+ ///
+ /// tests if this ObjectContainer
is closed.
+ ///
+ ///
+ /// true
if this ObjectContainer
is closed.
+ bool IsClosed();
+
+ /// tests if an object is stored in this ObjectContainer
.
+ ///
+ /// tests if an object is stored in this ObjectContainer
.
+ ///
+ ///
+ /// to be tested
+ /// true
if the passed object is stored.
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ bool IsStored(object obj);
+
+ ///
+ /// returns all class representations that are known to this
+ /// ObjectContainer because they have been used or stored.
+ ///
+ ///
+ /// returns all class representations that are known to this
+ /// ObjectContainer because they have been used or stored.
+ ///
+ ///
+ /// all class representations that are known to this
+ /// ObjectContainer because they have been used or stored.
+ ///
+ IReflectClass[] KnownClasses();
+
+ /// returns the main synchronization lock.
+ ///
+ /// returns the main synchronization lock.
+ ///
+ /// Synchronize over this object to ensure exclusive access to
+ /// the ObjectContainer.
+ /// Handle the use of this functionality with extreme care,
+ /// since deadlocks can be produced with just two lines of code.
+ ///
+ /// Object the ObjectContainer lock object
+ object Lock();
+
+ /// opens a new ObjectContainer on top of this ObjectContainer.
+ ///
+ /// opens a new ObjectContainer on top of this ObjectContainer.
+ /// The ObjectContainer will have it's own transaction and
+ /// it's own reference system.
+ ///
+ /// the new ObjectContainer session.
+ /// 8.0
+ IObjectContainer OpenSession();
+
+ ///
+ /// returns a transient copy of a persistent object with all members set
+ /// to the values that are currently stored to the database.
+ ///
+ ///
+ /// returns a transient copy of a persistent object with all members set
+ /// to the values that are currently stored to the database.
+ ///
+ /// The returned objects have no connection to the database.
+ /// With the committed
parameter it is possible to specify,
+ /// whether the desired object should contain the committed values or the
+ /// values that were set by the running transaction with
+ /// Db4objects.Db4o.IObjectContainer.Store(object)
+ ///
+ /// .
+ ///
A possible use case for this feature:
+ /// An application might want to check all changes applied to an object
+ /// by the running transaction.
+ ///
+ /// the object that is to be cloned
+ /// the member depth to which the object is to be instantiated
+ /// whether committed or set values are to be returned
+ /// the object
+ object PeekPersisted(object @object, int depth, bool committed);
+
+ /// unloads all clean indices from memory and frees unused objects.
+ ///
+ /// unloads all clean indices from memory and frees unused objects.
+ ///
Call commit() and purge() consecutively to achieve the best
+ /// result possible. This method can have a negative impact
+ /// on performance since indices will have to be reread before further
+ /// inserts, updates or queries can take place.
+ ///
+ void Purge();
+
+ /// unloads a specific object from the db4o reference mechanism.
+ ///
+ /// unloads a specific object from the db4o reference mechanism.
+ ///
db4o keeps references to all newly stored and
+ /// instantiated objects in memory, to be able to manage object identities.
+ ///
With calls to this method it is possible to remove an object from the
+ /// reference mechanism, to allow it to be garbage collected. You are not required to
+ /// call this method in the .NET and JDK 1.2 versions, since objects are
+ /// referred to by weak references and garbage collection happens
+ /// automatically.
An object removed with purge(Object)
is not
+ /// "known" to the ObjectContainer
afterwards, so this method may also be
+ /// used to create multiple copies of objects.
purge(Object)
has
+ /// no influence on the persistence state of objects. "Purged" objects can be
+ /// reretrieved with queries.
+ ///
+ /// the object to be removed from the reference mechanism.
+ void Purge(object obj);
+
+ /// Return the reflector currently being used by db4objects.
+ /// Return the reflector currently being used by db4objects.
+ /// the current Reflector.
+ GenericReflector Reflector();
+
+ /// refreshs all members on a stored object to the specified depth.
+ ///
+ /// refreshs all members on a stored object to the specified depth.
+ ///
If a member object is not activated, it will be activated by this method.
+ ///
The isolation used is READ COMMITTED. This method will read all objects
+ /// and values that have been committed by other transactions.
+ ///
+ /// the object to be refreshed.
+ ///
+ /// the member
+ /// depth
+ /// to which refresh is to cascade.
+ ///
+ void Refresh(object obj, int depth);
+
+ /// releases a semaphore, if the calling transaction is the owner.
+ /// releases a semaphore, if the calling transaction is the owner.
+ /// the name of the semaphore to be released.
+ void ReleaseSemaphore(string name);
+
+ /// deep update interface to store or update objects.
+ ///
+ /// deep update interface to store or update objects.
+ ///
In addition to the normal storage interface,
+ /// ObjectContainer#set(Object)
+ /// ,
+ /// this method allows a manual specification of the depth, the passed object is to be updated.
+ ///
+ /// the object to be stored or updated.
+ /// the depth to which the object is to be updated
+ /// com.db4o.ObjectContainer#set
+ void Store(object obj, int depth);
+
+ /// attempts to set a semaphore.
+ ///
+ /// attempts to set a semaphore.
+ ///
+ /// Semaphores are transient multi-purpose named flags for
+ /// ObjectContainers
+ /// .
+ ///
+ /// A transaction that successfully sets a semaphore becomes
+ /// the owner of the semaphore. Semaphores can only be owned
+ /// by a single transaction at one point in time.
+ /// This method returns true, if the transaction already owned
+ /// the semaphore before the method call or if it successfully
+ /// acquires ownership of the semaphore.
+ /// The waitForAvailability parameter allows to specify a time
+ /// in milliseconds to wait for other transactions to release
+ /// the semaphore, in case the semaphore is already owned by
+ /// another transaction.
+ /// Semaphores are released by the first occurrence of one of the
+ /// following:
+ /// - the transaction releases the semaphore with
+ /// ReleaseSemaphore(string)
+ ///
- the transaction is closed with
+ /// Db4objects.Db4o.IObjectContainer.Close()
+ ///
+ ///
- C/S only: the corresponding
+ /// Db4objects.Db4o.IObjectServer
+ /// is
+ /// closed.
- C/S only: the client
+ /// Db4objects.Db4o.IObjectContainer
+ /// looses the connection and is timed
+ /// out.
Semaphores are set immediately. They are independant of calling
+ /// Db4objects.Db4o.IObjectContainer.Commit()
+ ///
+ /// or
+ /// Db4objects.Db4o.IObjectContainer.Rollback()
+ ///
+ /// .
Possible use cases
+ /// for semaphores:
- prevent other clients from inserting a singleton at the same time.
+ /// A suggested name for the semaphore: "SINGLETON_" + Object#getClass().getName().
- lock
+ /// objects. A suggested name: "LOCK_" +
+ /// getID(Object)
+ ///
-
+ /// generate a unique client ID. A suggested name: "CLIENT_" +
+ /// System.currentTimeMillis().
+ ///
+ /// the name of the semaphore to be set
+ ///
+ /// the time in milliseconds to wait for other
+ /// transactions to release the semaphore. The parameter may be zero, if
+ /// the method is to return immediately.
+ ///
+ ///
+ /// boolean flag
+ ///
true
, if the semaphore could be set or if the
+ /// calling transaction already owned the semaphore.
+ ///
false
, if the semaphore is owned by another
+ /// transaction.
+ ///
+ bool SetSemaphore(string name, int waitForAvailability);
+
+ ///
+ /// returns a
+ /// IStoredClass
+ /// meta information object.
+ ///
+ /// There are three options how to use this method.
+ /// Any of the following parameters are possible:
+ /// - a fully qualified class name.
+ /// - a Class object.
+ /// - any object to be used as a template.
+ ///
+ /// class name, Class object, or example object.
+ ///
+ /// an instance of an
+ /// IStoredClass
+ /// meta information object.
+ ///
+ IStoredClass StoredClass(object clazz);
+
+ ///
+ /// returns an array of all
+ /// IStoredClass
+ /// meta information objects.
+ ///
+ IStoredClass[] StoredClasses();
+
+ ///
+ /// returns the
+ /// ISystemInfo
+ /// for this ObjectContainer.
+ ///
The
+ /// ISystemInfo
+ /// supplies methods that provide
+ /// information about system state and system settings of this
+ /// ObjectContainer.
+ ///
+ ///
+ /// the
+ /// ISystemInfo
+ /// for this ObjectContainer.
+ ///
+ ISystemInfo SystemInfo();
+
+ /// returns the current transaction serial number.
+ ///
+ /// returns the current transaction serial number.
+ ///
This serial number can be used to query for modified objects
+ /// and for replication purposes.
+ ///
+ /// the current transaction serial number.
+ long Version();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,80 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Config;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// extended functionality for the ObjectServer interface.
+ ///
+ /// extended functionality for the ObjectServer interface.
+ ///
Every ObjectServer also always is an ExtObjectServer
+ /// so a cast is possible.
+ /// Db4objects.Db4o.IObjectServer.Ext()
+ ///
+ /// is a convenient method to perform the cast.
+ /// The functionality is split to two interfaces to allow newcomers to
+ /// focus on the essential methods.
+ ///
+ public interface IExtObjectServer : IObjectServer
+ {
+ /// backs up the database file used by the ObjectServer.
+ ///
+ /// backs up the database file used by the ObjectServer.
+ ///
While the backup is running, the ObjectServer can continue to be
+ /// used. Changes that are made while the backup is in progress, will be applied to
+ /// the open ObjectServer and to the backup.
+ /// While the backup is running, the ObjectContainer should not be closed.
+ /// If a file already exists at the specified path, it will be overwritten.
+ ///
+ /// a fully qualified path
+ ///
+ void Backup(string path);
+
+ /// returns the number of connected clients.
+ /// returns the number of connected clients.
+ int ClientCount();
+
+ ///
+ /// returns the
+ /// Db4objects.Db4o.Config.IConfiguration
+ ///
+ /// context for this ObjectServer.
+ ///
+ /// Upon opening an ObjectServer with any of the factory methods in the
+ /// Db4objects.Db4o.Db4oFactory
+ /// class, the global
+ /// Db4objects.Db4o.Config.IConfiguration
+ ///
+ /// context
+ /// is copied into the ObjectServer. The
+ /// Db4objects.Db4o.Config.IConfiguration
+ ///
+ /// can be modified individually for
+ /// each ObjectServer without any effects on the global settings.
+ ///
+ /// the Configuration context for this ObjectServer
+ /// Db4objects.Db4o.Db4oFactory.Configure()
+ ///
+ IConfiguration Configure();
+
+ /// returns the ObjectContainer used by the server.
+ ///
+ /// returns the ObjectContainer used by the server.
+ ///
+ ///
+ /// the ObjectContainer used by the server
+ IObjectContainer ObjectContainer();
+
+ /// removes client access permissions for the specified user.
+ ///
+ /// removes client access permissions for the specified user.
+ ///
+ ///
+ /// the name of the user
+ void RevokeAccess(string userName);
+
+ /// The local port this server uses, 0 if disconnected or in embedded mode
+ int Port();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,43 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// extended functionality for the
+ /// IObjectSet
+ /// interface.
+ ///
Every db4o
+ /// IObjectSet
+ /// always is an ExtObjectSet so a cast is possible.
+ /// Db4objects.Db4o.IObjectSet.Ext()
+ /// is a convenient method to perform the cast.
+ /// The ObjectSet functionality is split to two interfaces to allow newcomers to
+ /// focus on the essential methods.
+ ///
+ public interface IExtObjectSet : IObjectSet
+ {
+ /// returns an array of internal IDs that correspond to the contained objects.
+ ///
+ ///
+ /// returns an array of internal IDs that correspond to the contained objects.
+ ///
+ ///
+ /// IExtObjectContainer.GetID(object)
+ ///
+ /// IExtObjectContainer.GetByID(long)
+ ///
+ long[] GetIDs();
+
+ /// returns the item at position [index] in this ObjectSet.
+ ///
+ /// returns the item at position [index] in this ObjectSet.
+ ///
+ /// The object will be activated.
+ ///
+ /// the index position in this ObjectSet.
+ /// the activated object.
+ object Get(int index);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the database file format
+ /// is not compatible with the applied configuration.
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the database file format
+ /// is not compatible with the applied configuration.
+ ///
+ [System.Serializable]
+ public class IncompatibleFileFormatException : Db4oFatalException
+ {
+ public IncompatibleFileFormatException() : base()
+ {
+ }
+
+ public IncompatibleFileFormatException(string message) : base(message)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,37 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the supplied object ID
+ /// is incorrect (outside the scope of the database IDs).
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when the supplied object ID
+ /// is incorrect (outside the scope of the database IDs).
+ ///
+ /// IExtObjectContainer.Bind(object, long)
+ ///
+ /// IExtObjectContainer.GetByID(long)
+ ///
+ [System.Serializable]
+ public class InvalidIDException : Db4oRecoverableException
+ {
+ /// Constructor allowing to specify the exception cause
+ /// cause exception
+ public InvalidIDException(Exception cause) : base(cause)
+ {
+ }
+
+ /// Constructor allowing to specify the offending id
+ /// the offending id
+ public InvalidIDException(int id) : base("id: " + id)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when a client tries to connect
+ /// to a server with a wrong password or null password.
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when a client tries to connect
+ /// to a server with a wrong password or null password.
+ ///
+ [System.Serializable]
+ public class InvalidPasswordException : Db4oRecoverableException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,37 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when db4o reads slot
+ /// information which is not valid (length or address).
+ ///
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when db4o reads slot
+ /// information which is not valid (length or address).
+ ///
+ [System.Serializable]
+ public class InvalidSlotException : Db4oRecoverableException
+ {
+ /// Constructor allowing to specify a detailed message.
+ /// Constructor allowing to specify a detailed message.
+ /// message
+ public InvalidSlotException(string msg) : base(msg)
+ {
+ }
+
+ /// Constructor allowing to specify the address, length and id.
+ /// Constructor allowing to specify the address, length and id.
+ /// offending address
+ /// offending length
+ /// id where the address and length were read.
+ public InvalidSlotException(int address, int length, int id) : base("address: " +
+ address + ", length : " + length + ", id : " + id)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,101 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// callback methods.
+ ///
+ /// callback methods.
+ ///
+ /// This interface only serves as a list of all available callback methods.
+ /// Every method is called individually, independantly of implementing this interface.
+ /// Using callbacks
+ /// Simply implement one or more of the listed methods in your application classes to
+ /// do tasks before activation, deactivation, delete, new or update, to cancel the
+ /// action about to be performed and to respond to the performed task.
+ ///
Callback methods are typically used for:
+ ///
- cascaded delete
+ ///
- cascaded update
+ ///
- cascaded activation
+ ///
- restoring transient members on instantiation
+ ///
Callback methods follow regular calling conventions. Methods in superclasses
+ /// need to be called explicitely.
+ ///
All method calls are implemented to occur only once, upon one event.
+ ///
+ public interface IObjectCallbacks
+ {
+ /// called before an Object is activated.
+ /// called before an Object is activated.
+ /// the ObjectContainer
the object is stored in.
+ ///
+ /// false to prevent activation.
+ bool ObjectCanActivate(IObjectContainer container);
+
+ /// called before an Object is deactivated.
+ /// called before an Object is deactivated.
+ /// the ObjectContainer
the object is stored in.
+ ///
+ /// false to prevent deactivation.
+ bool ObjectCanDeactivate(IObjectContainer container);
+
+ /// called before an Object is deleted.
+ ///
+ /// called before an Object is deleted.
+ ///
In a client/server setup this callback method will be executed on
+ /// the server.
+ ///
+ /// the ObjectContainer
the object is stored in.
+ ///
+ /// false to prevent the object from being deleted.
+ bool ObjectCanDelete(IObjectContainer container);
+
+ /// called before an Object is stored the first time.
+ /// called before an Object is stored the first time.
+ /// the ObjectContainer
is about to be stored to.
+ ///
+ /// false to prevent the object from being stored.
+ bool ObjectCanNew(IObjectContainer container);
+
+ /// called before a persisted Object is updated.
+ /// called before a persisted Object is updated.
+ /// the ObjectContainer
the object is stored in.
+ ///
+ /// false to prevent the object from being updated.
+ bool ObjectCanUpdate(IObjectContainer container);
+
+ /// called upon activation of an object.
+ /// called upon activation of an object.
+ /// the ObjectContainer
the object is stored in.
+ ///
+ void ObjectOnActivate(IObjectContainer container);
+
+ /// called upon deactivation of an object.
+ /// called upon deactivation of an object.
+ /// the ObjectContainer
the object is stored in.
+ ///
+ void ObjectOnDeactivate(IObjectContainer container);
+
+ /// called after an object was deleted.
+ ///
+ /// called after an object was deleted.
+ ///
In a client/server setup this callback method will be executed on
+ /// the server.
+ ///
+ /// the ObjectContainer
the object was stored in.
+ ///
+ void ObjectOnDelete(IObjectContainer container);
+
+ /// called after a new object was stored.
+ /// called after a new object was stored.
+ /// the ObjectContainer
the object is stored to.
+ ///
+ void ObjectOnNew(IObjectContainer container);
+
+ /// called after an object was updated.
+ /// called after an object was updated.
+ /// the ObjectContainer
the object is stored in.
+ ///
+ void ObjectOnUpdate(IObjectContainer container);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,17 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// Interface to an iterable collection
+ /// IObjectInfo
+ /// objects.
+ /// ObjectInfoCollection is used reference a number of stored objects.
+ ///
+ /// IObjectInfo
+ public interface IObjectInfoCollection : IEnumerable
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,87 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// interface to the internal reference that an ObjectContainer
+ /// holds for a stored object.
+ ///
+ ///
+ /// interface to the internal reference that an ObjectContainer
+ /// holds for a stored object.
+ ///
+ public interface IObjectInfo
+ {
+ /// returns the internal db4o ID.
+ /// returns the internal db4o ID.
+ long GetInternalID();
+
+ /// returns the object that is referenced.
+ ///
+ /// returns the object that is referenced.
+ ///
This method may return null, if the object has
+ /// been garbage collected.
+ ///
+ ///
+ /// the referenced object or null, if the object has
+ /// been garbage collected.
+ ///
+ object GetObject();
+
+ /// returns a UUID representation of the referenced object.
+ ///
+ /// returns a UUID representation of the referenced object.
+ /// UUID generation has to be turned on, in order to be able
+ /// to use this feature:
+ /// Db4objects.Db4o.Config.IConfiguration.GenerateUUIDs(Db4objects.Db4o.Config.ConfigScope)
+ ///
+ ///
+ /// the UUID of the referenced object.
+ Db4oUUID GetUUID();
+
+ ///
+ /// returns the transaction serial number ("version") the referenced object
+ /// was stored with last.
+ ///
+ ///
+ /// returns the transaction serial number ("version") the referenced object
+ /// was stored with last. Version number generation has to be turned on, in
+ /// order to be able to use this feature:
+ /// Db4objects.Db4o.Config.IConfiguration.GenerateVersionNumbers(Db4objects.Db4o.Config.ConfigScope)
+ ///
+ ///
+ /// This feature was replaced by
+ /// GetCommitTimestamp()
+ /// . The main
+ /// difference is that the old version mechamism used to assign a serial
+ /// timestamp to the object upon storing time, and the new commiTimestamp
+ /// approach, assigns it upon commit time.
+ ///
+ /// the version number.
+ [System.ObsoleteAttribute(@"As of version 8.0 please use GetCommitTimestamp() instead."
+ )]
+ long GetVersion();
+
+ ///
+ /// The serial timestamp the object is assigned to when it is commited.
+ ///
+ /// You need to enable this feature before using it in
+ /// Db4objects.Db4o.Config.IFileConfiguration.GenerateCommitTimestamps(bool)
+ /// .
+ ///
+ /// All the objects commited within the same transaction will receive the same commitTimestamp.
+ ///
+ /// db4o replication system (dRS) relies on this feature.
+ ///
+ /// the serial timestamp that was given to the object upon commit.
+ /// Db4objects.Db4o.Config.IFileConfiguration.GenerateCommitTimestamps(bool)
+ /// 8.0
+ long GetCommitTimestamp();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,76 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// the internal representation of a stored class.
+ /// the internal representation of a stored class.
+ public interface IStoredClass
+ {
+ /// returns the name of this stored class.
+ /// returns the name of this stored class.
+ string GetName();
+
+ /// returns an array of IDs of all stored object instances of this stored class.
+ ///
+ /// returns an array of IDs of all stored object instances of this stored class.
+ ///
+ long[] GetIDs();
+
+ /// returns the StoredClass for the parent of the class, this StoredClass represents.
+ ///
+ /// returns the StoredClass for the parent of the class, this StoredClass represents.
+ ///
+ IStoredClass GetParentStoredClass();
+
+ /// returns all stored fields of this stored class.
+ /// returns all stored fields of this stored class.
+ IStoredField[] GetStoredFields();
+
+ /// returns true if this StoredClass has a class index.
+ /// returns true if this StoredClass has a class index.
+ bool HasClassIndex();
+
+ /// renames this stored class.
+ ///
+ /// renames this stored class.
+ ///
After renaming one or multiple classes the ObjectContainer has
+ /// to be closed and reopened to allow internal caches to be refreshed.
+ ///
.NET: As the name you should provide [Classname, Assemblyname]
+ ///
+ /// the new name
+ void Rename(string name);
+
+ // TODO: add field creation
+ /// returns an existing stored field of this stored class.
+ /// returns an existing stored field of this stored class.
+ /// the name of the field
+ ///
+ /// the type of the field.
+ /// There are four possibilities how to supply the type:
+ /// - a Class object. (.NET: a Type object)
+ /// - a fully qualified classname.
+ /// - any object to be used as a template.
+ /// - null, if the first found field should be returned.
+ ///
+ ///
+ /// the
+ /// IStoredField
+ ///
+ IStoredField StoredField(string name, object type);
+
+ ///
+ /// Returns the number of instances of this class that have been persisted to the
+ /// database, as seen by the transaction (container) that produces this StoredClass
+ /// instance.
+ ///
+ ///
+ /// Returns the number of instances of this class that have been persisted to the
+ /// database, as seen by the transaction (container) that produces this StoredClass
+ /// instance.
+ ///
+ /// The number of instances
+ int InstanceCount();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,86 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Reflect;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// the internal representation of a field on a stored class.
+ /// the internal representation of a field on a stored class.
+ public interface IStoredField
+ {
+ /// creates an index on this field at runtime.
+ /// creates an index on this field at runtime.
+ void CreateIndex();
+
+ /// drops an existing index on this field at runtime.
+ /// drops an existing index on this field at runtime.
+ void DropIndex();
+
+ /// returns the field value on the passed object.
+ ///
+ /// returns the field value on the passed object.
+ ///
This method will also work, if the field is not present in the current
+ /// version of the class.
+ ///
It is recommended to use this method for refactoring purposes, if fields
+ /// are removed and the field values need to be copied to other fields.
+ ///
+ object Get(object onObject);
+
+ /// returns the name of the field.
+ /// returns the name of the field.
+ string GetName();
+
+ /// returns the Class (Java) / Type (.NET) of the field.
+ ///
+ /// returns the Class (Java) / Type (.NET) of the field.
+ ///
For array fields this method will return the type of the array.
+ /// Use
+ /// IsArray()
+ /// to detect arrays.
+ ///
+ IReflectClass GetStoredType();
+
+ /// returns true if the field is an array.
+ /// returns true if the field is an array.
+ bool IsArray();
+
+ /// modifies the name of this stored field.
+ ///
+ /// modifies the name of this stored field.
+ ///
After renaming one or multiple fields the ObjectContainer has
+ /// to be closed and reopened to allow internal caches to be refreshed.
+ ///
+ /// the new name
+ void Rename(string name);
+
+ ///
+ /// specialized highspeed API to collect all values of a field for all instances
+ /// of a class, if the field is indexed.
+ ///
+ ///
+ /// specialized highspeed API to collect all values of a field for all instances
+ /// of a class, if the field is indexed.
+ ///
The field values will be taken directly from the index without the
+ /// detour through class indexes or object instantiation.
+ ///
+ /// If this method is used to get the values of a first class object index,
+ /// deactivated objects will be passed to the visitor.
+ ///
+ /// the visitor to be called with each index value.
+ void TraverseValues(IVisitor4 visitor);
+
+ /// Returns whether this field has an index or not.
+ /// Returns whether this field has an index or not.
+ /// true if this field has an index.
+ bool HasIndex();
+ // will need for replication. Requested for 3.0
+ //
+ // /**
+ // * sets the field value on the passed object.
+ // * @param onObject
+ // * @param fieldValue
+ // */
+ // public void set(Object onObject, Object fieldValue);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,38 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Ext
+{
+ /// provides information about system state and system settings.
+ /// provides information about system state and system settings.
+ public interface ISystemInfo
+ {
+ /// returns the number of entries in the Freespace Manager.
+ ///
+ /// returns the number of entries in the Freespace Manager.
+ ///
A high value for the number of freespace entries
+ /// is an indication that the database is fragmented and
+ /// that defragment should be run.
+ ///
+ /// the number of entries in the Freespace Manager.
+ int FreespaceEntryCount();
+
+ /// returns the freespace size in the database in bytes.
+ ///
+ /// returns the freespace size in the database in bytes.
+ ///
When db4o stores modified objects, it allocates
+ /// a new slot for it. During commit the old slot is freed.
+ /// Free slots are collected in the freespace manager, so
+ /// they can be reused for other objects.
+ ///
This method returns a sum of the size of all
+ /// free slots in the database file.
+ ///
To reclaim freespace run defragment.
+ ///
+ /// the freespace size in the database in bytes.
+ long FreespaceSize();
+
+ /// Returns the total size of the database on disk.
+ /// Returns the total size of the database on disk.
+ /// total size of database on disk
+ long TotalSize();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Reflect;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// this Exception is thrown, if objects can not be stored and if
+ /// db4o is configured to throw Exceptions on storage failures.
+ ///
+ ///
+ /// this Exception is thrown, if objects can not be stored and if
+ /// db4o is configured to throw Exceptions on storage failures.
+ ///
+ /// Db4objects.Db4o.Config.IConfiguration.ExceptionsOnNotStorable(bool)
+ [System.Serializable]
+ public class ObjectNotStorableException : Db4oRecoverableException
+ {
+ public ObjectNotStorableException(IReflectClass a_class) : base(Db4objects.Db4o.Internal.Messages
+ .Get(a_class.IsPrimitive() ? 59 : 45, a_class.GetName()))
+ {
+ }
+
+ public ObjectNotStorableException(string message) : base(message)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// db4o-specific exception.
+ /// This exception is thrown when an old file format was detected
+ /// and
+ /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates(bool)
+ ///
+ /// is set to false.
+ ///
+ [System.Serializable]
+ public class OldFormatException : Db4oFatalException
+ {
+ /// Constructor with the default message.
+ /// Constructor with the default message.
+ public OldFormatException() : base(Db4objects.Db4o.Internal.Messages.OldDatabaseFormat
+ )
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Ext
+{
+ /// Static constants to describe the status of objects.
+ /// Static constants to describe the status of objects.
+ public class Status
+ {
+ public const double Unused = -1.0;
+
+ public const double Available = -2.0;
+
+ public const double Queued = -3.0;
+
+ public const double Completed = -4.0;
+
+ public const double Processing = -5.0;
+
+ public const double Error = -99.0;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+
+namespace Db4objects.Db4o.Ext
+{
+ ///
+ /// This exception is thrown while reading old database
+ /// files for which support has been dropped.
+ ///
+ ///
+ /// This exception is thrown while reading old database
+ /// files for which support has been dropped.
+ ///
+ [System.Serializable]
+ public class UnsupportedOldFormatException : Db4oFatalException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Ext
+{
+ /// intended for future virtual fields on classes.
+ ///
+ /// intended for future virtual fields on classes. Currently only
+ /// the constant for the virtual version field is found here.
+ ///
+ ///
+ public class VirtualField
+ {
+ ///
+ /// the field name of the virtual version field, to be used
+ /// for querying.
+ ///
+ ///
+ /// the field name of the virtual version field, to be used
+ /// for querying.
+ ///
+ public static readonly string Version = Const4.VirtualFieldPrefix + "version";
+
+ public static readonly string CommitTimestamp = Const4.VirtualFieldPrefix + "commitTimestamp";
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,106 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public abstract class AbstractTreeIterator : IEnumerator
+ {
+ private readonly Tree _tree;
+
+ private Stack4 _stack;
+
+ public AbstractTreeIterator(Tree tree)
+ {
+ _tree = tree;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ if (_stack == null)
+ {
+ throw new InvalidOperationException();
+ }
+ Tree tree = Peek();
+ if (tree == null)
+ {
+ return null;
+ }
+ return CurrentValue(tree);
+ }
+ }
+
+ private Tree Peek()
+ {
+ return (Tree)_stack.Peek();
+ }
+
+ public virtual void Reset()
+ {
+ _stack = null;
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (_stack == null)
+ {
+ InitStack();
+ return _stack != null;
+ }
+ Tree current = Peek();
+ if (current == null)
+ {
+ return false;
+ }
+ if (PushPreceding(((Tree)current._subsequent)))
+ {
+ return true;
+ }
+ while (true)
+ {
+ _stack.Pop();
+ Tree parent = Peek();
+ if (parent == null)
+ {
+ return false;
+ }
+ if (current == ((Tree)parent._preceding))
+ {
+ return true;
+ }
+ current = parent;
+ }
+ }
+
+ private void InitStack()
+ {
+ if (_tree == null)
+ {
+ return;
+ }
+ _stack = new Stack4();
+ PushPreceding(_tree);
+ }
+
+ private bool PushPreceding(Tree node)
+ {
+ if (node == null)
+ {
+ return false;
+ }
+ while (node != null)
+ {
+ _stack.Push(node);
+ node = ((Tree)node._preceding);
+ }
+ return true;
+ }
+
+ protected abstract object CurrentValue(Tree tree);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,181 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Algorithms4
+ {
+ private const int QsortLengthThreshold = 7;
+
+ public static void Sort(ISortable4 sortable)
+ {
+ Sort(sortable, 0, sortable.Size());
+ }
+
+ public static void Sort(ISortable4 sortable, int start, int end)
+ {
+ int length = end - start;
+ if (length < QsortLengthThreshold)
+ {
+ InsertionSort(sortable, start, end);
+ return;
+ }
+ Qsort(sortable, start, end);
+ }
+
+ public static void Qsort(ISortable4 sortable, int start, int end)
+ {
+ int length = end - start;
+ int middle = start + length / 2;
+ if (length > 7)
+ {
+ int bottom = start;
+ int top = end - 1;
+ if (length > 40)
+ {
+ length /= 8;
+ bottom = MiddleValueIndex(sortable, bottom, bottom + length, bottom + (2 * length
+ ));
+ middle = MiddleValueIndex(sortable, middle - length, middle, middle + length);
+ top = MiddleValueIndex(sortable, top - (2 * length), top - length, top);
+ }
+ middle = MiddleValueIndex(sortable, bottom, middle, top);
+ }
+ int a;
+ int b;
+ int c;
+ int d;
+ a = b = start;
+ c = d = end - 1;
+ while (true)
+ {
+ while (b <= c && sortable.Compare(b, middle) <= 0)
+ {
+ if (sortable.Compare(b, middle) == 0)
+ {
+ middle = NewPartionIndex(middle, a, b);
+ Swap(sortable, a++, b);
+ }
+ b++;
+ }
+ while (c >= b && sortable.Compare(c, middle) >= 0)
+ {
+ if (sortable.Compare(c, middle) == 0)
+ {
+ middle = NewPartionIndex(middle, c, d);
+ Swap(sortable, c, d--);
+ }
+ c--;
+ }
+ if (b > c)
+ {
+ break;
+ }
+ middle = NewPartionIndex(middle, b, c);
+ Swap(sortable, b++, c--);
+ }
+ length = Math.Min(a - start, b - a);
+ Swap(sortable, start, b - length, length);
+ length = Math.Min(d - c, end - 1 - d);
+ Swap(sortable, b, end - length, length);
+ length = b - a;
+ if (length > 0)
+ {
+ Sort(sortable, start, start + length);
+ }
+ length = d - c;
+ if (length > 0)
+ {
+ Sort(sortable, end - length, end);
+ }
+ }
+
+ public static void InsertionSort(ISortable4 sortable, int start, int end)
+ {
+ for (int i = start + 1; i < end; i++)
+ {
+ for (int j = i; j > start && sortable.Compare(j - 1, j) > 0; j--)
+ {
+ Swap(sortable, j - 1, j);
+ }
+ }
+ }
+
+ private static int NewPartionIndex(int oldPartionIndex, int leftSwapIndex, int rightSwapIndex
+ )
+ {
+ if (leftSwapIndex == oldPartionIndex)
+ {
+ return rightSwapIndex;
+ }
+ else
+ {
+ if (rightSwapIndex == oldPartionIndex)
+ {
+ return leftSwapIndex;
+ }
+ }
+ return oldPartionIndex;
+ }
+
+ private static int MiddleValueIndex(ISortable4 sortable, int a, int b, int c)
+ {
+ if (sortable.Compare(a, b) < 0)
+ {
+ if (sortable.Compare(b, c) < 0)
+ {
+ return b;
+ }
+ else
+ {
+ if (sortable.Compare(a, c) < 0)
+ {
+ return c;
+ }
+ else
+ {
+ return a;
+ }
+ }
+ }
+ else
+ {
+ if (sortable.Compare(b, c) > 0)
+ {
+ return b;
+ }
+ else
+ {
+ if (sortable.Compare(a, c) > 0)
+ {
+ return c;
+ }
+ else
+ {
+ return a;
+ }
+ }
+ }
+ }
+
+ private static void Swap(ISortable4 sortable, int left, int right)
+ {
+ if (left == right)
+ {
+ return;
+ }
+ sortable.Swap(left, right);
+ }
+
+ private static void Swap(ISortable4 sortable, int from, int to, int length)
+ {
+ while (length-- > 0)
+ {
+ Swap(sortable, from++, to++);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class ArrayIterator4 : IndexedIterator
+ {
+ private readonly object[] _elements;
+
+ public ArrayIterator4(object[] elements) : base(elements.Length)
+ {
+ _elements = elements;
+ }
+
+ protected override object Get(int index)
+ {
+ return _elements[index];
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,150 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Arrays4
+ {
+ public static int[] CopyOf(int[] src, int newLength)
+ {
+ int[] copy = new int[newLength];
+ System.Array.Copy(src, 0, copy, 0, Math.Min(src.Length, newLength));
+ return copy;
+ }
+
+ public static int IndexOfIdentity(object[] array, object element)
+ {
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (array[i] == element)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public static int IndexOfEquals(object[] array, object expected)
+ {
+ for (int i = 0; i < array.Length; ++i)
+ {
+ if (expected.Equals(array[i]))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public static int IndexOf(int[] array, int element)
+ {
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (array[i] == element)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public static bool Equals(byte[] x, byte[] y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ if (x == null)
+ {
+ return false;
+ }
+ if (x.Length != y.Length)
+ {
+ return false;
+ }
+ for (int i = 0; i < x.Length; i++)
+ {
+ if (y[i] != x[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static bool Equals(object[] x, object[] y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ if (x == null)
+ {
+ return false;
+ }
+ if (x.Length != y.Length)
+ {
+ return false;
+ }
+ for (int i = 0; i < x.Length; i++)
+ {
+ if (!ObjectsAreEqual(y[i], x[i]))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static bool ObjectsAreEqual(object x, object y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ if (x == null || y == null)
+ {
+ return false;
+ }
+ return x.Equals(y);
+ }
+
+ public static bool ContainsInstanceOf(object[] array, Type klass)
+ {
+ if (array == null)
+ {
+ return false;
+ }
+ for (int i = 0; i < array.Length; ++i)
+ {
+ if (klass.IsInstanceOfType(array[i]))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void Fill(object[] array, object value)
+ {
+ for (int i = 0; i < array.Length; ++i)
+ {
+ array[i] = value;
+ }
+ }
+
+ public static Collection4 AsList(object[] arr)
+ {
+ Collection4 coll = new Collection4();
+ for (int arrIdx = 0; arrIdx < arr.Length; arrIdx++)
+ {
+ coll.Add(arr[arrIdx]);
+ }
+ return coll;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,14 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class AutoStopWatch : StopWatch
+ {
+ public AutoStopWatch()
+ {
+ Start();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,100 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public sealed class BitMap4
+ {
+ private readonly byte[] _bits;
+
+ public BitMap4(int numBits)
+ {
+ _bits = new byte[ByteCount(numBits)];
+ }
+
+ /// "readFrom buffer" constructor
+ public BitMap4(byte[] buffer, int pos, int numBits) : this(numBits)
+ {
+ System.Array.Copy(buffer, pos, _bits, 0, _bits.Length);
+ }
+
+ public BitMap4(byte singleByte)
+ {
+ _bits = new byte[] { singleByte };
+ }
+
+ public bool IsTrue(int bit)
+ {
+ return (((_bits[ArrayOffset(bit)]) >> (ByteOffset(bit) & 0x1f)) & 1) != 0;
+ }
+
+ public bool IsFalse(int bit)
+ {
+ return !IsTrue(bit);
+ }
+
+ public int MarshalledLength()
+ {
+ return _bits.Length;
+ }
+
+ public void SetFalse(int bit)
+ {
+ _bits[ArrayOffset(bit)] &= (byte)~BitMask(bit);
+ }
+
+ public void Set(int bit, bool val)
+ {
+ if (val)
+ {
+ SetTrue(bit);
+ }
+ else
+ {
+ SetFalse(bit);
+ }
+ }
+
+ public void SetTrue(int bit)
+ {
+ _bits[ArrayOffset(bit)] |= BitMask(bit);
+ }
+
+ public void WriteTo(byte[] bytes, int pos)
+ {
+ System.Array.Copy(_bits, 0, bytes, pos, _bits.Length);
+ }
+
+ private byte ByteOffset(int bit)
+ {
+ return (byte)(bit % 8);
+ }
+
+ private int ArrayOffset(int bit)
+ {
+ return bit / 8;
+ }
+
+ private byte BitMask(int bit)
+ {
+ return (byte)(1 << ByteOffset(bit));
+ }
+
+ private int ByteCount(int numBits)
+ {
+ return (numBits + 7) / 8;
+ }
+
+ public byte GetByte(int index)
+ {
+ return _bits[index];
+ }
+
+ public byte[] Bytes()
+ {
+ return _bits;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,290 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class BlockingQueue : IBlockingQueue4
+ {
+ protected NonblockingQueue _queue = new NonblockingQueue();
+
+ protected Lock4 _lock = new Lock4();
+
+ protected bool _stopped;
+
+ public virtual void Add(object obj)
+ {
+ if (obj == null)
+ {
+ throw new ArgumentException();
+ }
+ _lock.Run(new _IClosure4_20(this, obj));
+ }
+
+ private sealed class _IClosure4_20 : IClosure4
+ {
+ public _IClosure4_20(BlockingQueue _enclosing, object obj)
+ {
+ this._enclosing = _enclosing;
+ this.obj = obj;
+ }
+
+ public object Run()
+ {
+ this._enclosing._queue.Add(obj);
+ this._enclosing._lock.Awake();
+ return null;
+ }
+
+ private readonly BlockingQueue _enclosing;
+
+ private readonly object obj;
+ }
+
+ public virtual bool HasNext()
+ {
+ return (((bool)_lock.Run(new _IClosure4_30(this))));
+ }
+
+ private sealed class _IClosure4_30 : IClosure4
+ {
+ public _IClosure4_30(BlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ return this._enclosing._queue.HasNext();
+ }
+
+ private readonly BlockingQueue _enclosing;
+ }
+
+ public virtual IEnumerator Iterator()
+ {
+ return ((IEnumerator)_lock.Run(new _IClosure4_38(this)));
+ }
+
+ private sealed class _IClosure4_38 : IClosure4
+ {
+ public _IClosure4_38(BlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ return this._enclosing._queue.Iterator();
+ }
+
+ private readonly BlockingQueue _enclosing;
+ }
+
+ ///
+ public virtual object Next(long timeout)
+ {
+ return (object)_lock.Run(new _IClosure4_46(this, timeout));
+ }
+
+ private sealed class _IClosure4_46 : IClosure4
+ {
+ public _IClosure4_46(BlockingQueue _enclosing, long timeout)
+ {
+ this._enclosing = _enclosing;
+ this.timeout = timeout;
+ }
+
+ public object Run()
+ {
+ return this._enclosing.UnsafeWaitForNext(timeout) ? this._enclosing.UnsafeNext() :
+ null;
+ }
+
+ private readonly BlockingQueue _enclosing;
+
+ private readonly long timeout;
+ }
+
+ public virtual int DrainTo(Collection4 target)
+ {
+ return (((int)_lock.Run(new _IClosure4_54(this, target))));
+ }
+
+ private sealed class _IClosure4_54 : IClosure4
+ {
+ public _IClosure4_54(BlockingQueue _enclosing, Collection4 target)
+ {
+ this._enclosing = _enclosing;
+ this.target = target;
+ }
+
+ public object Run()
+ {
+ this._enclosing.UnsafeWaitForNext();
+ int i = 0;
+ while (this._enclosing.HasNext())
+ {
+ i++;
+ target.Add(this._enclosing.UnsafeNext());
+ }
+ return i;
+ }
+
+ private readonly BlockingQueue _enclosing;
+
+ private readonly Collection4 target;
+ }
+
+ ///
+ public virtual bool WaitForNext(long timeout)
+ {
+ return (((bool)_lock.Run(new _IClosure4_68(this, timeout))));
+ }
+
+ private sealed class _IClosure4_68 : IClosure4
+ {
+ public _IClosure4_68(BlockingQueue _enclosing, long timeout)
+ {
+ this._enclosing = _enclosing;
+ this.timeout = timeout;
+ }
+
+ public object Run()
+ {
+ return this._enclosing.UnsafeWaitForNext(timeout);
+ }
+
+ private readonly BlockingQueue _enclosing;
+
+ private readonly long timeout;
+ }
+
+ ///
+ public virtual object Next()
+ {
+ return (object)_lock.Run(new _IClosure4_76(this));
+ }
+
+ private sealed class _IClosure4_76 : IClosure4
+ {
+ public _IClosure4_76(BlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ this._enclosing.UnsafeWaitForNext();
+ return this._enclosing.UnsafeNext();
+ }
+
+ private readonly BlockingQueue _enclosing;
+ }
+
+ public virtual void Stop()
+ {
+ _lock.Run(new _IClosure4_85(this));
+ }
+
+ private sealed class _IClosure4_85 : IClosure4
+ {
+ public _IClosure4_85(BlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ this._enclosing._stopped = true;
+ this._enclosing._lock.Awake();
+ return null;
+ }
+
+ private readonly BlockingQueue _enclosing;
+ }
+
+ public virtual object NextMatching(IPredicate4 condition)
+ {
+ return _lock.Run(new _IClosure4_95(this, condition));
+ }
+
+ private sealed class _IClosure4_95 : IClosure4
+ {
+ public _IClosure4_95(BlockingQueue _enclosing, IPredicate4 condition)
+ {
+ this._enclosing = _enclosing;
+ this.condition = condition;
+ }
+
+ public object Run()
+ {
+ return this._enclosing._queue.NextMatching(condition);
+ }
+
+ private readonly BlockingQueue _enclosing;
+
+ private readonly IPredicate4 condition;
+ }
+
+ ///
+ public virtual void WaitForNext()
+ {
+ _lock.Run(new _IClosure4_103(this));
+ }
+
+ private sealed class _IClosure4_103 : IClosure4
+ {
+ public _IClosure4_103(BlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ this._enclosing.UnsafeWaitForNext();
+ return null;
+ }
+
+ private readonly BlockingQueue _enclosing;
+ }
+
+ ///
+ protected virtual void UnsafeWaitForNext()
+ {
+ UnsafeWaitForNext(long.MaxValue);
+ }
+
+ ///
+ protected virtual bool UnsafeWaitForNext(long timeout)
+ {
+ long timeLeft = timeout;
+ long now = Runtime.CurrentTimeMillis();
+ while (timeLeft > 0)
+ {
+ if (_queue.HasNext())
+ {
+ return true;
+ }
+ if (_stopped)
+ {
+ throw new BlockingQueueStoppedException();
+ }
+ _lock.Snooze(timeLeft);
+ long l = now;
+ now = Runtime.CurrentTimeMillis();
+ timeLeft -= now - l;
+ }
+ return false;
+ }
+
+ private object UnsafeNext()
+ {
+ return _queue.Next();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ [System.Serializable]
+ public class BlockingQueueStoppedException : Exception
+ {
+ public BlockingQueueStoppedException() : base()
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.BlockingQueueStoppedException.Log();
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Useful as "out" or "by ref" function parameter.
+ /// Useful as "out" or "by ref" function parameter.
+ public class BooleanByRef
+ {
+ public bool value;
+
+ public BooleanByRef() : this(false)
+ {
+ }
+
+ public BooleanByRef(bool value_)
+ {
+ value = value_;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Useful as "out" or "by reference" function parameter.
+ /// Useful as "out" or "by reference" function parameter.
+ public class ByRef
+ {
+ public static ByRef NewInstance(object initialValue)
+ {
+ ByRef instance = new ByRef();
+ instance.value = initialValue;
+ return instance;
+ }
+
+ public static ByRef NewInstance()
+ {
+ return new ByRef();
+ }
+
+ public object value;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,205 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations.
+ ///
+ /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations.
+ ///
+ public class CircularBuffer4 : IEnumerable
+ {
+ private readonly object[] _buffer;
+
+ private int _head;
+
+ private int _tail;
+
+ public CircularBuffer4(int size)
+ {
+ _buffer = (object[])new object[size + 1];
+ }
+
+ public virtual int Size()
+ {
+ return Index(_tail - _head);
+ }
+
+ public virtual void AddFirst(object value)
+ {
+ int newHead = CircularIndex(_head - 1);
+ if (newHead == _tail)
+ {
+ throw new InvalidOperationException();
+ }
+ _head = newHead;
+ _buffer[Index(_head)] = value;
+ }
+
+ private int CircularIndex(int index)
+ {
+ return index % _buffer.Length;
+ }
+
+ private int Index(int i)
+ {
+ return i < 0 ? _buffer.Length + i : i;
+ }
+
+ public virtual object RemoveLast()
+ {
+ AssertNotEmpty();
+ _tail = CircularIndex(_tail - 1);
+ return Erase(_tail);
+ }
+
+ private void AssertNotEmpty()
+ {
+ if (IsEmpty())
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return Index(_head) == Index(_tail);
+ }
+
+ public virtual bool IsFull()
+ {
+ return CircularIndex(_head - 1) == _tail;
+ }
+
+ public virtual object RemoveFirst()
+ {
+ AssertNotEmpty();
+ object erased = Erase(_head);
+ _head = CircularIndex(_head + 1);
+ return erased;
+ }
+
+ private object Erase(int index)
+ {
+ int bufferIndex = Index(index);
+ object erasedValue = _buffer[bufferIndex];
+ _buffer[bufferIndex] = null;
+ return erasedValue;
+ }
+
+ public virtual bool Remove(object value)
+ {
+ int idx = IndexOf(value);
+ if (idx >= 0)
+ {
+ RemoveAt(idx);
+ return true;
+ }
+ return false;
+ }
+
+ public virtual bool Contains(object value)
+ {
+ return IndexOf(value) >= 0;
+ }
+
+ private int IndexOf(object value)
+ {
+ int current = Index(_head);
+ int tail = Index(_tail);
+ while (current != tail)
+ {
+ if (((object)value).Equals(_buffer[current]))
+ {
+ break;
+ }
+ current = CircularIndex(current + 1);
+ }
+ return (current == tail ? -1 : current);
+ }
+
+ private void RemoveAt(int index)
+ {
+ if (Index(_tail - 1) == index)
+ {
+ RemoveLast();
+ return;
+ }
+ if (index == Index(_head))
+ {
+ RemoveFirst();
+ return;
+ }
+ int current = index;
+ int tail = Index(_tail);
+ while (current != tail)
+ {
+ int next = CircularIndex(current + 1);
+ _buffer[current] = _buffer[next];
+ current = next;
+ }
+ _tail = CircularIndex(_tail - 1);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ int tail = Index(_tail);
+ int head = Index(_head);
+ // TODO: detect concurrent modification and throw IllegalStateException
+ return new _IEnumerator_121(this, head, tail);
+ }
+
+ private sealed class _IEnumerator_121 : IEnumerator
+ {
+ public _IEnumerator_121(CircularBuffer4 _enclosing, int head, int tail)
+ {
+ this._enclosing = _enclosing;
+ this.head = head;
+ this.tail = tail;
+ this._index = head;
+ this._current = Iterators.NoElement;
+ }
+
+ private int _index;
+
+ private object _current;
+
+ public object Current
+ {
+ get
+ {
+ if (this._current == Iterators.NoElement)
+ {
+ throw new InvalidOperationException();
+ }
+ return this._current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._index == tail)
+ {
+ return false;
+ }
+ this._current = this._enclosing._buffer[this._index];
+ this._index = this._enclosing.CircularIndex(this._index + 1);
+ return true;
+ }
+
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ private readonly CircularBuffer4 _enclosing;
+
+ private readonly int head;
+
+ private readonly int tail;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,207 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations.
+ ///
+ /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations.
+ ///
+ public class CircularIntBuffer4 : IEnumerable
+ {
+ private const int Empty = -1;
+
+ private readonly int[] _buffer;
+
+ private int _head;
+
+ private int _tail;
+
+ public CircularIntBuffer4(int size)
+ {
+ _buffer = new int[size + 1];
+ }
+
+ public virtual int Size()
+ {
+ return Index(_tail - _head);
+ }
+
+ public virtual void AddFirst(int value)
+ {
+ int newHead = CircularIndex(_head - 1);
+ if (newHead == _tail)
+ {
+ throw new InvalidOperationException();
+ }
+ _head = newHead;
+ _buffer[Index(_head)] = value;
+ }
+
+ private int CircularIndex(int index)
+ {
+ return index % _buffer.Length;
+ }
+
+ private int Index(int i)
+ {
+ return i < 0 ? _buffer.Length + i : i;
+ }
+
+ public virtual int RemoveLast()
+ {
+ AssertNotEmpty();
+ _tail = CircularIndex(_tail - 1);
+ return Erase(_tail);
+ }
+
+ private void AssertNotEmpty()
+ {
+ if (IsEmpty())
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return Index(_head) == Index(_tail);
+ }
+
+ public virtual bool IsFull()
+ {
+ return CircularIndex(_head - 1) == _tail;
+ }
+
+ public virtual int RemoveFirst()
+ {
+ AssertNotEmpty();
+ int erased = Erase(_head);
+ _head = CircularIndex(_head + 1);
+ return erased;
+ }
+
+ private int Erase(int index)
+ {
+ int bufferIndex = Index(index);
+ int erasedValue = _buffer[bufferIndex];
+ _buffer[bufferIndex] = Empty;
+ return erasedValue;
+ }
+
+ public virtual bool Remove(int value)
+ {
+ int idx = IndexOf(value);
+ if (idx >= 0)
+ {
+ RemoveAt(idx);
+ return true;
+ }
+ return false;
+ }
+
+ public virtual bool Contains(int value)
+ {
+ return IndexOf(value) >= 0;
+ }
+
+ private int IndexOf(int value)
+ {
+ int current = Index(_head);
+ int tail = Index(_tail);
+ while (current != tail)
+ {
+ if (value == _buffer[current])
+ {
+ break;
+ }
+ current = CircularIndex(current + 1);
+ }
+ return (current == tail ? -1 : current);
+ }
+
+ private void RemoveAt(int index)
+ {
+ if (Index(_tail - 1) == index)
+ {
+ RemoveLast();
+ return;
+ }
+ if (index == Index(_head))
+ {
+ RemoveFirst();
+ return;
+ }
+ int current = index;
+ int tail = Index(_tail);
+ while (current != tail)
+ {
+ int next = CircularIndex(current + 1);
+ _buffer[current] = _buffer[next];
+ current = next;
+ }
+ _tail = CircularIndex(_tail - 1);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ int tail = Index(_tail);
+ int head = Index(_head);
+ // TODO: detect concurrent modification and throw IllegalStateException
+ return new _IEnumerator_123(this, head, tail);
+ }
+
+ private sealed class _IEnumerator_123 : IEnumerator
+ {
+ public _IEnumerator_123(CircularIntBuffer4 _enclosing, int head, int tail)
+ {
+ this._enclosing = _enclosing;
+ this.head = head;
+ this.tail = tail;
+ this._index = head;
+ this._current = Iterators.NoElement;
+ }
+
+ private int _index;
+
+ private object _current;
+
+ public object Current
+ {
+ get
+ {
+ if (this._current == Iterators.NoElement)
+ {
+ throw new InvalidOperationException();
+ }
+ return this._current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._index == tail)
+ {
+ return false;
+ }
+ this._current = this._enclosing._buffer[this._index];
+ this._index = this._enclosing.CircularIndex(this._index + 1);
+ return true;
+ }
+
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ private readonly CircularIntBuffer4 _enclosing;
+
+ private readonly int head;
+
+ private readonly int tail;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,207 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations.
+ ///
+ /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations.
+ ///
+ public class CircularLongBuffer4 : IEnumerable
+ {
+ private const int Empty = -1;
+
+ private readonly long[] _buffer;
+
+ private int _head;
+
+ private int _tail;
+
+ public CircularLongBuffer4(int size)
+ {
+ _buffer = new long[size + 1];
+ }
+
+ public virtual int Size()
+ {
+ return Index(_tail - _head);
+ }
+
+ public virtual void AddFirst(long value)
+ {
+ int newHead = CircularIndex(_head - 1);
+ if (newHead == _tail)
+ {
+ throw new InvalidOperationException();
+ }
+ _head = newHead;
+ _buffer[Index(_head)] = value;
+ }
+
+ private int CircularIndex(int index)
+ {
+ return index % _buffer.Length;
+ }
+
+ private int Index(int i)
+ {
+ return i < 0 ? _buffer.Length + i : i;
+ }
+
+ public virtual long RemoveLast()
+ {
+ AssertNotEmpty();
+ _tail = CircularIndex(_tail - 1);
+ return Erase(_tail);
+ }
+
+ private void AssertNotEmpty()
+ {
+ if (IsEmpty())
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return Index(_head) == Index(_tail);
+ }
+
+ public virtual bool IsFull()
+ {
+ return CircularIndex(_head - 1) == _tail;
+ }
+
+ public virtual long RemoveFirst()
+ {
+ AssertNotEmpty();
+ long erased = Erase(_head);
+ _head = CircularIndex(_head + 1);
+ return erased;
+ }
+
+ private long Erase(int index)
+ {
+ int bufferIndex = Index(index);
+ long erasedValue = _buffer[bufferIndex];
+ _buffer[bufferIndex] = Empty;
+ return erasedValue;
+ }
+
+ public virtual bool Remove(long value)
+ {
+ int idx = IndexOf(value);
+ if (idx >= 0)
+ {
+ RemoveAt(idx);
+ return true;
+ }
+ return false;
+ }
+
+ public virtual bool Contains(long value)
+ {
+ return IndexOf(value) >= 0;
+ }
+
+ private int IndexOf(long value)
+ {
+ int current = Index(_head);
+ int tail = Index(_tail);
+ while (current != tail)
+ {
+ if (value == _buffer[current])
+ {
+ break;
+ }
+ current = CircularIndex(current + 1);
+ }
+ return (current == tail ? -1 : current);
+ }
+
+ private void RemoveAt(int index)
+ {
+ if (Index(_tail - 1) == index)
+ {
+ RemoveLast();
+ return;
+ }
+ if (index == Index(_head))
+ {
+ RemoveFirst();
+ return;
+ }
+ int current = index;
+ int tail = Index(_tail);
+ while (current != tail)
+ {
+ int next = CircularIndex(current + 1);
+ _buffer[current] = _buffer[next];
+ current = next;
+ }
+ _tail = CircularIndex(_tail - 1);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ int tail = Index(_tail);
+ int head = Index(_head);
+ // TODO: detect concurrent modification and throw IllegalStateException
+ return new _IEnumerator_122(this, head, tail);
+ }
+
+ private sealed class _IEnumerator_122 : IEnumerator
+ {
+ public _IEnumerator_122(CircularLongBuffer4 _enclosing, int head, int tail)
+ {
+ this._enclosing = _enclosing;
+ this.head = head;
+ this.tail = tail;
+ this._index = head;
+ this._current = Iterators.NoElement;
+ }
+
+ private int _index;
+
+ private object _current;
+
+ public object Current
+ {
+ get
+ {
+ if (this._current == Iterators.NoElement)
+ {
+ throw new InvalidOperationException();
+ }
+ return this._current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._index == tail)
+ {
+ return false;
+ }
+ this._current = this._enclosing._buffer[this._index];
+ this._index = this._enclosing.CircularIndex(this._index + 1);
+ return true;
+ }
+
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ private readonly CircularLongBuffer4 _enclosing;
+
+ private readonly int head;
+
+ private readonly int tail;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,450 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Types;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Fast linked list for all usecases.
+ /// Fast linked list for all usecases.
+ ///
+ public class Collection4 : ISequence4, IEnumerable, IDeepClone, IUnversioned
+ {
+ private List4 _first;
+
+ private List4 _last;
+
+ private int _size;
+
+ private int _version;
+
+ public Collection4()
+ {
+ }
+
+ public Collection4(object[] elements)
+ {
+ AddAll(elements);
+ }
+
+ public Collection4(IEnumerable other)
+ {
+ AddAll(other);
+ }
+
+ public Collection4(IEnumerator iterator)
+ {
+ AddAll(iterator);
+ }
+
+ public virtual object SingleElement()
+ {
+ if (Size() != 1)
+ {
+ throw new InvalidOperationException();
+ }
+ return ((object)_first._element);
+ }
+
+ /// Adds an element to the end of this collection.
+ /// Adds an element to the end of this collection.
+ ///
+ public bool Add(object element)
+ {
+ DoAdd(element);
+ Changed();
+ return true;
+ }
+
+ public void Prepend(object element)
+ {
+ DoPrepend(element);
+ Changed();
+ }
+
+ private void DoPrepend(object element)
+ {
+ if (_first == null)
+ {
+ DoAdd(element);
+ }
+ else
+ {
+ _first = new List4(_first, element);
+ _size++;
+ }
+ }
+
+ private void DoAdd(object element)
+ {
+ if (_last == null)
+ {
+ _first = new List4(element);
+ _last = _first;
+ }
+ else
+ {
+ _last._next = new List4(element);
+ _last = ((List4)_last._next);
+ }
+ _size++;
+ }
+
+ public void AddAll(object[] elements)
+ {
+ AssertNotNull(elements);
+ for (int i = 0; i < elements.Length; i++)
+ {
+ Add(elements[i]);
+ }
+ }
+
+ public void AddAll(IEnumerable other)
+ {
+ AssertNotNull(other);
+ AddAll(other.GetEnumerator());
+ }
+
+ public void AddAll(IEnumerator iterator)
+ {
+ AssertNotNull(iterator);
+ while (iterator.MoveNext())
+ {
+ Add(iterator.Current);
+ }
+ }
+
+ public void Clear()
+ {
+ _first = null;
+ _last = null;
+ _size = 0;
+ Changed();
+ }
+
+ public bool Contains(object element)
+ {
+ return Find(element) != null;
+ }
+
+ public virtual bool ContainsAll(IEnumerable iter)
+ {
+ return ContainsAll(iter.GetEnumerator());
+ }
+
+ public virtual bool ContainsAll(IEnumerator iter)
+ {
+ AssertNotNull(iter);
+ while (iter.MoveNext())
+ {
+ if (!Contains(iter.Current))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// tests if the object is in the Collection.
+ /// tests if the object is in the Collection. == comparison.
+ public bool ContainsByIdentity(object element)
+ {
+ IEnumerator i = InternalIterator();
+ while (i.MoveNext())
+ {
+ object current = i.Current;
+ if (current == element)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private List4 Find(object obj)
+ {
+ List4 current = _first;
+ while (current != null)
+ {
+ if (current.Holds(obj))
+ {
+ return current;
+ }
+ current = ((List4)current._next);
+ }
+ return null;
+ }
+
+ private List4 FindByIdentity(object obj)
+ {
+ List4 current = _first;
+ while (current != null)
+ {
+ if (((object)current._element) == obj)
+ {
+ return current;
+ }
+ current = ((List4)current._next);
+ }
+ return null;
+ }
+
+ ///
+ /// returns the first object found in the Collections that equals() the
+ /// passed object
+ ///
+ public object Get(object element)
+ {
+ List4 holder = Find(element);
+ return holder == null ? null : ((object)holder._element);
+ }
+
+ public virtual object DeepClone(object newParent)
+ {
+ Db4objects.Db4o.Foundation.Collection4 col = new Db4objects.Db4o.Foundation.Collection4
+ ();
+ object element = null;
+ IEnumerator i = InternalIterator();
+ while (i.MoveNext())
+ {
+ element = i.Current;
+ if (element is IDeepClone)
+ {
+ col.Add(((IDeepClone)element).DeepClone(newParent));
+ }
+ else
+ {
+ col.Add(element);
+ }
+ }
+ return col;
+ }
+
+ /// makes sure the passed object is in the Collection.
+ /// makes sure the passed object is in the Collection. equals() comparison.
+ public object Ensure(object element)
+ {
+ List4 list = Find(element);
+ if (list == null)
+ {
+ Add(element);
+ return element;
+ }
+ return ((object)list._element);
+ }
+
+ ///
+ /// Iterates through the collection in reversed insertion order which happens
+ /// to be the fastest.
+ ///
+ ///
+ /// Iterates through the collection in reversed insertion order which happens
+ /// to be the fastest.
+ ///
+ ///
+ public IEnumerator GetEnumerator()
+ {
+ return _first == null ? Iterators.EmptyIterator : new Collection4Iterator(this, _first
+ );
+ }
+
+ public virtual object Get(int index)
+ {
+ if (index < 0)
+ {
+ throw new ArgumentException();
+ }
+ List4 cur = _first;
+ while (index > 0 && cur != null)
+ {
+ cur = ((List4)cur._next);
+ index--;
+ }
+ if (cur == null)
+ {
+ throw new ArgumentException();
+ }
+ return ((object)cur._element);
+ }
+
+ ///
+ /// Removes all the elements from this collection that are returned by
+ /// iterable.
+ ///
+ ///
+ /// Removes all the elements from this collection that are returned by
+ /// iterable.
+ ///
+ ///
+ public virtual void RemoveAll(IEnumerable iterable)
+ {
+ RemoveAll(iterable.GetEnumerator());
+ }
+
+ ///
+ /// Removes all the elements from this collection that are returned by
+ /// iterator.
+ ///
+ ///
+ /// Removes all the elements from this collection that are returned by
+ /// iterator.
+ ///
+ public virtual void RemoveAll(IEnumerator iterator)
+ {
+ while (iterator.MoveNext())
+ {
+ Remove(iterator.Current);
+ }
+ }
+
+ ///
+ /// removes an object from the Collection equals() comparison returns the
+ /// removed object or null, if none found
+ ///
+ public virtual bool Remove(object a_object)
+ {
+ List4 previous = null;
+ List4 current = _first;
+ while (current != null)
+ {
+ if (current.Holds(a_object))
+ {
+ _size--;
+ AdjustOnRemoval(previous, current);
+ Changed();
+ return true;
+ }
+ previous = current;
+ current = ((List4)current._next);
+ }
+ return false;
+ }
+
+ public virtual void Replace(object oldObject, object newObject)
+ {
+ List4 list = Find(oldObject);
+ if (list != null)
+ {
+ list._element = newObject;
+ }
+ }
+
+ public virtual void ReplaceByIdentity(object oldObject, object newObject)
+ {
+ List4 list = FindByIdentity(oldObject);
+ if (list != null)
+ {
+ list._element = newObject;
+ }
+ }
+
+ private void AdjustOnRemoval(List4 previous, List4 removed)
+ {
+ if (removed == _first)
+ {
+ _first = ((List4)removed._next);
+ }
+ else
+ {
+ previous._next = ((List4)removed._next);
+ }
+ if (removed == _last)
+ {
+ _last = previous;
+ }
+ }
+
+ public int Size()
+ {
+ return _size;
+ }
+
+ public virtual int IndexOf(object obj)
+ {
+ int index = 0;
+ List4 current = _first;
+ while (current != null)
+ {
+ if (current.Holds(obj))
+ {
+ return index;
+ }
+ index++;
+ current = ((List4)current._next);
+ }
+ return -1;
+ }
+
+ public bool IsEmpty()
+ {
+ return _size == 0;
+ }
+
+ /// This is a non reflection implementation for more speed.
+ ///
+ /// This is a non reflection implementation for more speed. In contrast to
+ /// the JDK behaviour, the passed array has to be initialized to the right
+ /// length.
+ ///
+ public object[] ToArray(object[] array)
+ {
+ int j = 0;
+ IEnumerator i = InternalIterator();
+ while (i.MoveNext())
+ {
+ array[j++] = i.Current;
+ }
+ return array;
+ }
+
+ public object[] ToArray()
+ {
+ int j = 0;
+ object[] array = new object[Size()];
+ IEnumerator i = InternalIterator();
+ while (i.MoveNext())
+ {
+ array[j++] = i.Current;
+ }
+ return array;
+ }
+
+ public override string ToString()
+ {
+ return Iterators.ToString(InternalIterator());
+ }
+
+ private void Changed()
+ {
+ ++_version;
+ }
+
+ internal virtual int Version()
+ {
+ return _version;
+ }
+
+ private void AssertNotNull(object element)
+ {
+ if (element == null)
+ {
+ throw new ArgumentNullException();
+ }
+ }
+
+ ///
+ /// Leaner iterator for faster iteration (but unprotected against
+ /// concurrent modifications).
+ ///
+ ///
+ /// Leaner iterator for faster iteration (but unprotected against
+ /// concurrent modifications).
+ ///
+ private IEnumerator InternalIterator()
+ {
+ return new Iterator4Impl(_first);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,49 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Collection4Iterator : Iterator4Impl
+ {
+ private readonly Collection4 _collection;
+
+ private readonly int _initialVersion;
+
+ public Collection4Iterator(Collection4 collection, List4 first) : base(first)
+ {
+ _collection = collection;
+ _initialVersion = CurrentVersion();
+ }
+
+ public override bool MoveNext()
+ {
+ Validate();
+ return base.MoveNext();
+ }
+
+ public override object Current
+ {
+ get
+ {
+ Validate();
+ return base.Current;
+ }
+ }
+
+ private void Validate()
+ {
+ if (_initialVersion != CurrentVersion())
+ {
+ // FIXME: change to ConcurrentModificationException
+ throw new InvalidIteratorException();
+ }
+ }
+
+ private int CurrentVersion()
+ {
+ return _collection.Version();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,86 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class Collections4
+ {
+ public static ISequence4 UnmodifiableList(ISequence4 orig)
+ {
+ return new Collections4.UnmodifiableSequence4(orig);
+ }
+
+ private class UnmodifiableSequence4 : ISequence4
+ {
+ private ISequence4 _sequence;
+
+ public UnmodifiableSequence4(ISequence4 sequence)
+ {
+ _sequence = sequence;
+ }
+
+ public virtual bool Add(object element)
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual void AddAll(IEnumerable iterable)
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return _sequence.IsEmpty();
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _sequence.GetEnumerator();
+ }
+
+ public virtual object Get(int index)
+ {
+ return _sequence.Get(index);
+ }
+
+ public virtual int Size()
+ {
+ return _sequence.Size();
+ }
+
+ public virtual void Clear()
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual bool Remove(object obj)
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual bool Contains(object obj)
+ {
+ return _sequence.Contains(obj);
+ }
+
+ public virtual bool ContainsAll(IEnumerable iter)
+ {
+ return _sequence.ContainsAll(iter);
+ }
+
+ public virtual object[] ToArray()
+ {
+ return _sequence.ToArray();
+ }
+
+ public virtual object[] ToArray(object[] array)
+ {
+ return _sequence.ToArray(array);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,34 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class CompositeIterable4 : IEnumerable
+ {
+ private readonly IEnumerable _iterables;
+
+ public CompositeIterable4(IEnumerable iterables)
+ {
+ _iterables = iterables;
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return new _CompositeIterator4_15(_iterables.GetEnumerator());
+ }
+
+ private sealed class _CompositeIterator4_15 : CompositeIterator4
+ {
+ public _CompositeIterator4_15(IEnumerator baseArg1) : base(baseArg1)
+ {
+ }
+
+ protected override IEnumerator NextIterator(object current)
+ {
+ return ((IEnumerable)current).GetEnumerator();
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,81 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class CompositeIterator4 : IEnumerator
+ {
+ protected readonly IEnumerator _iterators;
+
+ protected IEnumerator _currentIterator;
+
+ public CompositeIterator4(IEnumerator[] iterators) : this(new ArrayIterator4(iterators
+ ))
+ {
+ }
+
+ public CompositeIterator4(IEnumerator iterators)
+ {
+ if (null == iterators)
+ {
+ throw new ArgumentNullException();
+ }
+ _iterators = iterators;
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (null == _currentIterator)
+ {
+ if (!_iterators.MoveNext())
+ {
+ return false;
+ }
+ _currentIterator = NextIterator(_iterators.Current);
+ }
+ if (!_currentIterator.MoveNext())
+ {
+ _currentIterator = null;
+ return MoveNext();
+ }
+ return true;
+ }
+
+ public virtual void Reset()
+ {
+ ResetIterators();
+ _currentIterator = null;
+ _iterators.Reset();
+ }
+
+ private void ResetIterators()
+ {
+ _iterators.Reset();
+ while (_iterators.MoveNext())
+ {
+ NextIterator(_iterators.Current).Reset();
+ }
+ }
+
+ public virtual IEnumerator CurrentIterator()
+ {
+ return _currentIterator;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ return _currentIterator.Current;
+ }
+ }
+
+ protected virtual IEnumerator NextIterator(object current)
+ {
+ return (IEnumerator)current;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,58 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class DelegatingBlockingQueue : IBlockingQueue4
+ {
+ private IBlockingQueue4 queue;
+
+ ///
+ public virtual object Next(long timeout)
+ {
+ return queue.Next(timeout);
+ }
+
+ public virtual object Next()
+ {
+ return queue.Next();
+ }
+
+ public virtual void Add(object obj)
+ {
+ queue.Add(obj);
+ }
+
+ public virtual bool HasNext()
+ {
+ return queue.HasNext();
+ }
+
+ public virtual object NextMatching(IPredicate4 condition)
+ {
+ return queue.NextMatching(condition);
+ }
+
+ public virtual IEnumerator Iterator()
+ {
+ return queue.Iterator();
+ }
+
+ public DelegatingBlockingQueue(IBlockingQueue4 queue)
+ {
+ this.queue = queue;
+ }
+
+ public virtual void Stop()
+ {
+ queue.Stop();
+ }
+
+ public virtual int DrainTo(Collection4 list)
+ {
+ return queue.DrainTo(list);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,71 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// A dynamic variable is a value associated to a specific thread and scope.
+ ///
+ ///
+ /// A dynamic variable is a value associated to a specific thread and scope.
+ /// The value is brought into scope with the
+ /// With(object, IClosure4)
+ /// method.
+ ///
+ public class DynamicVariable
+ {
+ public static DynamicVariable NewInstance()
+ {
+ return new DynamicVariable();
+ }
+
+ private readonly ThreadLocal _value = new ThreadLocal();
+
+ public virtual object Value
+ {
+ get
+ {
+ object value = _value.Get();
+ return value == null ? DefaultValue() : value;
+ }
+ set
+ {
+ _value.Set(value);
+ }
+ }
+
+ protected virtual object DefaultValue()
+ {
+ return null;
+ }
+
+ public virtual object With(object value, IClosure4 block)
+ {
+ object previous = _value.Get();
+ _value.Set(value);
+ try
+ {
+ return block.Run();
+ }
+ finally
+ {
+ _value.Set(previous);
+ }
+ }
+
+ public virtual void With(object value, IRunnable block)
+ {
+ object previous = _value.Get();
+ _value.Set(value);
+ try
+ {
+ block.Run();
+ }
+ finally
+ {
+ _value.Set(previous);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,45 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class EnumerateIterator : MappingIterator
+ {
+ public sealed class Tuple
+ {
+ public readonly int index;
+
+ public readonly object value;
+
+ public Tuple(int index_, object value_)
+ {
+ index = index_;
+ value = value_;
+ }
+ }
+
+ private int _index;
+
+ public EnumerateIterator(IEnumerator iterator) : base(iterator)
+ {
+ _index = 0;
+ }
+
+ public override bool MoveNext()
+ {
+ if (base.MoveNext())
+ {
+ ++_index;
+ return true;
+ }
+ return false;
+ }
+
+ protected override object Map(object current)
+ {
+ return new EnumerateIterator.Tuple(_index, current);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,165 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public partial class Environments
+ {
+ private static readonly DynamicVariable _current = DynamicVariable.NewInstance();
+
+ public static object My(Type service)
+ {
+ IEnvironment environment = Current();
+ if (null == environment)
+ {
+ throw new InvalidOperationException();
+ }
+ return environment.Provide(service);
+ }
+
+ private static IEnvironment Current()
+ {
+ return ((IEnvironment)_current.Value);
+ }
+
+ public static void RunWith(IEnvironment environment, IRunnable runnable)
+ {
+ _current.With(environment, runnable);
+ }
+
+ public static IEnvironment NewClosedEnvironment(object[] bindings)
+ {
+ return new _IEnvironment_32(bindings);
+ }
+
+ private sealed class _IEnvironment_32 : IEnvironment
+ {
+ public _IEnvironment_32(object[] bindings)
+ {
+ this.bindings = bindings;
+ }
+
+ public object Provide(Type service)
+ {
+ for (int bindingIndex = 0; bindingIndex < bindings.Length; ++bindingIndex)
+ {
+ object binding = bindings[bindingIndex];
+ if (service.IsInstanceOfType(binding))
+ {
+ return (object)binding;
+ }
+ }
+ return null;
+ }
+
+ private readonly object[] bindings;
+ }
+
+ public static IEnvironment NewCachingEnvironmentFor(IEnvironment environment)
+ {
+ return new _IEnvironment_48(environment);
+ }
+
+ private sealed class _IEnvironment_48 : IEnvironment
+ {
+ public _IEnvironment_48(IEnvironment environment)
+ {
+ this.environment = environment;
+ this._bindings = new Hashtable();
+ }
+
+ private readonly IDictionary _bindings;
+
+ public object Provide(Type service)
+ {
+ object existing = this._bindings[service];
+ if (null != existing)
+ {
+ return (object)existing;
+ }
+ object binding = environment.Provide(service);
+ if (null == binding)
+ {
+ return null;
+ }
+ this._bindings[service] = binding;
+ return binding;
+ }
+
+ private readonly IEnvironment environment;
+ }
+
+ public static IEnvironment NewConventionBasedEnvironment(object[] bindings)
+ {
+ return NewCachingEnvironmentFor(Compose(new IEnvironment[] { NewClosedEnvironment
+ (bindings), new Environments.ConventionBasedEnvironment() }));
+ }
+
+ public static IEnvironment NewConventionBasedEnvironment()
+ {
+ return NewCachingEnvironmentFor(new Environments.ConventionBasedEnvironment());
+ }
+
+ public static IEnvironment Compose(IEnvironment[] environments)
+ {
+ return new _IEnvironment_75(environments);
+ }
+
+ private sealed class _IEnvironment_75 : IEnvironment
+ {
+ public _IEnvironment_75(IEnvironment[] environments)
+ {
+ this.environments = environments;
+ }
+
+ public object Provide(Type service)
+ {
+ for (int eIndex = 0; eIndex < environments.Length; ++eIndex)
+ {
+ IEnvironment e = environments[eIndex];
+ object binding = e.Provide(service);
+ if (null != binding)
+ {
+ return binding;
+ }
+ }
+ return null;
+ }
+
+ private readonly IEnvironment[] environments;
+ }
+
+ private sealed class ConventionBasedEnvironment : IEnvironment
+ {
+ public object Provide(Type service)
+ {
+ return Resolve(service);
+ }
+
+ ///
+ /// Resolves a service interface to its default implementation using the
+ /// db4o namespace convention:
+ /// interface foo.bar.Baz
+ /// default implementation foo.internal.bar.BazImpl
+ ///
+ /// the convention based type name for the requested service
+ private object Resolve(Type service)
+ {
+ string className = DefaultImplementationFor(service);
+ object binding = ReflectPlatform.CreateInstance(className);
+ if (null == binding)
+ {
+ throw new ArgumentException("Cant find default implementation for " + service.ToString
+ () + ": " + className);
+ }
+ return (object)binding;
+ }
+ }
+ // ignore convention for internal types
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class FilteredIterator : MappingIterator
+ {
+ private readonly IPredicate4 _filter;
+
+ public FilteredIterator(IEnumerator iterator, IPredicate4 filter) : base(iterator
+ )
+ {
+ _filter = filter;
+ }
+
+ protected override object Map(object current)
+ {
+ return _filter.Match(current) ? current : Iterators.Skip;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,74 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class FlatteningIterator : CompositeIterator4
+ {
+ private class IteratorStack
+ {
+ public readonly IEnumerator iterator;
+
+ public readonly FlatteningIterator.IteratorStack next;
+
+ public IteratorStack(IEnumerator iterator_, FlatteningIterator.IteratorStack next_
+ )
+ {
+ iterator = iterator_;
+ next = next_;
+ }
+ }
+
+ private FlatteningIterator.IteratorStack _stack;
+
+ public FlatteningIterator(IEnumerator iterators) : base(iterators)
+ {
+ }
+
+ public override bool MoveNext()
+ {
+ if (null == _currentIterator)
+ {
+ if (null == _stack)
+ {
+ _currentIterator = _iterators;
+ }
+ else
+ {
+ _currentIterator = Pop();
+ }
+ }
+ if (!_currentIterator.MoveNext())
+ {
+ if (_currentIterator == _iterators)
+ {
+ return false;
+ }
+ _currentIterator = null;
+ return MoveNext();
+ }
+ object current = _currentIterator.Current;
+ if (current is IEnumerator)
+ {
+ Push(_currentIterator);
+ _currentIterator = NextIterator(current);
+ return MoveNext();
+ }
+ return true;
+ }
+
+ private void Push(IEnumerator currentIterator)
+ {
+ _stack = new FlatteningIterator.IteratorStack(currentIterator, _stack);
+ }
+
+ private IEnumerator Pop()
+ {
+ IEnumerator iterator = _stack.iterator;
+ _stack = _stack.next;
+ return iterator;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class FunctionApplicationIterator : MappingIterator
+ {
+ private readonly IFunction4 _function;
+
+ public FunctionApplicationIterator(IEnumerator iterator, IFunction4 function) : base
+ (iterator)
+ {
+ if (null == function)
+ {
+ throw new ArgumentNullException();
+ }
+ _function = function;
+ }
+
+ protected override object Map(object current)
+ {
+ return _function.Apply(current);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,66 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class HashSet4 : ISet4
+ {
+ private Hashtable4 _map;
+
+ public HashSet4() : this(1)
+ {
+ }
+
+ public HashSet4(int count)
+ {
+ _map = new Hashtable4(count);
+ }
+
+ public virtual bool Add(object obj)
+ {
+ if (_map.ContainsKey(obj))
+ {
+ return false;
+ }
+ _map.Put(obj, obj);
+ return true;
+ }
+
+ public virtual void Clear()
+ {
+ _map.Clear();
+ }
+
+ public virtual bool Contains(object obj)
+ {
+ return _map.ContainsKey(obj);
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return _map.Size() == 0;
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _map.Values().GetEnumerator();
+ }
+
+ public virtual bool Remove(object obj)
+ {
+ return _map.Remove(obj) != null;
+ }
+
+ public virtual int Size()
+ {
+ return _map.Size();
+ }
+
+ public override string ToString()
+ {
+ return Iterators.Join(_map.Keys(), "{", "}", ", ");
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,231 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Hashtable4 : HashtableBase, IDeepClone, IMap4
+ {
+ public Hashtable4(int size) : base(size)
+ {
+ }
+
+ public Hashtable4() : this(1)
+ {
+ }
+
+ ///
+ protected Hashtable4(IDeepClone cloneOnlyCtor) : base(cloneOnlyCtor)
+ {
+ }
+
+ public virtual object DeepClone(object obj)
+ {
+ return DeepCloneInternal(new Db4objects.Db4o.Foundation.Hashtable4((IDeepClone)null
+ ), obj);
+ }
+
+ public virtual void ForEachKeyForIdentity(IVisitor4 visitor, object obj)
+ {
+ for (int i = 0; i < _table.Length; i++)
+ {
+ HashtableIntEntry entry = _table[i];
+ while (entry != null)
+ {
+ if (entry._object == obj)
+ {
+ visitor.Visit(entry.Key());
+ }
+ entry = entry._next;
+ }
+ }
+ }
+
+ public virtual object Get(byte[] key)
+ {
+ int intKey = HashtableByteArrayEntry.Hash(key);
+ return GetFromObjectEntry(intKey, key);
+ }
+
+ public virtual object Get(int key)
+ {
+ HashtableIntEntry entry = _table[key & _mask];
+ while (entry != null)
+ {
+ if (entry._key == key)
+ {
+ return entry._object;
+ }
+ entry = entry._next;
+ }
+ return null;
+ }
+
+ public virtual object Get(object key)
+ {
+ if (key == null)
+ {
+ return null;
+ }
+ return GetFromObjectEntry(key.GetHashCode(), key);
+ }
+
+ public virtual object Get(long key)
+ {
+ return GetFromLongEntry((int)key, key);
+ }
+
+ public virtual bool ContainsKey(object key)
+ {
+ if (null == key)
+ {
+ return false;
+ }
+ return null != GetObjectEntry(key.GetHashCode(), key);
+ }
+
+ public virtual bool ContainsAllKeys(IEnumerable collection)
+ {
+ return ContainsAllKeys(collection.GetEnumerator());
+ }
+
+ public virtual bool ContainsAllKeys(IEnumerator iterator)
+ {
+ while (iterator.MoveNext())
+ {
+ if (!ContainsKey(iterator.Current))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public virtual void Put(byte[] key, object value)
+ {
+ PutEntry(new HashtableByteArrayEntry(key, value));
+ }
+
+ public virtual void Put(int key, object value)
+ {
+ PutEntry(new HashtableIntEntry(key, value));
+ }
+
+ public virtual void Put(long key, object value)
+ {
+ PutEntry(new HashtableLongEntry(key, value));
+ }
+
+ public virtual void Put(object key, object value)
+ {
+ if (null == key)
+ {
+ throw new ArgumentNullException();
+ }
+ PutEntry(new HashtableObjectEntry(key, value));
+ }
+
+ public virtual object Remove(object objectKey)
+ {
+ int intKey = objectKey.GetHashCode();
+ return RemoveObjectEntry(intKey, objectKey);
+ }
+
+ public virtual object Remove(long longKey)
+ {
+ return RemoveLongEntry((int)longKey, longKey);
+ }
+
+ public virtual object Remove(byte[] key)
+ {
+ int intKey = HashtableByteArrayEntry.Hash(key);
+ return RemoveObjectEntry(intKey, key);
+ }
+
+ public virtual object Remove(int key)
+ {
+ return RemoveIntEntry(key);
+ }
+
+ ///
+ /// Iterates through all the
+ /// entries
+ /// .
+ ///
+ ///
+ ///
+ /// IEntry4
+ /// iterator
+ ///
+ /// HashtableBase.Values()
+ ///
+ /// #see
+ /// HashtableBase.ValuesIterator()
+ ///
+ public virtual IEnumerator Iterator()
+ {
+ return HashtableIterator();
+ }
+
+ protected virtual Db4objects.Db4o.Foundation.Hashtable4 DeepCloneInternal(Db4objects.Db4o.Foundation.Hashtable4
+ ret, object obj)
+ {
+ ret._mask = _mask;
+ ret._maximumSize = _maximumSize;
+ ret._size = _size;
+ ret._tableSize = _tableSize;
+ ret._table = new HashtableIntEntry[_tableSize];
+ for (int i = 0; i < _tableSize; i++)
+ {
+ if (_table[i] != null)
+ {
+ ret._table[i] = (HashtableIntEntry)_table[i].DeepClone(obj);
+ }
+ }
+ return ret;
+ }
+
+ private object GetFromObjectEntry(int intKey, object objectKey)
+ {
+ HashtableObjectEntry entry = GetObjectEntry(intKey, objectKey);
+ return entry == null ? null : entry._object;
+ }
+
+ private HashtableObjectEntry GetObjectEntry(int intKey, object objectKey)
+ {
+ HashtableObjectEntry entry = (HashtableObjectEntry)_table[intKey & _mask];
+ while (entry != null)
+ {
+ if (entry._key == intKey && entry.HasKey(objectKey))
+ {
+ return entry;
+ }
+ entry = (HashtableObjectEntry)entry._next;
+ }
+ return null;
+ }
+
+ private object GetFromLongEntry(int intKey, long longKey)
+ {
+ HashtableLongEntry entry = GetLongEntry(intKey, longKey);
+ return entry == null ? null : entry._object;
+ }
+
+ private HashtableLongEntry GetLongEntry(int intKey, long longKey)
+ {
+ HashtableLongEntry entry = (HashtableLongEntry)_table[intKey & _mask];
+ while (entry != null)
+ {
+ if (entry._key == intKey && entry._longKey == longKey)
+ {
+ return entry;
+ }
+ entry = (HashtableLongEntry)entry._next;
+ }
+ return null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,284 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class HashtableBase
+ {
+ private const float Fill = 0.5F;
+
+ public int _tableSize;
+
+ public int _mask;
+
+ public int _maximumSize;
+
+ public int _size;
+
+ public HashtableIntEntry[] _table;
+
+ public HashtableBase(int size)
+ {
+ // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1
+ size = NewSize(size);
+ // legacy for .NET conversion
+ _tableSize = 1;
+ while (_tableSize < size)
+ {
+ _tableSize = _tableSize << 1;
+ }
+ _mask = _tableSize - 1;
+ _maximumSize = (int)(_tableSize * Fill);
+ _table = new HashtableIntEntry[_tableSize];
+ }
+
+ public HashtableBase() : this(1)
+ {
+ }
+
+ ///
+ protected HashtableBase(IDeepClone cloneOnlyCtor)
+ {
+ }
+
+ public virtual void Clear()
+ {
+ _size = 0;
+ Arrays4.Fill(_table, null);
+ }
+
+ private int NewSize(int size)
+ {
+ return (int)(size / Fill);
+ }
+
+ public virtual int Size()
+ {
+ return _size;
+ }
+
+ protected virtual HashtableIntEntry FindWithSameKey(HashtableIntEntry newEntry)
+ {
+ HashtableIntEntry existing = _table[EntryIndex(newEntry)];
+ while (null != existing)
+ {
+ if (existing.SameKeyAs(newEntry))
+ {
+ return existing;
+ }
+ existing = existing._next;
+ }
+ return null;
+ }
+
+ protected virtual int EntryIndex(HashtableIntEntry entry)
+ {
+ return entry._key & _mask;
+ }
+
+ protected virtual void PutEntry(HashtableIntEntry newEntry)
+ {
+ HashtableIntEntry existing = FindWithSameKey(newEntry);
+ if (null != existing)
+ {
+ Replace(existing, newEntry);
+ }
+ else
+ {
+ Insert(newEntry);
+ }
+ }
+
+ private void Insert(HashtableIntEntry newEntry)
+ {
+ _size++;
+ if (_size > _maximumSize)
+ {
+ IncreaseSize();
+ }
+ int index = EntryIndex(newEntry);
+ newEntry._next = _table[index];
+ _table[index] = newEntry;
+ }
+
+ private void Replace(HashtableIntEntry existing, HashtableIntEntry newEntry)
+ {
+ newEntry._next = existing._next;
+ HashtableIntEntry entry = _table[EntryIndex(existing)];
+ if (entry == existing)
+ {
+ _table[EntryIndex(existing)] = newEntry;
+ }
+ else
+ {
+ while (entry._next != existing)
+ {
+ entry = entry._next;
+ }
+ entry._next = newEntry;
+ }
+ }
+
+ private void IncreaseSize()
+ {
+ _tableSize = _tableSize << 1;
+ _maximumSize = _maximumSize << 1;
+ _mask = _tableSize - 1;
+ HashtableIntEntry[] temp = _table;
+ _table = new HashtableIntEntry[_tableSize];
+ for (int i = 0; i < temp.Length; i++)
+ {
+ Reposition(temp[i]);
+ }
+ }
+
+ protected virtual Db4objects.Db4o.Foundation.HashtableIterator HashtableIterator(
+ )
+ {
+ return new Db4objects.Db4o.Foundation.HashtableIterator(_table);
+ }
+
+ private void Reposition(HashtableIntEntry entry)
+ {
+ HashtableIntEntry currentEntry = entry;
+ HashtableIntEntry nextEntry = null;
+ while (currentEntry != null)
+ {
+ nextEntry = currentEntry._next;
+ currentEntry._next = _table[EntryIndex(currentEntry)];
+ _table[EntryIndex(currentEntry)] = currentEntry;
+ currentEntry = nextEntry;
+ }
+ }
+
+ public virtual IEnumerator Keys()
+ {
+ return Iterators.Map(HashtableIterator(), new _IFunction4_133());
+ }
+
+ private sealed class _IFunction4_133 : IFunction4
+ {
+ public _IFunction4_133()
+ {
+ }
+
+ public object Apply(object current)
+ {
+ return ((IEntry4)current).Key();
+ }
+ }
+
+ public virtual IEnumerable Values()
+ {
+ return new _IEnumerable_141(this);
+ }
+
+ private sealed class _IEnumerable_141 : IEnumerable
+ {
+ public _IEnumerable_141(HashtableBase _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return this._enclosing.ValuesIterator();
+ }
+
+ private readonly HashtableBase _enclosing;
+ }
+
+ /// Iterates through all the values.
+ /// Iterates through all the values.
+ /// value iterator
+ public virtual IEnumerator ValuesIterator()
+ {
+ return Iterators.Map(HashtableIterator(), new _IFunction4_154());
+ }
+
+ private sealed class _IFunction4_154 : IFunction4
+ {
+ public _IFunction4_154()
+ {
+ }
+
+ public object Apply(object current)
+ {
+ return ((IEntry4)current).Value();
+ }
+ }
+
+ public override string ToString()
+ {
+ return Iterators.Join(HashtableIterator(), "{", "}", ", ");
+ }
+
+ protected virtual void RemoveEntry(HashtableIntEntry predecessor, HashtableIntEntry
+ entry)
+ {
+ if (predecessor != null)
+ {
+ predecessor._next = entry._next;
+ }
+ else
+ {
+ _table[EntryIndex(entry)] = entry._next;
+ }
+ _size--;
+ }
+
+ protected virtual object RemoveObjectEntry(int intKey, object objectKey)
+ {
+ HashtableObjectEntry entry = (HashtableObjectEntry)_table[intKey & _mask];
+ HashtableObjectEntry predecessor = null;
+ while (entry != null)
+ {
+ if (entry._key == intKey && entry.HasKey(objectKey))
+ {
+ RemoveEntry(predecessor, entry);
+ return entry._object;
+ }
+ predecessor = entry;
+ entry = (HashtableObjectEntry)entry._next;
+ }
+ return null;
+ }
+
+ protected virtual object RemoveLongEntry(int intKey, long longKey)
+ {
+ HashtableLongEntry entry = (HashtableLongEntry)_table[intKey & _mask];
+ HashtableLongEntry predecessor = null;
+ while (entry != null)
+ {
+ if (entry._key == intKey && entry._longKey == longKey)
+ {
+ RemoveEntry(predecessor, entry);
+ return entry._object;
+ }
+ predecessor = entry;
+ entry = (HashtableLongEntry)entry._next;
+ }
+ return null;
+ }
+
+ protected virtual object RemoveIntEntry(int key)
+ {
+ HashtableIntEntry entry = _table[key & _mask];
+ HashtableIntEntry predecessor = null;
+ while (entry != null)
+ {
+ if (entry._key == key)
+ {
+ RemoveEntry(predecessor, entry);
+ return entry._object;
+ }
+ predecessor = entry;
+ entry = entry._next;
+ }
+ return null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,59 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ internal class HashtableByteArrayEntry : HashtableObjectEntry
+ {
+ public HashtableByteArrayEntry(byte[] bytes, object value) : base(Hash(bytes), bytes
+ , value)
+ {
+ }
+
+ public HashtableByteArrayEntry() : base()
+ {
+ }
+
+ public override object DeepClone(object obj)
+ {
+ return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableByteArrayEntry()
+ , obj);
+ }
+
+ public override bool HasKey(object key)
+ {
+ if (key is byte[])
+ {
+ return AreEqual((byte[])Key(), (byte[])key);
+ }
+ return false;
+ }
+
+ internal static int Hash(byte[] bytes)
+ {
+ int ret = 0;
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ ret = ret * 31 + bytes[i];
+ }
+ return ret;
+ }
+
+ internal static bool AreEqual(byte[] lhs, byte[] rhs)
+ {
+ if (rhs.Length != lhs.Length)
+ {
+ return false;
+ }
+ for (int i = 0; i < rhs.Length; i++)
+ {
+ if (rhs[i] != lhs[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class HashtableIdentityEntry : HashtableIntEntry
+ {
+ public HashtableIdentityEntry(object obj) : base(Runtime.IdentityHashCode(obj), obj
+ )
+ {
+ }
+
+ public override bool SameKeyAs(HashtableIntEntry other)
+ {
+ if (!base.SameKeyAs(other))
+ {
+ return false;
+ }
+ return other._object == _object;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class HashtableIntEntry : IEntry4, IDeepClone
+ {
+ public int _key;
+
+ public object _object;
+
+ public Db4objects.Db4o.Foundation.HashtableIntEntry _next;
+
+ internal HashtableIntEntry(int key, object obj)
+ {
+ // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1
+ _key = key;
+ _object = obj;
+ }
+
+ public HashtableIntEntry()
+ {
+ }
+
+ public virtual object Key()
+ {
+ return _key;
+ }
+
+ public virtual object Value()
+ {
+ return _object;
+ }
+
+ public virtual object DeepClone(object obj)
+ {
+ return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableIntEntry(), obj);
+ }
+
+ public virtual bool SameKeyAs(Db4objects.Db4o.Foundation.HashtableIntEntry other)
+ {
+ return _key == other._key;
+ }
+
+ protected virtual Db4objects.Db4o.Foundation.HashtableIntEntry DeepCloneInternal(
+ Db4objects.Db4o.Foundation.HashtableIntEntry entry, object obj)
+ {
+ entry._key = _key;
+ entry._next = _next;
+ if (_object is IDeepClone)
+ {
+ entry._object = ((IDeepClone)_object).DeepClone(obj);
+ }
+ else
+ {
+ entry._object = _object;
+ }
+ if (_next != null)
+ {
+ entry._next = (Db4objects.Db4o.Foundation.HashtableIntEntry)_next.DeepClone(obj);
+ }
+ return entry;
+ }
+
+ public override string ToString()
+ {
+ return string.Empty + _key + ": " + _object;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,83 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class HashtableIterator : IEnumerator
+ {
+ private readonly HashtableIntEntry[] _table;
+
+ private HashtableIntEntry _currentEntry;
+
+ private int _currentIndex;
+
+ public HashtableIterator(HashtableIntEntry[] table)
+ {
+ _table = table;
+ Reset();
+ }
+
+ private void CheckInvalidTable()
+ {
+ if (_table == null || _table.Length == 0)
+ {
+ PositionBeyondLast();
+ }
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ if (_currentEntry == null)
+ {
+ throw new InvalidOperationException();
+ }
+ return _currentEntry;
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (IsBeyondLast())
+ {
+ return false;
+ }
+ if (_currentEntry != null)
+ {
+ _currentEntry = _currentEntry._next;
+ }
+ while (_currentEntry == null)
+ {
+ if (_currentIndex >= _table.Length)
+ {
+ PositionBeyondLast();
+ return false;
+ }
+ _currentEntry = _table[_currentIndex++];
+ }
+ return true;
+ }
+
+ public virtual void Reset()
+ {
+ _currentEntry = null;
+ _currentIndex = 0;
+ CheckInvalidTable();
+ }
+
+ private bool IsBeyondLast()
+ {
+ return _currentIndex == -1;
+ }
+
+ private void PositionBeyondLast()
+ {
+ _currentIndex = -1;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,51 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class HashtableLongEntry : HashtableIntEntry
+ {
+ public long _longKey;
+
+ internal HashtableLongEntry(long key, object obj) : base((int)key, obj)
+ {
+ // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1
+ _longKey = key;
+ }
+
+ public HashtableLongEntry() : base()
+ {
+ }
+
+ public override object Key()
+ {
+ return _longKey;
+ }
+
+ public override object DeepClone(object obj)
+ {
+ return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableLongEntry(), obj
+ );
+ }
+
+ protected override HashtableIntEntry DeepCloneInternal(HashtableIntEntry entry, object
+ obj)
+ {
+ ((Db4objects.Db4o.Foundation.HashtableLongEntry)entry)._longKey = _longKey;
+ return base.DeepCloneInternal(entry, obj);
+ }
+
+ public override bool SameKeyAs(HashtableIntEntry other)
+ {
+ return other is Db4objects.Db4o.Foundation.HashtableLongEntry ? ((Db4objects.Db4o.Foundation.HashtableLongEntry
+ )other)._longKey == _longKey : false;
+ }
+
+ public override string ToString()
+ {
+ return string.Empty + _longKey + ": " + _object;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,63 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class HashtableObjectEntry : HashtableIntEntry
+ {
+ public object _objectKey;
+
+ internal HashtableObjectEntry(int a_hash, object a_key, object a_object) : base(a_hash
+ , a_object)
+ {
+ // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1
+ _objectKey = a_key;
+ }
+
+ internal HashtableObjectEntry(object a_key, object a_object) : base(a_key.GetHashCode
+ (), a_object)
+ {
+ _objectKey = a_key;
+ }
+
+ public HashtableObjectEntry() : base()
+ {
+ }
+
+ public override object Key()
+ {
+ return _objectKey;
+ }
+
+ public override object DeepClone(object obj)
+ {
+ return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableObjectEntry(), obj
+ );
+ }
+
+ protected override HashtableIntEntry DeepCloneInternal(HashtableIntEntry entry, object
+ obj)
+ {
+ ((Db4objects.Db4o.Foundation.HashtableObjectEntry)entry)._objectKey = _objectKey;
+ return base.DeepCloneInternal(entry, obj);
+ }
+
+ public virtual bool HasKey(object key)
+ {
+ return _objectKey.Equals(key);
+ }
+
+ public override bool SameKeyAs(HashtableIntEntry other)
+ {
+ return other is Db4objects.Db4o.Foundation.HashtableObjectEntry ? HasKey(((Db4objects.Db4o.Foundation.HashtableObjectEntry
+ )other)._objectKey) : false;
+ }
+
+ public override string ToString()
+ {
+ return string.Empty + _objectKey + ": " + _object;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,9 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IArrayFactory
+ {
+ object[] NewArray(int size);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,9 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IBlock4
+ {
+ void Run();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,57 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IBlockingQueue4 : IQueue4
+ {
+ ///
+ ///
+ /// Returns the next queued item or waits for it to be available for the
+ /// maximum of timeout
miliseconds.
+ ///
+ ///
+ ///
+ /// Returns the next queued item or waits for it to be available for the
+ /// maximum of timeout
miliseconds.
+ ///
+ /// maximum time to wait for the next avilable item in miliseconds
+ ///
+ ///
+ /// the next item or null
if timeout
is
+ /// reached
+ ///
+ ///
+ /// if the
+ /// Stop()
+ /// is called.
+ ///
+ ///
+ object Next(long timeout);
+
+ void Stop();
+
+ ///
+ ///
+ /// Removes all the available elements in the queue to the colletion passed
+ /// as argument.
+ ///
+ ///
+ ///
+ /// Removes all the available elements in the queue to the colletion passed
+ /// as argument.
+ ///
+ /// It will block until at least one element is available.
+ ///
+ ///
+ /// the number of elements added to the list.
+ ///
+ /// if the
+ /// Stop()
+ /// is called.
+ ///
+ ///
+ int DrainTo(Collection4 list);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface ICancellableVisitor4
+ {
+ /// true to continue traversal, false otherwise
+ bool Visit(object obj);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,9 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IClosure4
+ {
+ object Run();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,15 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IComparison4
+ {
+ ///
+ /// Returns negative number if x < y
+ /// Returns zero if x == y
+ /// Returns positive number if x > y
+ ///
+ int Compare(object x, object y);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Deep clone
+ ///
+ public interface IDeepClone
+ {
+ ///
+ /// The parameter allows passing one new object so parent
+ /// references can be corrected on children.
+ ///
+ ///
+ /// The parameter allows passing one new object so parent
+ /// references can be corrected on children.
+ ///
+ object DeepClone(object context);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class IdentityHashtable4 : HashtableBase, IMap4
+ {
+ public IdentityHashtable4()
+ {
+ }
+
+ public IdentityHashtable4(int size) : base(size)
+ {
+ }
+
+ public virtual bool Contains(object obj)
+ {
+ return GetEntry(obj) != null;
+ }
+
+ public virtual object Remove(object obj)
+ {
+ if (null == obj)
+ {
+ throw new ArgumentNullException();
+ }
+ return RemoveIntEntry(Runtime.IdentityHashCode(obj));
+ }
+
+ public virtual bool ContainsKey(object key)
+ {
+ return GetEntry(key) != null;
+ }
+
+ public virtual object Get(object key)
+ {
+ HashtableIntEntry entry = GetEntry(key);
+ return (entry == null ? null : entry._object);
+ }
+
+ private HashtableIntEntry GetEntry(object key)
+ {
+ return FindWithSameKey(new IdentityHashtable4.IdentityEntry(key));
+ }
+
+ public virtual void Put(object key, object value)
+ {
+ if (null == key)
+ {
+ throw new ArgumentNullException();
+ }
+ PutEntry(new IdentityHashtable4.IdentityEntry(key, value));
+ }
+
+ public class IdentityEntry : HashtableObjectEntry
+ {
+ public IdentityEntry(object obj) : this(obj, null)
+ {
+ }
+
+ public IdentityEntry(object key, object value) : base(Runtime.IdentityHashCode(key
+ ), key, value)
+ {
+ }
+
+ public override bool HasKey(object key)
+ {
+ return _objectKey == key;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,49 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class IdentitySet4 : HashtableBase, IEnumerable
+ {
+ public IdentitySet4()
+ {
+ }
+
+ public IdentitySet4(int size) : base(size)
+ {
+ }
+
+ public virtual bool Contains(object obj)
+ {
+ return FindWithSameKey(new HashtableIdentityEntry(obj)) != null;
+ }
+
+ public virtual void Add(object obj)
+ {
+ if (null == obj)
+ {
+ throw new ArgumentNullException();
+ }
+ PutEntry(new HashtableIdentityEntry(obj));
+ }
+
+ public virtual void Remove(object obj)
+ {
+ if (null == obj)
+ {
+ throw new ArgumentNullException();
+ }
+ RemoveIntEntry(Runtime.IdentityHashCode(obj));
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return ValuesIterator();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,12 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IEntry4
+ {
+ object Key();
+
+ object Value();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IEnvironment
+ {
+ object Provide(Type service);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IFixedSizeIntIterator4 : IIntIterator4
+ {
+ int Size();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IFunction4
+ {
+ object Apply(object arg);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,16 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ /// Non boxing/unboxing version of
+ /// System.Collections.IComparer<T>
+ ///
+ /// for
+ /// faster id comparisons.
+ ///
+ public interface IIntComparator
+ {
+ int Compare(int x, int y);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,12 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IIntIterator4 : IEnumerator
+ {
+ int CurrentInt();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IIntObjectVisitor
+ {
+ void Visit(int anInt, object anObject);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IListener4
+ {
+ void OnEvent(object @event);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,24 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IMap4
+ {
+ int Size();
+
+ object Get(object key);
+
+ void Put(object key, object value);
+
+ bool ContainsKey(object key);
+
+ object Remove(object key);
+
+ IEnumerable Values();
+
+ void Clear();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,61 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ /// Basic functionality for implementing iterators for
+ /// fixed length structures whose elements can be efficiently
+ /// accessed by a numeric index.
+ ///
+ ///
+ /// Basic functionality for implementing iterators for
+ /// fixed length structures whose elements can be efficiently
+ /// accessed by a numeric index.
+ ///
+ public abstract class IndexedIterator : IEnumerator
+ {
+ private readonly int _length;
+
+ private int _next;
+
+ public IndexedIterator(int length)
+ {
+ _length = length;
+ _next = -1;
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (_next < LastIndex())
+ {
+ ++_next;
+ return true;
+ }
+ // force exception on unexpected call to current
+ _next = _length;
+ return false;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ return Get(_next);
+ }
+ }
+
+ public virtual void Reset()
+ {
+ _next = -1;
+ }
+
+ protected abstract object Get(int index);
+
+ private int LastIndex()
+ {
+ return _length - 1;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class IntArrayByRef
+ {
+ public int[] value;
+
+ public IntArrayByRef(int[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ public IntArrayByRef()
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,106 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class IntArrayList : IEnumerable
+ {
+ protected int[] i_content;
+
+ private int i_count;
+
+ public IntArrayList() : this(10)
+ {
+ }
+
+ public IntArrayList(int initialSize)
+ {
+ i_content = new int[initialSize];
+ }
+
+ public virtual void Add(int a_value)
+ {
+ EnsureCapacity();
+ i_content[i_count++] = a_value;
+ }
+
+ public virtual void Add(int index, int a_value)
+ {
+ EnsureCapacity();
+ System.Array.Copy(i_content, index, i_content, index + 1, i_count - index);
+ i_content[index] = a_value;
+ i_count++;
+ }
+
+ private void EnsureCapacity()
+ {
+ if (i_count >= i_content.Length)
+ {
+ int inc = i_content.Length / 2;
+ if (inc < 10)
+ {
+ inc = 10;
+ }
+ int[] temp = new int[i_content.Length + inc];
+ System.Array.Copy(i_content, 0, temp, 0, i_content.Length);
+ i_content = temp;
+ }
+ }
+
+ public virtual int IndexOf(int a_value)
+ {
+ for (int i = 0; i < i_count; i++)
+ {
+ if (i_content[i] == a_value)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public virtual int Size()
+ {
+ return i_count;
+ }
+
+ public virtual long[] AsLong()
+ {
+ long[] longs = new long[i_count];
+ for (int i = 0; i < i_count; i++)
+ {
+ longs[i] = i_content[i];
+ }
+ return longs;
+ }
+
+ public virtual IIntIterator4 IntIterator()
+ {
+ return IntIterators.ForInts(i_content, i_count);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return IntIterator();
+ }
+
+ public virtual int Get(int index)
+ {
+ return i_content[index];
+ }
+
+ public virtual void Swap(int left, int right)
+ {
+ if (left != right)
+ {
+ int swap = i_content[left];
+ i_content[left] = i_content[right];
+ i_content[right] = swap;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Useful as "out" or "by ref" function parameter.
+ /// Useful as "out" or "by ref" function parameter.
+ public sealed class IntByRef
+ {
+ public int value;
+
+ public IntByRef(int initialValue)
+ {
+ value = initialValue;
+ }
+
+ public IntByRef()
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class IntIdGenerator
+ {
+ private int _current = 1;
+
+ public virtual int Next()
+ {
+ _current++;
+ if (_current < 0)
+ {
+ _current = 1;
+ }
+ return _current;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,45 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class IntIterator4Adaptor : IIntIterator4
+ {
+ private readonly IEnumerator _iterator;
+
+ public IntIterator4Adaptor(IEnumerator iterator)
+ {
+ _iterator = iterator;
+ }
+
+ public IntIterator4Adaptor(IEnumerable iterable) : this(iterable.GetEnumerator())
+ {
+ }
+
+ public virtual int CurrentInt()
+ {
+ return ((int)Current);
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ return _iterator.Current;
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ return _iterator.MoveNext();
+ }
+
+ public virtual void Reset()
+ {
+ _iterator.Reset();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,62 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class IntIterator4Impl : IFixedSizeIntIterator4
+ {
+ private readonly int _count;
+
+ private int[] _content;
+
+ private int _current;
+
+ public IntIterator4Impl(int[] content, int count)
+ {
+ _content = content;
+ _count = count;
+ Reset();
+ }
+
+ public virtual int CurrentInt()
+ {
+ if (_content == null || _current == _count)
+ {
+ throw new InvalidOperationException();
+ }
+ return _content[_current];
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ return CurrentInt();
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (_current < _count - 1)
+ {
+ _current++;
+ return true;
+ }
+ _content = null;
+ return false;
+ }
+
+ public virtual void Reset()
+ {
+ _current = -1;
+ }
+
+ public virtual int Size()
+ {
+ return _count;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,64 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class IntIterators
+ {
+ public static IFixedSizeIntIterator4 ForInts(int[] array, int count)
+ {
+ return new IntIterator4Impl(array, count);
+ }
+
+ public static IIntIterator4 ForLongs(long[] ids)
+ {
+ return new _IIntIterator4_10(ids);
+ }
+
+ private sealed class _IIntIterator4_10 : IIntIterator4
+ {
+ public _IIntIterator4_10(long[] ids)
+ {
+ this.ids = ids;
+ this._next = 0;
+ }
+
+ internal int _next;
+
+ internal int _current;
+
+ public int CurrentInt()
+ {
+ return this._current;
+ }
+
+ public object Current
+ {
+ get
+ {
+ return this._current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._next < ids.Length)
+ {
+ this._current = (int)ids[this._next];
+ ++this._next;
+ return true;
+ }
+ return false;
+ }
+
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ private readonly long[] ids;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,12 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ [System.Serializable]
+ public class InvalidIteratorException : InvalidOperationException
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IObjectPool
+ {
+ object BorrowObject();
+
+ void ReturnObject(object o);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IPausableBlockingQueue4 : IBlockingQueue4
+ {
+ ///
+ ///
+ /// Pauses the queue, making calls to
+ /// IQueue4.Next()
+ /// block
+ /// until
+ /// Resume()
+ /// is called.
+ ///
+ /// whether or not this call changed the state of the queue.
+ bool Pause();
+
+ ///
+ ///
+ /// Resumes the queue, releasing blocked calls to
+ /// IQueue4.Next()
+ /// that can reach a next queue item..
+ ///
+ /// whether or not this call changed the state of the queue.
+ bool Resume();
+
+ bool IsPaused();
+
+ ///
+ ///
+ /// Returns the next element in queue if there is one available, returns null
+ /// otherwise.
+ ///
+ ///
+ ///
+ /// Returns the next element in queue if there is one available, returns null
+ /// otherwise.
+ ///
+ /// This method will not never block, regardless of the queue being paused or
+ /// no elements are available.
+ ///
+ /// next element, if available and queue not paused.
+ object TryNext();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IPredicate4
+ {
+ bool Match(object candidate);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ /// a prepared comparison, to compare multiple objects
+ /// with one single object.
+ ///
+ ///
+ /// a prepared comparison, to compare multiple objects
+ /// with one single object.
+ ///
+ public interface IPreparedComparison
+ {
+ ///
+ /// return a negative int, zero or a positive int if
+ /// the object being held in 'this' is smaller, equal
+ /// or greater than the passed object.
+ /// Typical implementation: return this.object - obj;
+ ///
+ int CompareTo(object obj);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IProcedure4
+ {
+ void Apply(object value);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface IQueue4
+ {
+ void Add(object obj);
+
+ object Next();
+
+ bool HasNext();
+
+ /// Returns the next object in the queue that matches the specified condition.
+ ///
+ ///
+ /// Returns the next object in the queue that matches the specified condition.
+ /// The operation is always NON-BLOCKING.
+ ///
+ /// the object must satisfy to be returned
+ /// the object satisfying the condition or null if none does
+ object NextMatching(IPredicate4 condition);
+
+ IEnumerator Iterator();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface ISequence4 : IEnumerable
+ {
+ bool Add(object element);
+
+ void AddAll(IEnumerable iterable);
+
+ bool IsEmpty();
+
+ object Get(int index);
+
+ int Size();
+
+ void Clear();
+
+ bool Remove(object obj);
+
+ bool Contains(object obj);
+
+ bool ContainsAll(IEnumerable iter);
+
+ object[] ToArray();
+
+ object[] ToArray(object[] array);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface ISet4 : IEnumerable
+ {
+ bool Add(object obj);
+
+ void Clear();
+
+ bool Contains(object obj);
+
+ bool IsEmpty();
+
+ IEnumerator GetEnumerator();
+
+ bool Remove(object obj);
+
+ int Size();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IShallowClone
+ {
+ object ShallowClone();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,14 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface ISortable4
+ {
+ int Size();
+
+ int Compare(int leftIndex, int rightIndex);
+
+ void Swap(int leftIndex, int rightIndex);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ /// Adapts Iterable4/Iterator4 iteration model (moveNext, current) to the old db4o
+ /// and jdk model (hasNext, next).
+ ///
+ ///
+ /// Adapts Iterable4/Iterator4 iteration model (moveNext, current) to the old db4o
+ /// and jdk model (hasNext, next).
+ ///
+ ///
+ public class Iterable4Adaptor
+ {
+ private static readonly object EofMarker = new object();
+
+ private static readonly object MoveNextMarker = new object();
+
+ private readonly IEnumerable _delegate;
+
+ private IEnumerator _iterator;
+
+ private object _current = MoveNextMarker;
+
+ public Iterable4Adaptor(IEnumerable delegate_)
+ {
+ _delegate = delegate_;
+ }
+
+ public virtual bool HasNext()
+ {
+ if (_current == MoveNextMarker)
+ {
+ return MoveNext();
+ }
+ return _current != EofMarker;
+ }
+
+ public virtual object Next()
+ {
+ if (!HasNext())
+ {
+ throw new InvalidOperationException();
+ }
+ object returnValue = _current;
+ _current = MoveNextMarker;
+ return returnValue;
+ }
+
+ protected virtual bool MoveNext()
+ {
+ if (null == _iterator)
+ {
+ _iterator = _delegate.GetEnumerator();
+ }
+ if (_iterator.MoveNext())
+ {
+ _current = _iterator.Current;
+ return true;
+ }
+ _current = EofMarker;
+ return false;
+ }
+
+ public virtual void Reset()
+ {
+ _iterator = null;
+ _current = MoveNextMarker;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,55 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Iterator4Impl : IEnumerator
+ {
+ private readonly List4 _first;
+
+ private List4 _next;
+
+ private object _current;
+
+ public Iterator4Impl(List4 first)
+ {
+ _first = first;
+ _next = first;
+ _current = Iterators.NoElement;
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (_next == null)
+ {
+ _current = Iterators.NoElement;
+ return false;
+ }
+ _current = ((object)_next._element);
+ _next = ((List4)_next._next);
+ return true;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ if (Iterators.NoElement == _current)
+ {
+ throw new InvalidOperationException();
+ }
+ return (object)_current;
+ }
+ }
+
+ public virtual void Reset()
+ {
+ _next = _first;
+ _current = Iterators.NoElement;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,626 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using System.Text;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Iterator primitives (concat, map, reduce, filter, etc...).
+ /// Iterator primitives (concat, map, reduce, filter, etc...).
+ ///
+ public partial class Iterators
+ {
+ ///
+ /// Constant indicating that the current element in a
+ /// Map(IEnumerator, IFunction4)
+ /// operation
+ /// should be skipped.
+ ///
+ public static readonly object Skip = new object();
+
+ private sealed class _IEnumerator_20 : IEnumerator
+ {
+ public _IEnumerator_20()
+ {
+ }
+
+ public object Current
+ {
+ get
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public bool MoveNext()
+ {
+ return false;
+ }
+
+ public void Reset()
+ {
+ }
+ }
+
+ public static readonly IEnumerator EmptyIterator = new _IEnumerator_20();
+
+ private sealed class _IEnumerable_34 : IEnumerable
+ {
+ public _IEnumerable_34()
+ {
+ }
+
+ // do nothing
+ public IEnumerator GetEnumerator()
+ {
+ return Iterators.EmptyIterator;
+ }
+ }
+
+ public static readonly IEnumerable EmptyIterable = new _IEnumerable_34();
+
+ internal static readonly object NoElement = new object();
+
+ ///
+ /// Generates
+ /// Tuple
+ /// items with indexes starting at 0.
+ ///
+ /// the iterable to be enumerated
+ public static IEnumerable Enumerate(IEnumerable iterable)
+ {
+ return new _IEnumerable_48(iterable);
+ }
+
+ private sealed class _IEnumerable_48 : IEnumerable
+ {
+ public _IEnumerable_48(IEnumerable iterable)
+ {
+ this.iterable = iterable;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return new EnumerateIterator(iterable.GetEnumerator());
+ }
+
+ private readonly IEnumerable iterable;
+ }
+
+ public static bool Any(IEnumerator iterator, IPredicate4 condition)
+ {
+ while (iterator.MoveNext())
+ {
+ if (condition.Match(iterator.Current))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static IEnumerator Concat(IEnumerator[] array)
+ {
+ return Concat(Iterate((object[])array));
+ }
+
+ public static IEnumerator Concat(IEnumerator iterators)
+ {
+ return new CompositeIterator4(iterators);
+ }
+
+ public static IEnumerable Concat(IEnumerable[] iterables)
+ {
+ return Concat(Iterable(iterables));
+ }
+
+ public static IEnumerable Concat(IEnumerable iterables)
+ {
+ return new CompositeIterable4(iterables);
+ }
+
+ public static IEnumerator Concat(IEnumerator first, IEnumerator second)
+ {
+ return Concat(new IEnumerator[] { first, second });
+ }
+
+ public static IEnumerable ConcatMap(IEnumerable iterable, IFunction4 function)
+ {
+ return Concat(Map(iterable, function));
+ }
+
+ ///
+ /// Returns a new iterator which yields the result of applying the function
+ /// to every element in the original iterator.
+ ///
+ ///
+ /// Returns a new iterator which yields the result of applying the function
+ /// to every element in the original iterator.
+ /// Skip
+ /// can be returned from function to indicate the current
+ /// element should be skipped.
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerator Map(IEnumerator iterator, IFunction4 function)
+ {
+ return new FunctionApplicationIterator(iterator, function);
+ }
+
+ public static IEnumerator Map(object[] array, IFunction4 function)
+ {
+ return Map(new ArrayIterator4(array), function);
+ }
+
+ public static IEnumerator Filter(object[] array, IPredicate4 predicate)
+ {
+ return Filter(new ArrayIterator4(array), predicate);
+ }
+
+ public static IEnumerable Filter(IEnumerable source, IPredicate4 predicate)
+ {
+ return new _IEnumerable_112(source, predicate);
+ }
+
+ private sealed class _IEnumerable_112 : IEnumerable
+ {
+ public _IEnumerable_112(IEnumerable source, IPredicate4 predicate)
+ {
+ this.source = source;
+ this.predicate = predicate;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return Iterators.Filter(source.GetEnumerator(), predicate);
+ }
+
+ private readonly IEnumerable source;
+
+ private readonly IPredicate4 predicate;
+ }
+
+ public static IEnumerator Filter(IEnumerator iterator, IPredicate4 predicate)
+ {
+ return new FilteredIterator(iterator, predicate);
+ }
+
+ public static IEnumerable SingletonIterable(object element)
+ {
+ return new _IEnumerable_124(element);
+ }
+
+ private sealed class _IEnumerable_124 : IEnumerable
+ {
+ public _IEnumerable_124(object element)
+ {
+ this.element = element;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return Iterators.SingletonIterator(element);
+ }
+
+ private readonly object element;
+ }
+
+ public static IEnumerable Append(IEnumerable front, object last)
+ {
+ return Concat(Iterable(new object[] { front, SingletonIterable(last) }));
+ }
+
+ public static IEnumerator Iterator(IEnumerable iterable)
+ {
+ return iterable.GetEnumerator();
+ }
+
+ public static IEnumerator Iterate(object[] array)
+ {
+ return new ArrayIterator4(array);
+ }
+
+ public static IEnumerator Revert(IEnumerator iterator)
+ {
+ iterator.Reset();
+ List4 tail = null;
+ while (iterator.MoveNext())
+ {
+ tail = new List4(tail, iterator.Current);
+ }
+ return Iterate(tail);
+ }
+
+ public static IEnumerator Iterate(List4 list)
+ {
+ if (list == null)
+ {
+ return EmptyIterator;
+ }
+ Collection4 collection = new Collection4();
+ while (list != null)
+ {
+ collection.Add(list._element);
+ list = ((List4)list._next);
+ }
+ return collection.GetEnumerator();
+ }
+
+ public static int Size(IEnumerable iterable)
+ {
+ return Size(iterable.GetEnumerator());
+ }
+
+ public static object Next(IEnumerator iterator)
+ {
+ if (!iterator.MoveNext())
+ {
+ throw new InvalidOperationException();
+ }
+ return iterator.Current;
+ }
+
+ public static int Size(IEnumerator iterator)
+ {
+ int count = 0;
+ while (iterator.MoveNext())
+ {
+ ++count;
+ }
+ return count;
+ }
+
+ public static string ToString(IEnumerable i)
+ {
+ return ToString(i.GetEnumerator());
+ }
+
+ public static string ToString(IEnumerator i)
+ {
+ return Join(i, "[", "]", ", ");
+ }
+
+ public static string Join(IEnumerable i, string separator)
+ {
+ return Join(i.GetEnumerator(), separator);
+ }
+
+ public static string Join(IEnumerator i, string separator)
+ {
+ return Join(i, string.Empty, string.Empty, separator);
+ }
+
+ public static string Join(IEnumerator i, string prefix, string suffix, string separator
+ )
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(prefix);
+ if (i.MoveNext())
+ {
+ sb.Append(i.Current);
+ while (i.MoveNext())
+ {
+ sb.Append(separator);
+ sb.Append(i.Current);
+ }
+ }
+ sb.Append(suffix);
+ return sb.ToString();
+ }
+
+ public static object[] ToArray(IEnumerator tests)
+ {
+ return ToArray(tests, new _IArrayFactory_230());
+ }
+
+ private sealed class _IArrayFactory_230 : IArrayFactory
+ {
+ public _IArrayFactory_230()
+ {
+ }
+
+ public object[] NewArray(int size)
+ {
+ return new object[size];
+ }
+ }
+
+ public static object[] ToArray(IEnumerator tests, IArrayFactory factory)
+ {
+ Collection4 elements = new Collection4(tests);
+ return elements.ToArray(factory.NewArray(elements.Size()));
+ }
+
+ /// Yields a flat sequence of elements.
+ ///
+ /// Yields a flat sequence of elements. Any
+ /// IEnumerable
+ /// or
+ /// IEnumerator
+ /// found in the original sequence is recursively flattened.
+ ///
+ /// original sequence
+ public static IEnumerator Flatten(IEnumerator iterator)
+ {
+ return new FlatteningIterator(iterator);
+ }
+
+ public static IEnumerable Map(IEnumerable iterable, IFunction4 function)
+ {
+ return new _IEnumerable_253(iterable, function);
+ }
+
+ private sealed class _IEnumerable_253 : IEnumerable
+ {
+ public _IEnumerable_253(IEnumerable iterable, IFunction4 function)
+ {
+ this.iterable = iterable;
+ this.function = function;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return Iterators.Map(iterable.GetEnumerator(), function);
+ }
+
+ private readonly IEnumerable iterable;
+
+ private readonly IFunction4 function;
+ }
+
+ public static IEnumerable CrossProduct(IEnumerable iterables)
+ {
+ return CrossProduct((IEnumerable[])ToArray(iterables.GetEnumerator(), new _IArrayFactory_261
+ ()));
+ }
+
+ private sealed class _IArrayFactory_261 : IArrayFactory
+ {
+ public _IArrayFactory_261()
+ {
+ }
+
+ public object[] NewArray(int size)
+ {
+ return new IEnumerable[size];
+ }
+ }
+
+ public static IEnumerable CrossProduct(IEnumerable[] iterables)
+ {
+ return CrossProduct(iterables, 0, Iterators.EmptyIterable);
+ }
+
+ private static IEnumerable CrossProduct(IEnumerable[] iterables, int level, IEnumerable
+ row)
+ {
+ if (level == iterables.Length - 1)
+ {
+ return Map(iterables[level], new _IFunction4_276(row));
+ }
+ return ConcatMap(iterables[level], new _IFunction4_284(iterables, level, row));
+ }
+
+ private sealed class _IFunction4_276 : IFunction4
+ {
+ public _IFunction4_276(IEnumerable row)
+ {
+ this.row = row;
+ }
+
+ public object Apply(object arg)
+ {
+ return Iterators.Append(row, arg);
+ }
+
+ private readonly IEnumerable row;
+ }
+
+ private sealed class _IFunction4_284 : IFunction4
+ {
+ public _IFunction4_284(IEnumerable[] iterables, int level, IEnumerable row)
+ {
+ this.iterables = iterables;
+ this.level = level;
+ this.row = row;
+ }
+
+ public object Apply(object arg)
+ {
+ return Iterators.CrossProduct(iterables, level + 1, Iterators.Append(row, arg));
+ }
+
+ private readonly IEnumerable[] iterables;
+
+ private readonly int level;
+
+ private readonly IEnumerable row;
+ }
+
+ public static IEnumerable Iterable(object[] objects)
+ {
+ return new _IEnumerable_292(objects);
+ }
+
+ private sealed class _IEnumerable_292 : IEnumerable
+ {
+ public _IEnumerable_292(object[] objects)
+ {
+ this.objects = objects;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return Iterators.Iterate(objects);
+ }
+
+ private readonly object[] objects;
+ }
+
+ public static IEnumerator SingletonIterator(object element)
+ {
+ return new SingleValueIterator(element);
+ }
+
+ public static IEnumerable Iterable(IEnumerator iterator)
+ {
+ return new _IEnumerable_304(iterator);
+ }
+
+ private sealed class _IEnumerable_304 : IEnumerable
+ {
+ public _IEnumerable_304(IEnumerator iterator)
+ {
+ this.iterator = iterator;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return iterator;
+ }
+
+ private readonly IEnumerator iterator;
+ }
+
+ public static IEnumerator Copy(IEnumerator iterator)
+ {
+ return new Collection4(iterator).GetEnumerator();
+ }
+
+ public static IEnumerator Take(int count, IEnumerator iterator)
+ {
+ return new _IEnumerator_316(count, iterator);
+ }
+
+ private sealed class _IEnumerator_316 : IEnumerator
+ {
+ public _IEnumerator_316(int count, IEnumerator iterator)
+ {
+ this.count = count;
+ this.iterator = iterator;
+ this._taken = 0;
+ }
+
+ private int _taken;
+
+ public object Current
+ {
+ get
+ {
+ if (this._taken > count)
+ {
+ throw new InvalidOperationException();
+ }
+ return iterator.Current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._taken < count)
+ {
+ if (!iterator.MoveNext())
+ {
+ this._taken = count;
+ return false;
+ }
+ ++this._taken;
+ return true;
+ }
+ return false;
+ }
+
+ public void Reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ private readonly int count;
+
+ private readonly IEnumerator iterator;
+ }
+
+ public static IEnumerator Range(int fromInclusive, int toExclusive)
+ {
+ if (toExclusive < fromInclusive)
+ {
+ throw new ArgumentException();
+ }
+ return Take(toExclusive - fromInclusive, Series(fromInclusive - 1, new _IFunction4_350
+ ()).GetEnumerator());
+ }
+
+ private sealed class _IFunction4_350 : IFunction4
+ {
+ public _IFunction4_350()
+ {
+ }
+
+ public object Apply(object i)
+ {
+ return (((int)i)) + 1;
+ }
+ }
+
+ public static IEnumerable Series(object seed, IFunction4 function)
+ {
+ return new _IEnumerable_356(seed, function);
+ }
+
+ private sealed class _IEnumerable_356 : IEnumerable
+ {
+ public _IEnumerable_356(object seed, IFunction4 function)
+ {
+ this.seed = seed;
+ this.function = function;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return new _IEnumerator_358(seed, function);
+ }
+
+ private sealed class _IEnumerator_358 : IEnumerator
+ {
+ public _IEnumerator_358(object seed, IFunction4 function)
+ {
+ this.seed = seed;
+ this.function = function;
+ this._current = seed;
+ }
+
+ private object _current;
+
+ public object Current
+ {
+ get
+ {
+ return this._current;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ this._current = function.Apply(this._current);
+ return true;
+ }
+
+ public void Reset()
+ {
+ this._current = seed;
+ }
+
+ private readonly object seed;
+
+ private readonly IFunction4 function;
+ }
+
+ private readonly object seed;
+
+ private readonly IFunction4 function;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,13 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public interface ITimeoutBlockingQueue4 : IPausableBlockingQueue4
+ {
+ void Check();
+
+ void Reset();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,12 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IVisitable
+ {
+ void Accept(IVisitor4 visitor);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public interface IVisitor4
+ {
+ void Visit(object obj);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,46 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class KeySpec
+ {
+ public interface IDeferred
+ {
+ object Evaluate();
+ }
+
+ private object _defaultValue;
+
+ public KeySpec(byte defaultValue)
+ {
+ _defaultValue = defaultValue;
+ }
+
+ public KeySpec(int defaultValue)
+ {
+ _defaultValue = defaultValue;
+ }
+
+ public KeySpec(bool defaultValue)
+ {
+ _defaultValue = defaultValue;
+ }
+
+ public KeySpec(object defaultValue)
+ {
+ _defaultValue = defaultValue;
+ }
+
+ public virtual object DefaultValue()
+ {
+ if (_defaultValue is KeySpec.IDeferred)
+ {
+ return ((KeySpec.IDeferred)_defaultValue).Evaluate();
+ }
+ return _defaultValue;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,89 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class KeySpecHashtable4 : IDeepClone
+ {
+ private SynchronizedHashtable4 _delegate;
+
+ private KeySpecHashtable4(SynchronizedHashtable4 delegate_)
+ {
+ _delegate = delegate_;
+ }
+
+ public KeySpecHashtable4(int size) : this(new SynchronizedHashtable4(size))
+ {
+ }
+
+ public virtual void Put(KeySpec spec, byte value)
+ {
+ _delegate.Put(spec, value);
+ }
+
+ public virtual void Put(KeySpec spec, bool value)
+ {
+ _delegate.Put(spec, value);
+ }
+
+ public virtual void Put(KeySpec spec, int value)
+ {
+ _delegate.Put(spec, value);
+ }
+
+ public virtual void Put(KeySpec spec, object value)
+ {
+ _delegate.Put(spec, value);
+ }
+
+ public virtual byte GetAsByte(KeySpec spec)
+ {
+ return ((byte)Get(spec));
+ }
+
+ public virtual bool GetAsBoolean(KeySpec spec)
+ {
+ return ((bool)Get(spec));
+ }
+
+ public virtual int GetAsInt(KeySpec spec)
+ {
+ return ((int)Get(spec));
+ }
+
+ public virtual TernaryBool GetAsTernaryBool(KeySpec spec)
+ {
+ return (TernaryBool)Get(spec);
+ }
+
+ public virtual string GetAsString(KeySpec spec)
+ {
+ return (string)Get(spec);
+ }
+
+ public virtual object Get(KeySpec spec)
+ {
+ lock (this)
+ {
+ object value = _delegate.Get(spec);
+ if (value == null)
+ {
+ value = spec.DefaultValue();
+ if (value != null)
+ {
+ _delegate.Put(spec, value);
+ }
+ }
+ return value;
+ }
+ }
+
+ public virtual object DeepClone(object obj)
+ {
+ return new Db4objects.Db4o.Foundation.KeySpecHashtable4((SynchronizedHashtable4)_delegate
+ .DeepClone(obj));
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,55 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Types;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// simplest possible linked list
+ ///
+ public sealed class List4 : IUnversioned
+ {
+ /// next element in list
+ public Db4objects.Db4o.Foundation.List4 _next;
+
+ /// carried object
+ public object _element;
+
+ /// db4o constructor to be able to store objects of this class
+ public List4()
+ {
+ }
+
+ public List4(object element)
+ {
+ // TODO: encapsulate field access
+ _element = element;
+ }
+
+ public List4(Db4objects.Db4o.Foundation.List4 next, object element)
+ {
+ _next = next;
+ _element = element;
+ }
+
+ internal bool Holds(object obj)
+ {
+ if (obj == null)
+ {
+ return _element == null;
+ }
+ return ((object)obj).Equals(_element);
+ }
+
+ public static int Size(Db4objects.Db4o.Foundation.List4 list)
+ {
+ int counter = 0;
+ Db4objects.Db4o.Foundation.List4 nextList = list;
+ while (nextList != null)
+ {
+ counter++;
+ nextList = ((Db4objects.Db4o.Foundation.List4)nextList._next);
+ }
+ return counter;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,49 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class ListenerRegistry
+ {
+ public static ListenerRegistry NewInstance()
+ {
+ return new ListenerRegistry();
+ }
+
+ private IdentitySet4 _listeners;
+
+ public virtual void Register(IListener4 listener)
+ {
+ if (_listeners == null)
+ {
+ _listeners = new IdentitySet4();
+ }
+ _listeners.Add(listener);
+ }
+
+ public virtual void NotifyListeners(object @event)
+ {
+ if (_listeners == null)
+ {
+ return;
+ }
+ IEnumerator i = _listeners.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ((IListener4)i.Current).OnEvent(@event);
+ }
+ }
+
+ public virtual void Remove(IListener4 listener)
+ {
+ if (_listeners == null)
+ {
+ return;
+ }
+ _listeners.Remove(listener);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Useful as "out" or "by ref" function parameter.
+ /// Useful as "out" or "by ref" function parameter.
+ public sealed class LongByRef
+ {
+ public long value;
+
+ public LongByRef(long initialValue)
+ {
+ value = initialValue;
+ }
+
+ public LongByRef()
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,61 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public abstract class MappingIterator : IEnumerator
+ {
+ private readonly IEnumerator _iterator;
+
+ private object _current;
+
+ public MappingIterator(IEnumerator iterator)
+ {
+ if (null == iterator)
+ {
+ throw new ArgumentNullException();
+ }
+ _iterator = iterator;
+ _current = Iterators.NoElement;
+ }
+
+ protected abstract object Map(object current);
+
+ public virtual bool MoveNext()
+ {
+ do
+ {
+ if (!_iterator.MoveNext())
+ {
+ _current = Iterators.NoElement;
+ return false;
+ }
+ _current = Map(_iterator.Current);
+ }
+ while (_current == Iterators.Skip);
+ return true;
+ }
+
+ public virtual void Reset()
+ {
+ _current = Iterators.NoElement;
+ _iterator.Reset();
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ if (Iterators.NoElement == _current)
+ {
+ throw new InvalidOperationException();
+ }
+ return _current;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,24 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class NativeCollections
+ {
+ public static IList Filter(IList items, IPredicate4 predicate)
+ {
+ IList filtered = new ArrayList();
+ for (IEnumerator itemIter = items.GetEnumerator(); itemIter.MoveNext(); )
+ {
+ object item = itemIter.Current;
+ if (predicate.Match(item))
+ {
+ filtered.Add(item);
+ }
+ }
+ return filtered;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,12 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class No4 : IInternal4
+ {
+ public static readonly No4 Instance = new No4();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,50 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class NoDuplicatesQueue : IQueue4
+ {
+ private IQueue4 _queue;
+
+ private Hashtable4 _seen;
+
+ public NoDuplicatesQueue(IQueue4 queue)
+ {
+ _queue = queue;
+ _seen = new Hashtable4();
+ }
+
+ public virtual void Add(object obj)
+ {
+ if (_seen.ContainsKey(obj))
+ {
+ return;
+ }
+ _queue.Add(obj);
+ _seen.Put(obj, obj);
+ }
+
+ public virtual bool HasNext()
+ {
+ return _queue.HasNext();
+ }
+
+ public virtual IEnumerator Iterator()
+ {
+ return _queue.Iterator();
+ }
+
+ public virtual object Next()
+ {
+ return _queue.Next();
+ }
+
+ public virtual object NextMatching(IPredicate4 condition)
+ {
+ return _queue.NextMatching(condition);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,120 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Unbounded queue.
+ /// Unbounded queue.
+ ///
+ public class NonblockingQueue : IQueue4
+ {
+ private List4 _insertionPoint;
+
+ private List4 _next;
+
+ public void Add(object obj)
+ {
+ List4 newNode = new List4(null, obj);
+ if (_insertionPoint == null)
+ {
+ _next = newNode;
+ }
+ else
+ {
+ _insertionPoint._next = newNode;
+ }
+ _insertionPoint = newNode;
+ }
+
+ public object Next()
+ {
+ if (_next == null)
+ {
+ return null;
+ }
+ object ret = ((object)_next._element);
+ RemoveNext();
+ return ret;
+ }
+
+ private void RemoveNext()
+ {
+ _next = ((List4)_next._next);
+ if (_next == null)
+ {
+ _insertionPoint = null;
+ }
+ }
+
+ public virtual object NextMatching(IPredicate4 condition)
+ {
+ if (null == condition)
+ {
+ throw new ArgumentNullException();
+ }
+ List4 current = _next;
+ List4 previous = null;
+ while (null != current)
+ {
+ object element = ((object)current._element);
+ if (condition.Match(element))
+ {
+ if (previous == null)
+ {
+ RemoveNext();
+ }
+ else
+ {
+ previous._next = ((List4)current._next);
+ }
+ return element;
+ }
+ previous = current;
+ current = ((List4)current._next);
+ }
+ return null;
+ }
+
+ public bool HasNext()
+ {
+ return _next != null;
+ }
+
+ public virtual IEnumerator Iterator()
+ {
+ List4 origInsertionPoint = _insertionPoint;
+ List4 origNext = _next;
+ return new _Iterator4Impl_82(this, origInsertionPoint, origNext, _next);
+ }
+
+ private sealed class _Iterator4Impl_82 : Iterator4Impl
+ {
+ public _Iterator4Impl_82(NonblockingQueue _enclosing, List4 origInsertionPoint, List4
+ origNext, List4 baseArg1) : base(baseArg1)
+ {
+ this._enclosing = _enclosing;
+ this.origInsertionPoint = origInsertionPoint;
+ this.origNext = origNext;
+ }
+
+ public override bool MoveNext()
+ {
+ if (origInsertionPoint != this._enclosing._insertionPoint || origNext != this._enclosing
+ ._next)
+ {
+ throw new InvalidOperationException();
+ }
+ return base.MoveNext();
+ }
+
+ private readonly NonblockingQueue _enclosing;
+
+ private readonly List4 origInsertionPoint;
+
+ private readonly List4 origNext;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// Useful as "out" or "by ref" function parameter.
+ /// Useful as "out" or "by ref" function parameter.
+ public sealed class ObjectByRef
+ {
+ public object value;
+
+ public ObjectByRef()
+ {
+ }
+
+ public ObjectByRef(object value_)
+ {
+ value = value_;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,82 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class Pair
+ {
+ public static Db4objects.Db4o.Foundation.Pair Of(object first, object second)
+ {
+ return new Db4objects.Db4o.Foundation.Pair(first, second);
+ }
+
+ public object first;
+
+ public object second;
+
+ public Pair(object first, object second)
+ {
+ this.first = first;
+ this.second = second;
+ }
+
+ public override string ToString()
+ {
+ return "Pair.of(" + first + ", " + second + ")";
+ }
+
+ public override int GetHashCode()
+ {
+ int prime = 31;
+ int result = 1;
+ result = prime * result + ((first == null) ? 0 : first.GetHashCode());
+ result = prime * result + ((second == null) ? 0 : second.GetHashCode());
+ return result;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (GetType() != obj.GetType())
+ {
+ return false;
+ }
+ Db4objects.Db4o.Foundation.Pair other = (Db4objects.Db4o.Foundation.Pair)obj;
+ if (first == null)
+ {
+ if (other.first != null)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!first.Equals(other.first))
+ {
+ return false;
+ }
+ }
+ if (second == null)
+ {
+ if (other.second != null)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!second.Equals(other.second))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,88 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class PausableBlockingQueue : BlockingQueue, IPausableBlockingQueue4
+ {
+ private volatile bool _paused = false;
+
+ public virtual bool Pause()
+ {
+ if (_paused)
+ {
+ return false;
+ }
+ _paused = true;
+ return true;
+ }
+
+ public virtual bool Resume()
+ {
+ return (((bool)_lock.Run(new _IClosure4_17(this))));
+ }
+
+ private sealed class _IClosure4_17 : IClosure4
+ {
+ public _IClosure4_17(PausableBlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ if (!this._enclosing._paused)
+ {
+ return false;
+ }
+ this._enclosing._paused = false;
+ this._enclosing._lock.Awake();
+ return true;
+ }
+
+ private readonly PausableBlockingQueue _enclosing;
+ }
+
+ public virtual bool IsPaused()
+ {
+ return _paused;
+ }
+
+ ///
+ protected override bool UnsafeWaitForNext(long timeout)
+ {
+ bool hasNext = base.UnsafeWaitForNext(timeout);
+ while (_paused && !_stopped)
+ {
+ _lock.Snooze(timeout);
+ }
+ if (_stopped)
+ {
+ throw new BlockingQueueStoppedException();
+ }
+ return hasNext;
+ }
+
+ public virtual object TryNext()
+ {
+ return _lock.Run(new _IClosure4_46(this));
+ }
+
+ private sealed class _IClosure4_46 : IClosure4
+ {
+ public _IClosure4_46(PausableBlockingQueue _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ return this._enclosing.IsPaused() ? null : this._enclosing.HasNext() ? this._enclosing
+ .Next() : null;
+ }
+
+ private readonly PausableBlockingQueue _enclosing;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,84 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Sharpen.IO;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public sealed class PrimitiveCodec
+ {
+ public const int IntLength = 4;
+
+ public const int LongLength = 8;
+
+ public static int ReadInt(byte[] buffer, int offset)
+ {
+ offset += 3;
+ return (buffer[offset] & 255) | (buffer[--offset] & 255) << 8 | (buffer[--offset]
+ & 255) << 16 | buffer[--offset] << 24;
+ }
+
+ public static int ReadInt(ByteArrayInputStream @in)
+ {
+ return (@in.Read() << 24) | ((@in.Read() & 255) << 16) | ((@in.Read() & 255) << 8
+ ) | (@in.Read() & 255);
+ }
+
+ public static void WriteInt(byte[] buffer, int offset, int val)
+ {
+ offset += 3;
+ buffer[offset] = (byte)val;
+ buffer[--offset] = (byte)(val >>= 8);
+ buffer[--offset] = (byte)(val >>= 8);
+ buffer[--offset] = (byte)(val >> 8);
+ }
+
+ public static void WriteInt(ByteArrayOutputStream @out, int val)
+ {
+ @out.Write((byte)(val >> 24));
+ @out.Write((byte)(val >> 16));
+ @out.Write((byte)(val >> 8));
+ @out.Write((byte)val);
+ }
+
+ public static void WriteLong(byte[] buffer, long val)
+ {
+ WriteLong(buffer, 0, val);
+ }
+
+ public static void WriteLong(byte[] buffer, int offset, long val)
+ {
+ for (int i = 0; i < LongLength; i++)
+ {
+ buffer[offset++] = (byte)(val >> ((7 - i) * 8));
+ }
+ }
+
+ public static void WriteLong(ByteArrayOutputStream @out, long val)
+ {
+ for (int i = 0; i < LongLength; i++)
+ {
+ @out.Write((byte)(val >> ((7 - i) * 8)));
+ }
+ }
+
+ public static long ReadLong(byte[] buffer, int offset)
+ {
+ long ret = 0;
+ for (int i = 0; i < LongLength; i++)
+ {
+ ret = (ret << 8) + (buffer[offset++] & unchecked((int)(0xff)));
+ }
+ return ret;
+ }
+
+ public static long ReadLong(ByteArrayInputStream @in)
+ {
+ long ret = 0;
+ for (int i = 0; i < LongLength; i++)
+ {
+ ret = (ret << 8) + ((byte)@in.Read() & unchecked((int)(0xff)));
+ }
+ return ret;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Runnable4
+ {
+ private sealed class _IRunnable_10 : IRunnable
+ {
+ public _IRunnable_10()
+ {
+ }
+
+ public void Run()
+ {
+ }
+ }
+
+ public static readonly IRunnable DoNothing = new _IRunnable_10();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,71 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// A collection of static methods that should be part of the runtime environment but are not.
+ ///
+ /// A collection of static methods that should be part of the runtime environment but are not.
+ ///
+ ///
+ public class Runtime4
+ {
+ /// sleeps without checked exceptions
+ public static void Sleep(long millis)
+ {
+ try
+ {
+ Thread.Sleep(millis);
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ /// sleeps with implicit exception
+ ///
+ public static void SleepThrowsOnInterrupt(long millis)
+ {
+ try
+ {
+ Thread.Sleep(millis);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeInterruptedException(e.ToString());
+ }
+ }
+
+ ///
+ /// Keeps executing a block of code until it either returns true or millisecondsTimeout
+ /// elapses.
+ ///
+ ///
+ /// Keeps executing a block of code until it either returns true or millisecondsTimeout
+ /// elapses.
+ ///
+ public static bool Retry(long millisecondsTimeout, IClosure4 block)
+ {
+ return Retry(millisecondsTimeout, 1, block);
+ }
+
+ public static bool Retry(long millisecondsTimeout, int millisecondsBetweenRetries
+ , IClosure4 block)
+ {
+ StopWatch watch = new AutoStopWatch();
+ do
+ {
+ if ((((bool)block.Run())))
+ {
+ return true;
+ }
+ Sleep(millisecondsBetweenRetries);
+ }
+ while (watch.Peek() < millisecondsTimeout);
+ return false;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,14 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Foundation
+{
+ [System.Serializable]
+ public class RuntimeInterruptedException : Exception
+ {
+ public RuntimeInterruptedException(string msg) : base(msg)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,43 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class SimpleObjectPool : IObjectPool
+ {
+ private readonly object[] _objects;
+
+ private int _available;
+
+ public SimpleObjectPool(object[] objects)
+ {
+ int length = objects.Length;
+ _objects = new object[length];
+ for (int i = 0; i < length; ++i)
+ {
+ _objects[length - i - 1] = objects[i];
+ }
+ _available = length;
+ }
+
+ public virtual object BorrowObject()
+ {
+ if (_available == 0)
+ {
+ throw new InvalidOperationException();
+ }
+ return (object)_objects[--_available];
+ }
+
+ public virtual void ReturnObject(object o)
+ {
+ if (_available == _objects.Length)
+ {
+ throw new InvalidOperationException();
+ }
+ _objects[_available++] = o;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,76 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public sealed class SimpleTimer : IRunnable
+ {
+ private readonly IRunnable _runnable;
+
+ private readonly long _interval;
+
+ private Lock4 _lock;
+
+ public volatile bool stopped = false;
+
+ public SimpleTimer(IRunnable runnable, long interval)
+ {
+ _runnable = runnable;
+ _interval = interval;
+ _lock = new Lock4();
+ }
+
+ public void Stop()
+ {
+ stopped = true;
+ _lock.Run(new _IClosure4_27(this));
+ }
+
+ private sealed class _IClosure4_27 : IClosure4
+ {
+ public _IClosure4_27(SimpleTimer _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ this._enclosing._lock.Awake();
+ return null;
+ }
+
+ private readonly SimpleTimer _enclosing;
+ }
+
+ public void Run()
+ {
+ while (!stopped)
+ {
+ _lock.Run(new _IClosure4_37(this));
+ if (!stopped)
+ {
+ _runnable.Run();
+ }
+ }
+ }
+
+ private sealed class _IClosure4_37 : IClosure4
+ {
+ public _IClosure4_37(SimpleTimer _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Run()
+ {
+ this._enclosing._lock.Snooze(this._enclosing._interval);
+ return null;
+ }
+
+ private readonly SimpleTimer _enclosing;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class SingleValueIterator : IEnumerator
+ {
+ private object _value;
+
+ private bool _moved;
+
+ public SingleValueIterator(object value)
+ {
+ _value = value;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ if (!_moved || _value == Iterators.NoElement)
+ {
+ throw new InvalidOperationException();
+ }
+ return _value;
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (!_moved)
+ {
+ _moved = true;
+ return true;
+ }
+ _value = Iterators.NoElement;
+ return false;
+ }
+
+ public virtual void Reset()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,82 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class SortedCollection4
+ {
+ private readonly IComparison4 _comparison;
+
+ private Tree _tree;
+
+ public SortedCollection4(IComparison4 comparison)
+ {
+ if (null == comparison)
+ {
+ throw new ArgumentNullException();
+ }
+ _comparison = comparison;
+ _tree = null;
+ }
+
+ public virtual object SingleElement()
+ {
+ if (1 != Size())
+ {
+ throw new InvalidOperationException();
+ }
+ return _tree.Key();
+ }
+
+ public virtual void AddAll(IEnumerator iterator)
+ {
+ while (iterator.MoveNext())
+ {
+ Add(iterator.Current);
+ }
+ }
+
+ public virtual void Add(object element)
+ {
+ _tree = Tree.Add(_tree, new TreeObject(element, _comparison));
+ }
+
+ public virtual void Remove(object element)
+ {
+ _tree = Tree.RemoveLike(_tree, new TreeObject(element, _comparison));
+ }
+
+ public virtual object[] ToArray(object[] array)
+ {
+ Tree.Traverse(_tree, new _IVisitor4_43(array));
+ return array;
+ }
+
+ private sealed class _IVisitor4_43 : IVisitor4
+ {
+ public _IVisitor4_43(object[] array)
+ {
+ this.array = array;
+ this.i = 0;
+ }
+
+ internal int i;
+
+ public void Visit(object obj)
+ {
+ array[this.i++] = ((TreeObject)obj).Key();
+ }
+
+ private readonly object[] array;
+ }
+
+ public virtual int Size()
+ {
+ return Tree.Size(_tree);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,43 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class Stack4
+ {
+ private List4 _tail;
+
+ public virtual void Push(object obj)
+ {
+ _tail = new List4(_tail, obj);
+ }
+
+ public virtual object Peek()
+ {
+ if (_tail == null)
+ {
+ return null;
+ }
+ return _tail._element;
+ }
+
+ public virtual object Pop()
+ {
+ if (_tail == null)
+ {
+ throw new InvalidOperationException();
+ }
+ object res = _tail._element;
+ _tail = ((List4)_tail._next);
+ return res;
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return _tail == null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class StopWatch
+ {
+ private long _started;
+
+ private long _elapsed;
+
+ public StopWatch()
+ {
+ }
+
+ public virtual void Start()
+ {
+ _started = Runtime.CurrentTimeMillis();
+ }
+
+ public virtual void Stop()
+ {
+ _elapsed = Peek();
+ }
+
+ public virtual long Peek()
+ {
+ return Runtime.CurrentTimeMillis() - _started;
+ }
+
+ public virtual long Elapsed()
+ {
+ return _elapsed;
+ }
+
+ public static long Time(IBlock4 block)
+ {
+ Db4objects.Db4o.Foundation.StopWatch stopWatch = new Db4objects.Db4o.Foundation.StopWatch
+ ();
+ stopWatch.Start();
+ block.Run();
+ stopWatch.Stop();
+ return stopWatch.Elapsed();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,22 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class SubTypePredicate : IPredicate4
+ {
+ private readonly Type _class;
+
+ public SubTypePredicate(Type clazz)
+ {
+ _class = clazz;
+ }
+
+ public virtual bool Match(object candidate)
+ {
+ return _class.IsInstanceOfType(candidate);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,46 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class SynchronizedHashtable4 : IDeepClone
+ {
+ private readonly Hashtable4 _delegate;
+
+ private SynchronizedHashtable4(Hashtable4 delegate_)
+ {
+ _delegate = delegate_;
+ }
+
+ public SynchronizedHashtable4(int size) : this(new Hashtable4(size))
+ {
+ }
+
+ public virtual object DeepClone(object obj)
+ {
+ lock (this)
+ {
+ return new Db4objects.Db4o.Foundation.SynchronizedHashtable4((Hashtable4)_delegate
+ .DeepClone(obj));
+ }
+ }
+
+ public virtual void Put(object key, object value)
+ {
+ lock (this)
+ {
+ _delegate.Put(key, value);
+ }
+ }
+
+ public virtual object Get(object key)
+ {
+ lock (this)
+ {
+ return _delegate.Get(key);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,46 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class SynchronizedIterator4 : IEnumerator
+ {
+ private readonly IEnumerator _delegate;
+
+ private readonly object _lock;
+
+ public SynchronizedIterator4(IEnumerator delegate_, object Lock)
+ {
+ _delegate = delegate_;
+ _lock = Lock;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ lock (_lock)
+ {
+ return _delegate.Current;
+ }
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ lock (_lock)
+ {
+ return _delegate.MoveNext();
+ }
+ }
+
+ public virtual void Reset()
+ {
+ lock (_lock)
+ {
+ _delegate.Reset();
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,138 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Foundation
+{
+ /// yes/no/dontknow data type
+ ///
+ [System.Serializable]
+ public sealed class TernaryBool
+ {
+ private const int NoId = -1;
+
+ private const int YesId = 1;
+
+ private const int UnspecifiedId = 0;
+
+ public static readonly Db4objects.Db4o.Foundation.TernaryBool No = new Db4objects.Db4o.Foundation.TernaryBool
+ (NoId);
+
+ public static readonly Db4objects.Db4o.Foundation.TernaryBool Yes = new Db4objects.Db4o.Foundation.TernaryBool
+ (YesId);
+
+ public static readonly Db4objects.Db4o.Foundation.TernaryBool Unspecified = new Db4objects.Db4o.Foundation.TernaryBool
+ (UnspecifiedId);
+
+ private readonly int _value;
+
+ private TernaryBool(int value)
+ {
+ _value = value;
+ }
+
+ public bool BooleanValue(bool defaultValue)
+ {
+ switch (_value)
+ {
+ case NoId:
+ {
+ return false;
+ }
+
+ case YesId:
+ {
+ return true;
+ }
+
+ default:
+ {
+ return defaultValue;
+ break;
+ }
+ }
+ }
+
+ public bool IsUnspecified()
+ {
+ return this == Unspecified;
+ }
+
+ public bool DefiniteYes()
+ {
+ return this == Yes;
+ }
+
+ public bool DefiniteNo()
+ {
+ return this == No;
+ }
+
+ public static Db4objects.Db4o.Foundation.TernaryBool ForBoolean(bool value)
+ {
+ return (value ? Yes : No);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+ Db4objects.Db4o.Foundation.TernaryBool tb = (Db4objects.Db4o.Foundation.TernaryBool
+ )obj;
+ return _value == tb._value;
+ }
+
+ public override int GetHashCode()
+ {
+ return _value;
+ }
+
+ private object ReadResolve()
+ {
+ switch (_value)
+ {
+ case NoId:
+ {
+ return No;
+ }
+
+ case YesId:
+ {
+ return Yes;
+ }
+
+ default:
+ {
+ return Unspecified;
+ break;
+ }
+ }
+ }
+
+ public override string ToString()
+ {
+ switch (_value)
+ {
+ case NoId:
+ {
+ return "NO";
+ }
+
+ case YesId:
+ {
+ return "YES";
+ }
+
+ default:
+ {
+ return "UNSPECIFIED";
+ break;
+ }
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,57 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ /// ThreadLocal implementation for less capable platforms such as JRE 1.1 and
+ /// Silverlight.
+ ///
+ ///
+ /// ThreadLocal implementation for less capable platforms such as JRE 1.1 and
+ /// Silverlight.
+ /// This class is not intended to be used directly, use
+ /// DynamicVariable
+ /// .
+ /// WARNING: This implementation might leak Thread references unless
+ /// Set(object)
+ /// is called with null on the right thread to clean it up. This
+ /// behavior is currently guaranteed by
+ /// DynamicVariable
+ /// .
+ ///
+ public class ThreadLocal4
+ {
+ private readonly IDictionary _values = new Hashtable();
+
+ public virtual void Set(object value)
+ {
+ lock (this)
+ {
+ if (value == null)
+ {
+ Sharpen.Collections.Remove(_values, Thread.CurrentThread());
+ }
+ else
+ {
+ _values[Thread.CurrentThread()] = value;
+ }
+ }
+ }
+
+ public virtual object Get()
+ {
+ lock (this)
+ {
+ return _values[Thread.CurrentThread()];
+ }
+ }
+
+ protected object InitialValue()
+ {
+ return null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,39 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ public class TimeoutBlockingQueue : PausableBlockingQueue, ITimeoutBlockingQueue4
+ {
+ private long expirationDate;
+
+ private readonly long maxTimeToRemainPaused;
+
+ public TimeoutBlockingQueue(long maxTimeToRemainPaused)
+ {
+ this.maxTimeToRemainPaused = maxTimeToRemainPaused;
+ }
+
+ public override bool Pause()
+ {
+ Reset();
+ return base.Pause();
+ }
+
+ public virtual void Check()
+ {
+ long now = Runtime.CurrentTimeMillis();
+ if (now > expirationDate)
+ {
+ Resume();
+ }
+ }
+
+ public virtual void Reset()
+ {
+ expirationDate = Runtime.CurrentTimeMillis() + maxTimeToRemainPaused;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,91 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Sharpen;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class TimeStampIdGenerator
+ {
+ public const int BitsReservedForCounter = 15;
+
+ public const int CounterLimit = 64;
+
+ private long _counter;
+
+ private long _lastTime;
+
+ public static long IdToMilliseconds(long id)
+ {
+ return id >> BitsReservedForCounter;
+ }
+
+ public static long MillisecondsToId(long milliseconds)
+ {
+ return milliseconds << BitsReservedForCounter;
+ }
+
+ public TimeStampIdGenerator(long minimumNext)
+ {
+ InternalSetMinimumNext(minimumNext);
+ }
+
+ public TimeStampIdGenerator() : this(0)
+ {
+ }
+
+ public virtual long Generate()
+ {
+ long t = Now();
+ if (t > _lastTime)
+ {
+ _lastTime = t;
+ _counter = 0;
+ return MillisecondsToId(t);
+ }
+ UpdateTimeOnCounterLimitOverflow();
+ _counter++;
+ UpdateTimeOnCounterLimitOverflow();
+ return Last();
+ }
+
+ protected virtual long Now()
+ {
+ return Runtime.CurrentTimeMillis();
+ }
+
+ private void UpdateTimeOnCounterLimitOverflow()
+ {
+ if (_counter < CounterLimit)
+ {
+ return;
+ }
+ long timeIncrement = _counter / CounterLimit;
+ _lastTime += timeIncrement;
+ _counter -= (timeIncrement * CounterLimit);
+ }
+
+ public virtual long Last()
+ {
+ return MillisecondsToId(_lastTime) + _counter;
+ }
+
+ public virtual bool SetMinimumNext(long newMinimum)
+ {
+ if (newMinimum <= Last())
+ {
+ return false;
+ }
+ InternalSetMinimumNext(newMinimum);
+ return true;
+ }
+
+ private void InternalSetMinimumNext(long newNext)
+ {
+ _lastTime = IdToMilliseconds(newNext);
+ long timePart = MillisecondsToId(_lastTime);
+ _counter = newNext - timePart;
+ UpdateTimeOnCounterLimitOverflow();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,694 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public abstract class Tree : IShallowClone, IDeepClone, IVisitable
+ {
+ public Tree _preceding;
+
+ public int _size = 1;
+
+ public Tree _subsequent;
+
+ public static Tree Add(Tree oldTree, Tree newTree)
+ {
+ if (oldTree == null)
+ {
+ return newTree;
+ }
+ return (Tree)((Tree)oldTree).Add(newTree);
+ }
+
+ public Tree Add(Tree newNode)
+ {
+ return Add(newNode, Compare(newNode));
+ }
+
+ ///
+ /// On adding a node to a tree, if it already exists, and if
+ /// Tree#duplicates() returns false, #isDuplicateOf() will be
+ /// called.
+ ///
+ ///
+ /// On adding a node to a tree, if it already exists, and if
+ /// Tree#duplicates() returns false, #isDuplicateOf() will be
+ /// called. The added node can then be asked for the node that
+ /// prevails in the tree using #duplicateOrThis(). This mechanism
+ /// allows doing find() and add() in one run.
+ ///
+ public virtual Tree Add(Tree newNode, int cmp)
+ {
+ if (cmp < 0)
+ {
+ if (_subsequent == null)
+ {
+ _subsequent = newNode;
+ _size++;
+ }
+ else
+ {
+ _subsequent = _subsequent.Add(newNode);
+ if (_preceding == null)
+ {
+ return (Tree)RotateLeft();
+ }
+ return (Tree)Balance();
+ }
+ }
+ else
+ {
+ if (cmp > 0 || ((Tree)newNode).Duplicates())
+ {
+ if (_preceding == null)
+ {
+ _preceding = newNode;
+ _size++;
+ }
+ else
+ {
+ _preceding = _preceding.Add(newNode);
+ if (_subsequent == null)
+ {
+ return (Tree)RotateRight();
+ }
+ return (Tree)Balance();
+ }
+ }
+ else
+ {
+ return (Tree)((Tree)newNode).OnAttemptToAddDuplicate(this);
+ }
+ }
+ return (Tree)this;
+ }
+
+ ///
+ /// On adding a node to a tree, if it already exists, and if
+ /// Tree#duplicates() returns false, #onAttemptToAddDuplicate()
+ /// will be called and the existing node will be stored in
+ /// this._preceding.
+ ///
+ ///
+ /// On adding a node to a tree, if it already exists, and if
+ /// Tree#duplicates() returns false, #onAttemptToAddDuplicate()
+ /// will be called and the existing node will be stored in
+ /// this._preceding.
+ /// This node node can then be asked for the node that prevails
+ /// in the tree on adding, using the #addedOrExisting() method.
+ /// This mechanism allows doing find() and add() in one run.
+ ///
+ public virtual Tree AddedOrExisting()
+ {
+ if (WasAddedToTree())
+ {
+ return this;
+ }
+ return _preceding;
+ }
+
+ public virtual bool WasAddedToTree()
+ {
+ return _size != 0;
+ }
+
+ public Tree Balance()
+ {
+ int cmp = _subsequent.Nodes() - _preceding.Nodes();
+ if (cmp < -2)
+ {
+ return RotateRight();
+ }
+ else
+ {
+ if (cmp > 2)
+ {
+ return RotateLeft();
+ }
+ else
+ {
+ SetSizeOwnPrecedingSubsequent();
+ return this;
+ }
+ }
+ }
+
+ public virtual Tree BalanceCheckNulls()
+ {
+ if (_subsequent == null)
+ {
+ if (_preceding == null)
+ {
+ SetSizeOwn();
+ return this;
+ }
+ return RotateRight();
+ }
+ else
+ {
+ if (_preceding == null)
+ {
+ return RotateLeft();
+ }
+ }
+ return Balance();
+ }
+
+ public virtual void CalculateSize()
+ {
+ if (_preceding == null)
+ {
+ if (_subsequent == null)
+ {
+ SetSizeOwn();
+ }
+ else
+ {
+ SetSizeOwnSubsequent();
+ }
+ }
+ else
+ {
+ if (_subsequent == null)
+ {
+ SetSizeOwnPreceding();
+ }
+ else
+ {
+ SetSizeOwnPrecedingSubsequent();
+ }
+ }
+ }
+
+ ///
+ /// returns 0, if keys are equal
+ /// uses this - other
+ /// returns positive if this is greater than a_to
+ /// returns negative if this is smaller than a_to
+ ///
+ public abstract int Compare(Tree a_to);
+
+ public static Tree DeepClone(Tree a_tree, object a_param)
+ {
+ if (a_tree == null)
+ {
+ return null;
+ }
+ Tree newNode = (Tree)a_tree.DeepClone(a_param);
+ newNode._size = a_tree._size;
+ newNode._preceding = Tree.DeepClone(((Tree)a_tree._preceding), a_param);
+ newNode._subsequent = Tree.DeepClone(((Tree)a_tree._subsequent), a_param);
+ return newNode;
+ }
+
+ public virtual object DeepClone(object a_param)
+ {
+ return ShallowClone();
+ }
+
+ public virtual bool Duplicates()
+ {
+ return true;
+ }
+
+ public Tree Filter(IPredicate4 a_filter)
+ {
+ if (_preceding != null)
+ {
+ _preceding = _preceding.Filter(a_filter);
+ }
+ if (_subsequent != null)
+ {
+ _subsequent = _subsequent.Filter(a_filter);
+ }
+ if (!a_filter.Match(this))
+ {
+ return Remove();
+ }
+ return this;
+ }
+
+ public static Tree Find(Tree inTree, Tree template)
+ {
+ if (inTree == null)
+ {
+ return null;
+ }
+ return inTree.Find(template);
+ }
+
+ public Tree Find(Tree template)
+ {
+ Tree current = this;
+ while (true)
+ {
+ int comparisonResult = current.Compare(template);
+ if (comparisonResult == 0)
+ {
+ return current;
+ }
+ if (comparisonResult < 0)
+ {
+ current = ((Tree)current._subsequent);
+ }
+ else
+ {
+ current = ((Tree)current._preceding);
+ }
+ if (current == null)
+ {
+ return null;
+ }
+ }
+ }
+
+ public static Tree FindGreaterOrEqual(Tree a_in, Tree a_finder)
+ {
+ if (a_in == null)
+ {
+ return null;
+ }
+ int cmp = a_in.Compare(a_finder);
+ if (cmp == 0)
+ {
+ return a_in;
+ }
+ // the highest node in the hierarchy !!!
+ if (cmp > 0)
+ {
+ Tree node = FindGreaterOrEqual(((Tree)a_in._preceding), a_finder);
+ if (node != null)
+ {
+ return node;
+ }
+ return a_in;
+ }
+ return FindGreaterOrEqual(((Tree)a_in._subsequent), a_finder);
+ }
+
+ public static Tree FindSmaller(Tree a_in, Tree a_node)
+ {
+ if (a_in == null)
+ {
+ return null;
+ }
+ int cmp = a_in.Compare(a_node);
+ if (cmp < 0)
+ {
+ Tree node = FindSmaller(((Tree)a_in._subsequent), a_node);
+ if (node != null)
+ {
+ return node;
+ }
+ return a_in;
+ }
+ return FindSmaller(((Tree)a_in._preceding), a_node);
+ }
+
+ public Tree First()
+ {
+ if (_preceding == null)
+ {
+ return this;
+ }
+ return _preceding.First();
+ }
+
+ public static Tree Last(Tree tree)
+ {
+ if (tree == null)
+ {
+ return null;
+ }
+ return tree.Last();
+ }
+
+ public Tree Last()
+ {
+ if (_subsequent == null)
+ {
+ return this;
+ }
+ return _subsequent.Last();
+ }
+
+ public virtual Tree OnAttemptToAddDuplicate(Tree oldNode)
+ {
+ _size = 0;
+ _preceding = oldNode;
+ return oldNode;
+ }
+
+ /// the number of nodes in this tree for balancing
+ public virtual int Nodes()
+ {
+ return _size;
+ }
+
+ public virtual int OwnSize()
+ {
+ return 1;
+ }
+
+ public virtual Tree Remove()
+ {
+ if (_subsequent != null && _preceding != null)
+ {
+ _subsequent = _subsequent.RotateSmallestUp();
+ _subsequent._preceding = _preceding;
+ _subsequent.CalculateSize();
+ return _subsequent;
+ }
+ if (_subsequent != null)
+ {
+ return _subsequent;
+ }
+ return _preceding;
+ }
+
+ public virtual void RemoveChildren()
+ {
+ _preceding = null;
+ _subsequent = null;
+ SetSizeOwn();
+ }
+
+ public virtual Tree RemoveFirst()
+ {
+ if (_preceding == null)
+ {
+ return _subsequent;
+ }
+ _preceding = _preceding.RemoveFirst();
+ CalculateSize();
+ return this;
+ }
+
+ public static Tree RemoveLike(Tree from, Tree a_find)
+ {
+ if (from == null)
+ {
+ return null;
+ }
+ return from.RemoveLike(a_find);
+ }
+
+ public Tree RemoveLike(Tree a_find)
+ {
+ int cmp = Compare(a_find);
+ if (cmp == 0)
+ {
+ return (Tree)Remove();
+ }
+ if (cmp > 0)
+ {
+ if (_preceding != null)
+ {
+ _preceding = _preceding.RemoveLike(a_find);
+ }
+ }
+ else
+ {
+ if (_subsequent != null)
+ {
+ _subsequent = _subsequent.RemoveLike(a_find);
+ }
+ }
+ CalculateSize();
+ return (Tree)this;
+ }
+
+ public Tree RemoveNode(Tree a_tree)
+ {
+ if (this == a_tree)
+ {
+ return Remove();
+ }
+ int cmp = Compare(a_tree);
+ if (cmp >= 0)
+ {
+ if (_preceding != null)
+ {
+ _preceding = _preceding.RemoveNode(a_tree);
+ }
+ }
+ if (cmp <= 0)
+ {
+ if (_subsequent != null)
+ {
+ _subsequent = _subsequent.RemoveNode(a_tree);
+ }
+ }
+ CalculateSize();
+ return this;
+ }
+
+ public Tree RotateLeft()
+ {
+ Tree tree = _subsequent;
+ _subsequent = ((Tree)tree._preceding);
+ CalculateSize();
+ tree._preceding = this;
+ if (((Tree)tree._subsequent) == null)
+ {
+ tree.SetSizeOwnPlus(this);
+ }
+ else
+ {
+ tree.SetSizeOwnPlus(this, ((Tree)tree._subsequent));
+ }
+ return tree;
+ }
+
+ public Tree RotateRight()
+ {
+ Tree tree = _preceding;
+ _preceding = ((Tree)tree._subsequent);
+ CalculateSize();
+ tree._subsequent = this;
+ if (((Tree)tree._preceding) == null)
+ {
+ tree.SetSizeOwnPlus(this);
+ }
+ else
+ {
+ tree.SetSizeOwnPlus(this, ((Tree)tree._preceding));
+ }
+ return tree;
+ }
+
+ private Tree RotateSmallestUp()
+ {
+ if (_preceding != null)
+ {
+ _preceding = _preceding.RotateSmallestUp();
+ return RotateRight();
+ }
+ return this;
+ }
+
+ public void SetSizeOwn()
+ {
+ _size = OwnSize();
+ }
+
+ public void SetSizeOwnPrecedingSubsequent()
+ {
+ _size = OwnSize() + _preceding._size + _subsequent._size;
+ }
+
+ public void SetSizeOwnPreceding()
+ {
+ _size = OwnSize() + _preceding._size;
+ }
+
+ public void SetSizeOwnSubsequent()
+ {
+ _size = OwnSize() + _subsequent._size;
+ }
+
+ public void SetSizeOwnPlus(Tree tree)
+ {
+ _size = OwnSize() + tree._size;
+ }
+
+ public void SetSizeOwnPlus(Tree tree1, Tree tree2)
+ {
+ _size = OwnSize() + tree1._size + tree2._size;
+ }
+
+ public static int Size(Tree a_tree)
+ {
+ if (a_tree == null)
+ {
+ return 0;
+ }
+ return a_tree.Size();
+ }
+
+ /// the number of objects represented.
+ public virtual int Size()
+ {
+ return _size;
+ }
+
+ public static void Traverse(Tree tree, IVisitor4 visitor)
+ {
+ if (tree == null)
+ {
+ return;
+ }
+ tree.Traverse(visitor);
+ }
+
+ /// Traverses a tree with a starting point node.
+ ///
+ /// Traverses a tree with a starting point node.
+ /// If there is no exact match for the starting node, the next higher will be taken.
+ ///
+ public static void Traverse(Tree tree, Tree startingNode, ICancellableVisitor4 visitor
+ )
+ {
+ if (tree == null)
+ {
+ return;
+ }
+ tree.Traverse(startingNode, visitor);
+ }
+
+ private bool Traverse(Tree startingNode, ICancellableVisitor4 visitor)
+ {
+ if (startingNode != null)
+ {
+ int cmp = Compare(startingNode);
+ if (cmp < 0)
+ {
+ if (_subsequent != null)
+ {
+ return _subsequent.Traverse(startingNode, visitor);
+ }
+ return true;
+ }
+ else
+ {
+ if (cmp > 0)
+ {
+ if (_preceding != null)
+ {
+ if (!_preceding.Traverse(startingNode, visitor))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if (_preceding != null)
+ {
+ if (!_preceding.Traverse(null, visitor))
+ {
+ return false;
+ }
+ }
+ }
+ if (!visitor.Visit(this))
+ {
+ return false;
+ }
+ if (_subsequent != null)
+ {
+ if (!_subsequent.Traverse(null, visitor))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void Traverse(IVisitor4 visitor)
+ {
+ if (_preceding != null)
+ {
+ _preceding.Traverse(visitor);
+ }
+ visitor.Visit((Tree)this);
+ if (_subsequent != null)
+ {
+ _subsequent.Traverse(visitor);
+ }
+ }
+
+ public void TraverseFromLeaves(IVisitor4 a_visitor)
+ {
+ if (_preceding != null)
+ {
+ _preceding.TraverseFromLeaves(a_visitor);
+ }
+ if (_subsequent != null)
+ {
+ _subsequent.TraverseFromLeaves(a_visitor);
+ }
+ a_visitor.Visit(this);
+ }
+
+ // Keep the debug method to debug the depth
+ // public final void debugLeafDepth(int currentDepth){
+ // currentDepth++;
+ // if(_preceding == null && _subsequent == null){
+ // System.out.println("" + currentDepth + " tree leaf depth.");
+ // return;
+ // }
+ // if (_preceding != null){
+ // _preceding.debugLeafDepth(currentDepth);
+ // }
+ // if(_subsequent != null){
+ // _subsequent.debugLeafDepth(currentDepth);
+ // }
+ // }
+ protected virtual Tree ShallowCloneInternal(Tree tree)
+ {
+ tree._preceding = _preceding;
+ tree._size = _size;
+ tree._subsequent = _subsequent;
+ return tree;
+ }
+
+ public virtual object ShallowClone()
+ {
+ throw new NotImplementedException();
+ }
+
+ public abstract object Key();
+
+ public virtual object Root()
+ {
+ return this;
+ }
+
+ public virtual void Accept(IVisitor4 visitor)
+ {
+ Traverse(new _IVisitor4_513(visitor));
+ }
+
+ private sealed class _IVisitor4_513 : IVisitor4
+ {
+ public _IVisitor4_513(IVisitor4 visitor)
+ {
+ this.visitor = visitor;
+ }
+
+ public void Visit(object obj)
+ {
+ Tree tree = (Tree)obj;
+ visitor.Visit(tree.Key());
+ }
+
+ private readonly IVisitor4 visitor;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class TreeKeyIterator : AbstractTreeIterator
+ {
+ public TreeKeyIterator(Tree tree) : base(tree)
+ {
+ }
+
+ protected override object CurrentValue(Tree tree)
+ {
+ return tree.Key();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class TreeNodeIterator : AbstractTreeIterator
+ {
+ public TreeNodeIterator(Tree tree) : base(tree)
+ {
+ }
+
+ protected override object CurrentValue(Tree tree)
+ {
+ return tree.Root();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Foundation
+{
+ ///
+ public class TreeObject : Tree
+ {
+ private readonly object _object;
+
+ private readonly IComparison4 _function;
+
+ public TreeObject(object @object, IComparison4 function)
+ {
+ _object = @object;
+ _function = function;
+ }
+
+ public override int Compare(Tree tree)
+ {
+ return _function.Compare(_object, tree.Key());
+ }
+
+ public override object Key()
+ {
+ return _object;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o
+{
+ ///
+ /// com.db4o.internal.blobs
+ public interface IBlobStatus
+ {
+ double GetStatus();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+#if !SILVERLIGHT
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o
+{
+ ///
+ public interface IBlobTransport
+ {
+ ///
+ void WriteBlobTo(Transaction trans, BlobImpl blob);
+
+ ///
+ void ReadBlobFrom(Transaction trans, BlobImpl blob);
+
+ void DeleteBlobFile(Transaction trans, BlobImpl blob);
+ }
+}
+#endif // !SILVERLIGHT
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,41 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+
+namespace Db4objects.Db4o
+{
+ ///
+ /// Represents a local ObjectContainer attached to a
+ /// database file.
+ ///
+ ///
+ /// Represents a local ObjectContainer attached to a
+ /// database file.
+ ///
+ /// 7.10
+ public interface IEmbeddedObjectContainer : IObjectContainer
+ {
+ /// backs up a database file of an open ObjectContainer.
+ ///
+ /// backs up a database file of an open ObjectContainer.
+ ///
While the backup is running, the ObjectContainer can continue to be
+ /// used. Changes that are made while the backup is in progress, will be applied to
+ /// the open ObjectContainer and to the backup.
+ /// While the backup is running, the ObjectContainer should not be closed.
+ /// If a file already exists at the specified path, it will be overwritten.
+ /// The
+ /// Db4objects.Db4o.IO.IStorage
+ /// used for backup is the one configured for this container.
+ ///
+ /// a fully qualified path
+ /// db4o database file was closed or failed to open.
+ ///
+ ///
+ /// is thrown when the operation is not supported in current
+ /// configuration/environment
+ ///
+ /// I/O operation failed or was unexpectedly interrupted.
+ ///
+ void Backup(string path);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o
+{
+ /// Marker interface to denote that a class is used for db4o internals.
+ /// Marker interface to denote that a class is used for db4o internals.
+ ///
+ public interface IInternal4
+ {
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,100 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public abstract class AbstractBufferContext : IBufferContext, IHandlerVersionContext
+ {
+ private IReadBuffer _buffer;
+
+ private readonly Db4objects.Db4o.Internal.Transaction _transaction;
+
+ public AbstractBufferContext(Db4objects.Db4o.Internal.Transaction transaction, IReadBuffer
+ buffer)
+ {
+ _transaction = transaction;
+ _buffer = buffer;
+ }
+
+ public virtual IReadBuffer Buffer(IReadBuffer buffer)
+ {
+ IReadBuffer temp = _buffer;
+ _buffer = buffer;
+ return temp;
+ }
+
+ public virtual IReadBuffer Buffer()
+ {
+ return _buffer;
+ }
+
+ public virtual byte ReadByte()
+ {
+ return _buffer.ReadByte();
+ }
+
+ public virtual void ReadBytes(byte[] bytes)
+ {
+ _buffer.ReadBytes(bytes);
+ }
+
+ public virtual int ReadInt()
+ {
+ return _buffer.ReadInt();
+ }
+
+ public virtual long ReadLong()
+ {
+ return _buffer.ReadLong();
+ }
+
+ public virtual int Offset()
+ {
+ return _buffer.Offset();
+ }
+
+ public virtual void Seek(int offset)
+ {
+ _buffer.Seek(offset);
+ }
+
+ public virtual ObjectContainerBase Container()
+ {
+ return _transaction.Container();
+ }
+
+ public virtual IObjectContainer ObjectContainer()
+ {
+ return Container();
+ }
+
+ public virtual Db4objects.Db4o.Internal.Transaction Transaction()
+ {
+ return _transaction;
+ }
+
+ public abstract int HandlerVersion();
+
+ public virtual bool IsLegacyHandlerVersion()
+ {
+ return HandlerVersion() == 0;
+ }
+
+ public virtual BitMap4 ReadBitMap(int bitCount)
+ {
+ return _buffer.ReadBitMap(bitCount);
+ }
+
+ public virtual Db4objects.Db4o.Internal.Marshall.SlotFormat SlotFormat()
+ {
+ return Db4objects.Db4o.Internal.Marshall.SlotFormat.ForHandlerVersion(HandlerVersion
+ ());
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,46 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Activation;
+using Db4objects.Db4o.TA;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public abstract class ActivatableBase : IActivatable
+ {
+ [System.NonSerialized]
+ private IActivator _activator;
+
+ public virtual void Bind(IActivator activator)
+ {
+ if (_activator == activator)
+ {
+ return;
+ }
+ if (activator != null && _activator != null)
+ {
+ throw new InvalidOperationException();
+ }
+ _activator = activator;
+ }
+
+ public virtual void Activate(ActivationPurpose purpose)
+ {
+ if (_activator == null)
+ {
+ return;
+ }
+ _activator.Activate(purpose);
+ }
+
+ protected virtual void ActivateForRead()
+ {
+ Activate(ActivationPurpose.Read);
+ }
+
+ protected virtual void ActivateForWrite()
+ {
+ Activate(ActivationPurpose.Write);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,123 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ ///
+ public class ActivationContext4 : IActivationContext
+ {
+ private readonly Db4objects.Db4o.Internal.Transaction _transaction;
+
+ private readonly object _targetObject;
+
+ private readonly IActivationDepth _depth;
+
+ public ActivationContext4(Db4objects.Db4o.Internal.Transaction transaction, object
+ obj, IActivationDepth depth)
+ {
+ if (null == obj)
+ {
+ throw new ArgumentNullException();
+ }
+ _transaction = transaction;
+ _targetObject = obj;
+ _depth = depth;
+ }
+
+ public virtual void CascadeActivationToTarget()
+ {
+ IActivationContext context = ClassMetadata().DescendOnCascadingActivation() ? Descend
+ () : this;
+ CascadeActivation(context);
+ }
+
+ public virtual void CascadeActivationToChild(object obj)
+ {
+ if (obj == null)
+ {
+ return;
+ }
+ IActivationContext cascadingContext = ForObject(obj);
+ Db4objects.Db4o.Internal.ClassMetadata classMetadata = cascadingContext.ClassMetadata
+ ();
+ if (classMetadata == null || !classMetadata.HasIdentity())
+ {
+ return;
+ }
+ CascadeActivation(cascadingContext.Descend());
+ }
+
+ private void CascadeActivation(IActivationContext context)
+ {
+ IActivationDepth depth = context.Depth();
+ if (!depth.RequiresActivation())
+ {
+ return;
+ }
+ if (depth.Mode().IsDeactivate())
+ {
+ Container().StillToDeactivate(_transaction, context.TargetObject(), depth, false);
+ }
+ else
+ {
+ // FIXME: [TA] do we really need to check for isValueType here?
+ Db4objects.Db4o.Internal.ClassMetadata classMetadata = context.ClassMetadata();
+ if (classMetadata.IsStruct())
+ {
+ classMetadata.CascadeActivation(context);
+ }
+ else
+ {
+ Container().StillToActivate(context);
+ }
+ }
+ }
+
+ public virtual ObjectContainerBase Container()
+ {
+ return _transaction.Container();
+ }
+
+ public virtual object TargetObject()
+ {
+ return _targetObject;
+ }
+
+ public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata()
+ {
+ return Container().ClassMetadataForObject(_targetObject);
+ }
+
+ public virtual IActivationDepth Depth()
+ {
+ return _depth;
+ }
+
+ public virtual IObjectContainer ObjectContainer()
+ {
+ return Container();
+ }
+
+ public virtual Db4objects.Db4o.Internal.Transaction Transaction()
+ {
+ return _transaction;
+ }
+
+ public virtual IActivationContext ForObject(object newTargetObject)
+ {
+ return new Db4objects.Db4o.Internal.Activation.ActivationContext4(Transaction(),
+ newTargetObject, Depth());
+ }
+
+ public virtual IActivationContext Descend()
+ {
+ return new Db4objects.Db4o.Internal.Activation.ActivationContext4(Transaction(),
+ TargetObject(), Depth().Descend(ClassMetadata()));
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public abstract class ActivationDepthImpl : IActivationDepth
+ {
+ protected readonly ActivationMode _mode;
+
+ protected ActivationDepthImpl(ActivationMode mode)
+ {
+ _mode = mode;
+ }
+
+ public virtual ActivationMode Mode()
+ {
+ return _mode;
+ }
+
+ public abstract IActivationDepth Descend(ClassMetadata arg1);
+
+ public abstract bool RequiresActivation();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public sealed class ActivationMode
+ {
+ public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Activate
+ = new Db4objects.Db4o.Internal.Activation.ActivationMode();
+
+ public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Deactivate
+ = new Db4objects.Db4o.Internal.Activation.ActivationMode();
+
+ public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Peek =
+ new Db4objects.Db4o.Internal.Activation.ActivationMode();
+
+ public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Prefetch
+ = new Db4objects.Db4o.Internal.Activation.ActivationMode();
+
+ public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Refresh
+ = new Db4objects.Db4o.Internal.Activation.ActivationMode();
+
+ private ActivationMode()
+ {
+ }
+
+ public override string ToString()
+ {
+ if (IsActivate())
+ {
+ return "ACTIVATE";
+ }
+ if (IsDeactivate())
+ {
+ return "DEACTIVATE";
+ }
+ if (IsPrefetch())
+ {
+ return "PREFETCH";
+ }
+ if (IsRefresh())
+ {
+ return "REFRESH";
+ }
+ return "PEEK";
+ }
+
+ public bool IsDeactivate()
+ {
+ return this == Deactivate;
+ }
+
+ public bool IsActivate()
+ {
+ return this == Activate;
+ }
+
+ public bool IsPeek()
+ {
+ return this == Peek;
+ }
+
+ public bool IsPrefetch()
+ {
+ return this == Prefetch;
+ }
+
+ public bool IsRefresh()
+ {
+ return this == Refresh;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,22 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public sealed class DepthUtil
+ {
+ public static int AdjustDepthToBorders(int depth)
+ {
+ int depthBorder = 2;
+ // TODO when can min value actually occur?
+ if (depth > int.MinValue && depth < depthBorder)
+ {
+ return depthBorder;
+ }
+ return depth;
+ }
+
+ private DepthUtil()
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class DescendingActivationDepth : ActivationDepthImpl
+ {
+ private readonly IActivationDepthProvider _provider;
+
+ public DescendingActivationDepth(IActivationDepthProvider provider, ActivationMode
+ mode) : base(mode)
+ {
+ _provider = provider;
+ }
+
+ public override IActivationDepth Descend(ClassMetadata metadata)
+ {
+ return _provider.ActivationDepthFor(metadata, _mode);
+ }
+
+ public override bool RequiresActivation()
+ {
+ return true;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,52 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ ///
+ /// Activates a fixed depth of the object graph regardless of
+ /// any existing activation depth configuration settings.
+ ///
+ ///
+ /// Activates a fixed depth of the object graph regardless of
+ /// any existing activation depth configuration settings.
+ ///
+ public class FixedActivationDepth : ActivationDepthImpl
+ {
+ private readonly int _depth;
+
+ public FixedActivationDepth(int depth, ActivationMode mode) : base(mode)
+ {
+ _depth = depth;
+ }
+
+ public FixedActivationDepth(int depth) : this(depth, ActivationMode.Activate)
+ {
+ }
+
+ public override bool RequiresActivation()
+ {
+ return _depth > 0;
+ }
+
+ public override IActivationDepth Descend(ClassMetadata metadata)
+ {
+ if (_depth < 1)
+ {
+ return this;
+ }
+ return new Db4objects.Db4o.Internal.Activation.FixedActivationDepth(_depth - 1, _mode
+ );
+ }
+
+ // TODO code duplication in fixed activation/update depth
+ public virtual Db4objects.Db4o.Internal.Activation.FixedActivationDepth AdjustDepthToBorders
+ ()
+ {
+ return new Db4objects.Db4o.Internal.Activation.FixedActivationDepth(DepthUtil.AdjustDepthToBorders
+ (_depth));
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,105 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public abstract class FixedUpdateDepth : IUpdateDepth
+ {
+ private int _depth;
+
+ private bool _tpMode = false;
+
+ public FixedUpdateDepth(int depth)
+ {
+ _depth = depth;
+ }
+
+ public virtual void TpMode(bool tpMode)
+ {
+ _tpMode = tpMode;
+ }
+
+ public virtual bool TpMode()
+ {
+ return _tpMode;
+ }
+
+ public virtual bool SufficientDepth()
+ {
+ return _depth > 0;
+ }
+
+ public virtual bool Negative()
+ {
+ // should never happen?
+ return _depth < 0;
+ }
+
+ public override string ToString()
+ {
+ return GetType().FullName + ": " + _depth;
+ }
+
+ public virtual IUpdateDepth Adjust(ClassMetadata clazz)
+ {
+ if (clazz.CascadesOnDeleteOrUpdate())
+ {
+ return AdjustDepthToBorders().Descend();
+ }
+ return Descend();
+ }
+
+ public virtual bool IsBroaderThan(Db4objects.Db4o.Internal.Activation.FixedUpdateDepth
+ other)
+ {
+ return _depth > other._depth;
+ }
+
+ // TODO code duplication in fixed activation/update depth
+ public virtual Db4objects.Db4o.Internal.Activation.FixedUpdateDepth AdjustDepthToBorders
+ ()
+ {
+ return ForDepth(DepthUtil.AdjustDepthToBorders(_depth));
+ }
+
+ public virtual IUpdateDepth AdjustUpdateDepthForCascade(bool isCollection)
+ {
+ int minimumUpdateDepth = isCollection ? 2 : 1;
+ if (_depth < minimumUpdateDepth)
+ {
+ return ForDepth(minimumUpdateDepth);
+ }
+ return this;
+ }
+
+ public virtual IUpdateDepth Descend()
+ {
+ return ForDepth(_depth - 1);
+ }
+
+ public override bool Equals(object other)
+ {
+ if (this == other)
+ {
+ return true;
+ }
+ if (other == null || GetType() != other.GetType())
+ {
+ return false;
+ }
+ return _depth == ((Db4objects.Db4o.Internal.Activation.FixedUpdateDepth)other)._depth;
+ }
+
+ public override int GetHashCode()
+ {
+ return _depth;
+ }
+
+ protected abstract Db4objects.Db4o.Internal.Activation.FixedUpdateDepth ForDepth(
+ int depth);
+
+ public abstract bool CanSkip(ObjectReference arg1);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ /// Activates the full object graph.
+ /// Activates the full object graph.
+ public class FullActivationDepth : ActivationDepthImpl
+ {
+ public FullActivationDepth(ActivationMode mode) : base(mode)
+ {
+ }
+
+ public FullActivationDepth() : this(ActivationMode.Activate)
+ {
+ }
+
+ public override IActivationDepth Descend(ClassMetadata metadata)
+ {
+ return this;
+ }
+
+ public override bool RequiresActivation()
+ {
+ return true;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ /// Controls how deep an object graph is activated.
+ /// Controls how deep an object graph is activated.
+ public interface IActivationDepth
+ {
+ ActivationMode Mode();
+
+ bool RequiresActivation();
+
+ IActivationDepth Descend(ClassMetadata metadata);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ /// Factory for ActivationDepth strategies.
+ /// Factory for ActivationDepth strategies.
+ public interface IActivationDepthProvider
+ {
+ /// Returns an ActivationDepth suitable for the specified class and activation mode.
+ ///
+ /// Returns an ActivationDepth suitable for the specified class and activation mode.
+ ///
+ /// root class that's being activated
+ /// activation mode
+ /// an appropriate ActivationDepth for the class and activation mode
+ IActivationDepth ActivationDepthFor(ClassMetadata classMetadata, ActivationMode mode
+ );
+
+ /// Returns an ActivationDepth that will activate at most *depth* levels.
+ ///
+ /// Returns an ActivationDepth that will activate at most *depth* levels.
+ /// A special case is Integer.MAX_VALUE (int.MaxValue for .net) for which a
+ /// FullActivationDepth object must be returned.
+ ///
+ ///
+ ///
+ ///
+ IActivationDepth ActivationDepth(int depth, ActivationMode mode);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public interface IFixedDepth
+ {
+ IFixedDepth AdjustDepthToBorders();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,9 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public interface IModifiedObjectQuery
+ {
+ bool IsModified(object obj);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.TA;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ ///
+ public interface ITransparentActivationDepthProvider : IActivationDepthProvider
+ {
+ void EnableTransparentPersistenceSupportFor(IInternalObjectContainer container, IRollbackStrategy
+ withRollbackStrategy);
+
+ void AddModified(object @object, Transaction inTransaction);
+
+ void RemoveModified(object @object, Transaction inTransaction);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,22 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public interface IUpdateDepth
+ {
+ bool SufficientDepth();
+
+ bool Negative();
+
+ IUpdateDepth Adjust(ClassMetadata clazz);
+
+ IUpdateDepth AdjustUpdateDepthForCascade(bool isCollection);
+
+ IUpdateDepth Descend();
+
+ bool CanSkip(ObjectReference @ref);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,13 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public interface IUpdateDepthProvider
+ {
+ UnspecifiedUpdateDepth Unspecified(IModifiedObjectQuery query);
+
+ FixedUpdateDepth ForDepth(int depth);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,67 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ ///
+ /// Activates an object graph to a specific depth respecting any
+ /// activation configuration settings that might be in effect.
+ ///
+ ///
+ /// Activates an object graph to a specific depth respecting any
+ /// activation configuration settings that might be in effect.
+ ///
+ public class LegacyActivationDepth : ActivationDepthImpl
+ {
+ private readonly int _depth;
+
+ public LegacyActivationDepth(int depth) : this(depth, ActivationMode.Activate)
+ {
+ }
+
+ public LegacyActivationDepth(int depth, ActivationMode mode) : base(mode)
+ {
+ _depth = depth;
+ }
+
+ public override IActivationDepth Descend(ClassMetadata metadata)
+ {
+ if (null == metadata)
+ {
+ return new Db4objects.Db4o.Internal.Activation.LegacyActivationDepth(_depth - 1,
+ _mode);
+ }
+ return new Db4objects.Db4o.Internal.Activation.LegacyActivationDepth(DescendDepth
+ (metadata), _mode);
+ }
+
+ private int DescendDepth(ClassMetadata metadata)
+ {
+ int depth = ConfiguredActivationDepth(metadata) - 1;
+ if (metadata.IsStruct())
+ {
+ // We also have to instantiate structs completely every time.
+ return Math.Max(1, depth);
+ }
+ return depth;
+ }
+
+ private int ConfiguredActivationDepth(ClassMetadata metadata)
+ {
+ Config4Class config = metadata.ConfigOrAncestorConfig();
+ if (config != null && _mode.IsActivate())
+ {
+ return config.AdjustActivationDepth(_depth);
+ }
+ return _depth;
+ }
+
+ public override bool RequiresActivation()
+ {
+ return _depth > 0;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,37 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class LegacyActivationDepthProvider : IActivationDepthProvider
+ {
+ public static readonly IActivationDepthProvider Instance = new LegacyActivationDepthProvider
+ ();
+
+ public virtual IActivationDepth ActivationDepthFor(ClassMetadata classMetadata, ActivationMode
+ mode)
+ {
+ if (mode.IsPrefetch())
+ {
+ return new LegacyActivationDepth(1, mode);
+ }
+ int globalLegacyActivationDepth = ConfigImpl(classMetadata).ActivationDepth();
+ Config4Class config = classMetadata.ConfigOrAncestorConfig();
+ int defaultDepth = null == config ? globalLegacyActivationDepth : config.AdjustActivationDepth
+ (globalLegacyActivationDepth);
+ return new LegacyActivationDepth(defaultDepth, mode);
+ }
+
+ public virtual IActivationDepth ActivationDepth(int depth, ActivationMode mode)
+ {
+ return new LegacyActivationDepth(depth, mode);
+ }
+
+ private Config4Impl ConfigImpl(ClassMetadata classMetadata)
+ {
+ return classMetadata.Container().ConfigImpl;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,24 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class LegacyFixedUpdateDepth : FixedUpdateDepth
+ {
+ public LegacyFixedUpdateDepth(int depth) : base(depth)
+ {
+ }
+
+ public override bool CanSkip(ObjectReference @ref)
+ {
+ return false;
+ }
+
+ protected override FixedUpdateDepth ForDepth(int depth)
+ {
+ return new Db4objects.Db4o.Internal.Activation.LegacyFixedUpdateDepth(depth);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class LegacyUnspecifiedUpdateDepth : UnspecifiedUpdateDepth
+ {
+ public static readonly Db4objects.Db4o.Internal.Activation.LegacyUnspecifiedUpdateDepth
+ Instance = new Db4objects.Db4o.Internal.Activation.LegacyUnspecifiedUpdateDepth
+ ();
+
+ private LegacyUnspecifiedUpdateDepth()
+ {
+ }
+
+ public override bool CanSkip(ObjectReference @ref)
+ {
+ return false;
+ }
+
+ protected override FixedUpdateDepth ForDepth(int depth)
+ {
+ return new LegacyFixedUpdateDepth(depth);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class LegacyUpdateDepthProvider : IUpdateDepthProvider
+ {
+ public virtual FixedUpdateDepth ForDepth(int depth)
+ {
+ return new LegacyFixedUpdateDepth(depth);
+ }
+
+ public virtual UnspecifiedUpdateDepth Unspecified(IModifiedObjectQuery query)
+ {
+ return LegacyUnspecifiedUpdateDepth.Instance;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ /// Transparent Activation strategy.
+ /// Transparent Activation strategy.
+ public class NonDescendingActivationDepth : ActivationDepthImpl
+ {
+ public NonDescendingActivationDepth(ActivationMode mode) : base(mode)
+ {
+ }
+
+ public override IActivationDepth Descend(ClassMetadata metadata)
+ {
+ return this;
+ }
+
+ public override bool RequiresActivation()
+ {
+ return false;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class NullModifiedObjectQuery : IModifiedObjectQuery
+ {
+ public static readonly IModifiedObjectQuery Instance = new Db4objects.Db4o.Internal.Activation.NullModifiedObjectQuery
+ ();
+
+ private NullModifiedObjectQuery()
+ {
+ }
+
+ public virtual bool IsModified(object @ref)
+ {
+ return false;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.TA;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class TPFixedUpdateDepth : FixedUpdateDepth
+ {
+ private IModifiedObjectQuery _query;
+
+ public TPFixedUpdateDepth(int depth, IModifiedObjectQuery query) : base(depth)
+ {
+ _query = query;
+ }
+
+ public override bool CanSkip(ObjectReference @ref)
+ {
+ ClassMetadata clazz = @ref.ClassMetadata();
+ return clazz.Reflector().ForClass(typeof(IActivatable)).IsAssignableFrom(clazz.ClassReflector
+ ()) && !_query.IsModified(@ref.GetObject());
+ }
+
+ protected override FixedUpdateDepth ForDepth(int depth)
+ {
+ return new Db4objects.Db4o.Internal.Activation.TPFixedUpdateDepth(depth, _query);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.TA;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class TPUnspecifiedUpdateDepth : UnspecifiedUpdateDepth
+ {
+ private readonly IModifiedObjectQuery _query;
+
+ internal TPUnspecifiedUpdateDepth(IModifiedObjectQuery query)
+ {
+ _query = query;
+ }
+
+ public override bool CanSkip(ObjectReference @ref)
+ {
+ ClassMetadata clazz = @ref.ClassMetadata();
+ return clazz.Reflector().ForClass(typeof(IActivatable)).IsAssignableFrom(clazz.ClassReflector
+ ()) && !_query.IsModified(@ref.GetObject());
+ }
+
+ protected override FixedUpdateDepth ForDepth(int depth)
+ {
+ return new TPFixedUpdateDepth(depth, _query);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,19 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class TPUpdateDepthProvider : IUpdateDepthProvider
+ {
+ public virtual FixedUpdateDepth ForDepth(int depth)
+ {
+ return new TPFixedUpdateDepth(depth, NullModifiedObjectQuery.Instance);
+ }
+
+ public virtual UnspecifiedUpdateDepth Unspecified(IModifiedObjectQuery query)
+ {
+ return new TPUnspecifiedUpdateDepth(query);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,257 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Events;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Reflect.Generic;
+using Db4objects.Db4o.TA;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class TransparentActivationDepthProviderImpl : IActivationDepthProvider, ITransparentActivationDepthProvider
+ {
+ public virtual IActivationDepth ActivationDepth(int depth, ActivationMode mode)
+ {
+ if (int.MaxValue == depth)
+ {
+ return new FullActivationDepth(mode);
+ }
+ return new FixedActivationDepth(depth, mode);
+ }
+
+ public virtual IActivationDepth ActivationDepthFor(ClassMetadata classMetadata, ActivationMode
+ mode)
+ {
+ if (IsTAAware(classMetadata))
+ {
+ return new NonDescendingActivationDepth(mode);
+ }
+ if (mode.IsPrefetch())
+ {
+ return new FixedActivationDepth(1, mode);
+ }
+ return new DescendingActivationDepth(this, mode);
+ }
+
+ private bool IsTAAware(ClassMetadata classMetadata)
+ {
+ GenericReflector reflector = classMetadata.Reflector();
+ return reflector.ForClass(typeof(IActivatable)).IsAssignableFrom(classMetadata.ClassReflector
+ ());
+ }
+
+ private IRollbackStrategy _rollbackStrategy;
+
+ public bool _transparentPersistenceIsEnabled;
+
+ public virtual void EnableTransparentPersistenceSupportFor(IInternalObjectContainer
+ container, IRollbackStrategy rollbackStrategy)
+ {
+ FlushOnQueryStarted(container);
+ _rollbackStrategy = rollbackStrategy;
+ _transparentPersistenceIsEnabled = true;
+ }
+
+ private void FlushOnQueryStarted(IInternalObjectContainer container)
+ {
+ IEventRegistry registry = EventRegistryFactory.ForObjectContainer(container);
+ registry.QueryStarted += new System.EventHandler
+ (new _IEventListener4_46(this).OnEvent);
+ }
+
+ private sealed class _IEventListener4_46
+ {
+ public _IEventListener4_46(TransparentActivationDepthProviderImpl _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void OnEvent(object sender, Db4objects.Db4o.Events.QueryEventArgs args)
+ {
+ this._enclosing.ObjectsModifiedIn(this._enclosing.TransactionFrom(args)).Flush();
+ }
+
+ private readonly TransparentActivationDepthProviderImpl _enclosing;
+ }
+
+ protected virtual Transaction TransactionFrom(EventArgs args)
+ {
+ return (Transaction)((TransactionalEventArgs)args).Transaction();
+ }
+
+ public virtual void AddModified(object @object, Transaction transaction)
+ {
+ if (!_transparentPersistenceIsEnabled)
+ {
+ return;
+ }
+ ObjectsModifiedIn(transaction).Add(@object);
+ }
+
+ public virtual void RemoveModified(object @object, Transaction transaction)
+ {
+ if (!_transparentPersistenceIsEnabled)
+ {
+ return;
+ }
+ ObjectsModifiedIn(transaction).Remove(@object);
+ }
+
+ private sealed class _TransactionLocal_73 : TransactionLocal
+ {
+ public _TransactionLocal_73(TransparentActivationDepthProviderImpl _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public override object InitialValueFor(Transaction transaction)
+ {
+ TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction objectsModifiedInTransaction
+ = new TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction(transaction
+ );
+ transaction.AddTransactionListener(new _ITransactionListener_77(this, objectsModifiedInTransaction
+ ));
+ return objectsModifiedInTransaction;
+ }
+
+ private sealed class _ITransactionListener_77 : ITransactionListener
+ {
+ public _ITransactionListener_77(_TransactionLocal_73 _enclosing, TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction
+ objectsModifiedInTransaction)
+ {
+ this._enclosing = _enclosing;
+ this.objectsModifiedInTransaction = objectsModifiedInTransaction;
+ }
+
+ public void PostRollback()
+ {
+ objectsModifiedInTransaction.Rollback(this._enclosing._enclosing._rollbackStrategy
+ );
+ }
+
+ public void PreCommit()
+ {
+ objectsModifiedInTransaction.Flush();
+ }
+
+ private readonly _TransactionLocal_73 _enclosing;
+
+ private readonly TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction
+ objectsModifiedInTransaction;
+ }
+
+ private readonly TransparentActivationDepthProviderImpl _enclosing;
+ }
+
+ private readonly TransactionLocal _objectsModifiedInTransaction;
+
+ private TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction ObjectsModifiedIn
+ (Transaction transaction)
+ {
+ return ((TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction)transaction
+ .Get(_objectsModifiedInTransaction).value);
+ }
+
+ private sealed class ObjectsModifiedInTransaction
+ {
+ private readonly IdentitySet4 _removedAfterModified = new IdentitySet4();
+
+ private readonly IdentitySet4 _modified = new IdentitySet4();
+
+ private readonly Transaction _transaction;
+
+ public ObjectsModifiedInTransaction(Transaction transaction)
+ {
+ _transaction = transaction;
+ }
+
+ public void Add(object @object)
+ {
+ if (Contains(@object))
+ {
+ return;
+ }
+ _modified.Add(@object);
+ }
+
+ public void Remove(object @object)
+ {
+ if (!Contains(@object))
+ {
+ return;
+ }
+ _modified.Remove(@object);
+ _removedAfterModified.Add(@object);
+ }
+
+ private bool Contains(object @object)
+ {
+ return _modified.Contains(@object);
+ }
+
+ public void Flush()
+ {
+ StoreModifiedObjects();
+ _modified.Clear();
+ }
+
+ private void StoreModifiedObjects()
+ {
+ ObjectContainerBase container = _transaction.Container();
+ container.StoreAll(_transaction, _modified.ValuesIterator(), container.UpdateDepthProvider
+ ().Unspecified(new _IModifiedObjectQuery_132(this)));
+ _transaction.ProcessDeletes();
+ }
+
+ private sealed class _IModifiedObjectQuery_132 : IModifiedObjectQuery
+ {
+ public _IModifiedObjectQuery_132(ObjectsModifiedInTransaction _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public bool IsModified(object obj)
+ {
+ return this._enclosing.Contains(obj);
+ }
+
+ private readonly ObjectsModifiedInTransaction _enclosing;
+ }
+
+ public void Rollback(IRollbackStrategy rollbackStrategy)
+ {
+ ApplyRollbackStrategy(rollbackStrategy);
+ _modified.Clear();
+ }
+
+ private void ApplyRollbackStrategy(IRollbackStrategy rollbackStrategy)
+ {
+ if (null == rollbackStrategy)
+ {
+ return;
+ }
+ ApplyRollbackStrategy(rollbackStrategy, _modified.ValuesIterator());
+ ApplyRollbackStrategy(rollbackStrategy, _removedAfterModified.ValuesIterator());
+ }
+
+ private void ApplyRollbackStrategy(IRollbackStrategy rollbackStrategy, IEnumerator
+ values)
+ {
+ IObjectContainer objectContainer = _transaction.ObjectContainer();
+ while (values.MoveNext())
+ {
+ rollbackStrategy.Rollback(objectContainer, values.Current);
+ }
+ }
+ }
+
+ public TransparentActivationDepthProviderImpl()
+ {
+ _objectsModifiedInTransaction = new _TransactionLocal_73(this);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,33 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public class UnknownActivationDepth : IActivationDepth
+ {
+ public static readonly IActivationDepth Instance = new Db4objects.Db4o.Internal.Activation.UnknownActivationDepth
+ ();
+
+ private UnknownActivationDepth()
+ {
+ }
+
+ public virtual ActivationMode Mode()
+ {
+ throw new InvalidOperationException();
+ }
+
+ public virtual IActivationDepth Descend(ClassMetadata metadata)
+ {
+ throw new InvalidOperationException();
+ }
+
+ public virtual bool RequiresActivation()
+ {
+ throw new InvalidOperationException();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,51 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+
+namespace Db4objects.Db4o.Internal.Activation
+{
+ public abstract class UnspecifiedUpdateDepth : IUpdateDepth
+ {
+ protected UnspecifiedUpdateDepth()
+ {
+ }
+
+ public virtual bool SufficientDepth()
+ {
+ return true;
+ }
+
+ public virtual bool Negative()
+ {
+ return true;
+ }
+
+ public override string ToString()
+ {
+ return GetType().FullName;
+ }
+
+ public virtual IUpdateDepth Adjust(ClassMetadata clazz)
+ {
+ FixedUpdateDepth depth = (FixedUpdateDepth)ForDepth(clazz.UpdateDepthFromConfig()
+ ).Descend();
+ return depth;
+ }
+
+ public virtual IUpdateDepth AdjustUpdateDepthForCascade(bool isCollection)
+ {
+ throw new InvalidOperationException();
+ }
+
+ public virtual IUpdateDepth Descend()
+ {
+ throw new InvalidOperationException();
+ }
+
+ protected abstract FixedUpdateDepth ForDepth(int depth);
+
+ public abstract bool CanSkip(ObjectReference arg1);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,57 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class ArrayType
+ {
+ public static readonly Db4objects.Db4o.Internal.ArrayType None = new Db4objects.Db4o.Internal.ArrayType
+ (0);
+
+ public static readonly Db4objects.Db4o.Internal.ArrayType PlainArray = new Db4objects.Db4o.Internal.ArrayType
+ (3);
+
+ public static readonly Db4objects.Db4o.Internal.ArrayType MultidimensionalArray =
+ new Db4objects.Db4o.Internal.ArrayType(4);
+
+ private ArrayType(int value)
+ {
+ _value = value;
+ }
+
+ private readonly int _value;
+
+ public virtual int Value()
+ {
+ return _value;
+ }
+
+ public static Db4objects.Db4o.Internal.ArrayType ForValue(int value)
+ {
+ switch (value)
+ {
+ case 0:
+ {
+ return None;
+ }
+
+ case 3:
+ {
+ return PlainArray;
+ }
+
+ case 4:
+ {
+ return MultidimensionalArray;
+ }
+
+ default:
+ {
+ throw new ArgumentException();
+ }
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,321 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+#if !SILVERLIGHT
+using System.IO;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Foundation.IO;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Types;
+using Sharpen;
+using Sharpen.IO;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ /// Transfer of blobs to and from the db4o system,
+ /// if users use the Blob Db4oType.
+ ///
+ ///
+ /// Transfer of blobs to and from the db4o system,
+ /// if users use the Blob Db4oType.
+ ///
+ /// com.db4o.internal.blobs
+ ///
+ public class BlobImpl : IBlob, System.ICloneable, IDb4oTypeImpl
+ {
+ public const int CopybufferLength = 4096;
+
+ public string fileName;
+
+ public string i_ext;
+
+ [System.NonSerialized]
+ private Sharpen.IO.File i_file;
+
+ [System.NonSerialized]
+ private IBlobStatus i_getStatusFrom;
+
+ public int i_length;
+
+ [System.NonSerialized]
+ private double i_status = Status.Unused;
+
+ [System.NonSerialized]
+ private ObjectContainerBase i_stream;
+
+ [System.NonSerialized]
+ private Transaction i_trans;
+
+ ///
+ public virtual int AdjustReadDepth(int depth)
+ {
+ return 1;
+ }
+
+ private string CheckExt(Sharpen.IO.File file)
+ {
+ string name = file.GetName();
+ int pos = name.LastIndexOf(".");
+ if (pos > 0)
+ {
+ i_ext = Sharpen.Runtime.Substring(name, pos);
+ return Sharpen.Runtime.Substring(name, 0, pos);
+ }
+ i_ext = string.Empty;
+ return name;
+ }
+
+ ///
+ private static void Copy(Sharpen.IO.File from, Sharpen.IO.File to)
+ {
+ System.IO.File.Copy(from, to);
+ }
+
+ public virtual object CreateDefault(Transaction a_trans)
+ {
+ BlobImpl bi = null;
+ bi = (BlobImpl)this.MemberwiseClone();
+ bi.SetTrans(a_trans);
+ return bi;
+ }
+
+ ///
+ public virtual FileInputStream GetClientInputStream()
+ {
+ return new FileInputStream(i_file);
+ }
+
+ ///
+ public virtual FileOutputStream GetClientOutputStream()
+ {
+ return new FileOutputStream(i_file);
+ }
+
+ public virtual string GetFileName()
+ {
+ return fileName;
+ }
+
+ public virtual int GetLength()
+ {
+ return i_length;
+ }
+
+ public virtual double GetStatus()
+ {
+ if (i_status == Status.Processing && i_getStatusFrom != null)
+ {
+ return i_getStatusFrom.GetStatus();
+ }
+ if (i_status == Status.Unused)
+ {
+ if (i_length > 0)
+ {
+ i_status = Status.Available;
+ }
+ }
+ return i_status;
+ }
+
+ public virtual void GetStatusFrom(IBlobStatus from)
+ {
+ i_getStatusFrom = from;
+ }
+
+ public virtual bool HasClassIndex()
+ {
+ return false;
+ }
+
+ ///
+ public virtual void ReadFrom(Sharpen.IO.File file)
+ {
+ if (!file.Exists())
+ {
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(41, file.GetAbsolutePath
+ ()));
+ }
+ i_length = (int)file.Length();
+ CheckExt(file);
+ if (i_stream.IsClient)
+ {
+ i_file = file;
+ ((IBlobTransport)i_stream).ReadBlobFrom(i_trans, this);
+ }
+ else
+ {
+ ReadLocal(file);
+ }
+ }
+
+ ///
+ public virtual void ReadLocal(Sharpen.IO.File file)
+ {
+ bool copied = false;
+ if (fileName == null)
+ {
+ Sharpen.IO.File newFile = new Sharpen.IO.File(ServerPath(), file.GetName());
+ if (!newFile.Exists())
+ {
+ Copy(file, newFile);
+ copied = true;
+ fileName = newFile.GetName();
+ }
+ }
+ if (!copied)
+ {
+ Copy(file, ServerFile(CheckExt(file), true));
+ }
+ lock (i_stream.Lock())
+ {
+ i_stream.StoreInternal(i_trans, this, false);
+ }
+ i_status = Status.Completed;
+ }
+
+ ///
+ public virtual Sharpen.IO.File ServerFile(string promptName, bool writeToServer)
+ {
+ lock (i_stream.Lock())
+ {
+ i_stream.Activate(i_trans, this, new FixedActivationDepth(2));
+ }
+ string path = ServerPath();
+ i_stream.ConfigImpl.EnsureDirExists(path);
+ if (writeToServer)
+ {
+ if (fileName == null)
+ {
+ if (promptName != null)
+ {
+ fileName = promptName;
+ }
+ else
+ {
+ fileName = "b_" + Runtime.CurrentTimeMillis();
+ }
+ string tryPath = fileName + i_ext;
+ int i = 0;
+ while (new Sharpen.IO.File(path, tryPath).Exists())
+ {
+ tryPath = fileName + "_" + i++ + i_ext;
+ if (i == 99)
+ {
+ // should never happen
+ i_status = Status.Error;
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(40));
+ }
+ }
+ fileName = tryPath;
+ lock (i_stream.Lock())
+ {
+ i_stream.StoreInternal(i_trans, this, false);
+ }
+ }
+ }
+ else
+ {
+ if (fileName == null)
+ {
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(38));
+ }
+ }
+ string lastTryPath = path + Sharpen.IO.File.separator + fileName;
+ if (!writeToServer)
+ {
+ if (!(new Sharpen.IO.File(lastTryPath).Exists()))
+ {
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(39));
+ }
+ }
+ return new Sharpen.IO.File(lastTryPath);
+ }
+
+ ///
+ private string ServerPath()
+ {
+ string path = i_stream.ConfigImpl.BlobPath();
+ if (path == null)
+ {
+ path = "blobs";
+ }
+ i_stream.ConfigImpl.EnsureDirExists(path);
+ return path;
+ }
+
+ public virtual void SetStatus(double status)
+ {
+ i_status = status;
+ }
+
+ public virtual void SetTrans(Transaction a_trans)
+ {
+ i_trans = a_trans;
+ i_stream = a_trans.Container();
+ }
+
+ ///
+ public virtual void WriteLocal(Sharpen.IO.File file)
+ {
+ Copy(ServerFile(null, false), file);
+ i_status = Status.Completed;
+ }
+
+ ///
+ public virtual void WriteTo(Sharpen.IO.File file)
+ {
+ if (GetStatus() == Status.Unused)
+ {
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(43));
+ }
+ if (i_stream.IsClient)
+ {
+ i_file = file;
+ i_status = Status.Queued;
+ ((IBlobTransport)i_stream).WriteBlobTo(i_trans, this);
+ }
+ else
+ {
+ WriteLocal(file);
+ }
+ }
+
+ public virtual void SetObjectReference(ObjectReference objectReference)
+ {
+ }
+
+ // not necessary
+ ///
+ public virtual void DeleteFile()
+ {
+ if (GetStatus() == Status.Unused)
+ {
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(43));
+ }
+ if (i_stream.IsClient)
+ {
+ ((IBlobTransport)i_stream).DeleteBlobFile(i_trans, this);
+ }
+ else
+ {
+ ServerFile(null, false).Delete();
+ }
+ fileName = null;
+ i_ext = null;
+ i_length = 0;
+ SetStatus(Status.Unused);
+ lock (i_stream.Lock())
+ {
+ i_stream.StoreInternal(i_trans, this, false);
+ }
+ }
+
+ object System.ICloneable.Clone()
+ {
+ return MemberwiseClone();
+ }
+ }
+}
+#endif // !SILVERLIGHT
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,43 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Slots;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public sealed class BlockSizeBlockConverter : IBlockConverter
+ {
+ private readonly int _blockSize;
+
+ public BlockSizeBlockConverter(int blockSize)
+ {
+ _blockSize = blockSize;
+ }
+
+ public int BytesToBlocks(long bytes)
+ {
+ return (int)((bytes + _blockSize - 1) / _blockSize);
+ }
+
+ public int BlockAlignedBytes(int bytes)
+ {
+ return BytesToBlocks(bytes) * _blockSize;
+ }
+
+ public int BlocksToBytes(int blocks)
+ {
+ return blocks * _blockSize;
+ }
+
+ public Slot ToBlockedLength(Slot slot)
+ {
+ return new Slot(slot.Address(), BytesToBlocks(slot.Length()));
+ }
+
+ public Slot ToNonBlockedLength(Slot slot)
+ {
+ return new Slot(slot.Address(), BlocksToBytes(slot.Length()));
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,67 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public abstract class AbstractBTreeRangeIterator : IEnumerator
+ {
+ private readonly BTreeRangeSingle _range;
+
+ private BTreePointer _cursor;
+
+ private BTreePointer _current;
+
+ public AbstractBTreeRangeIterator(BTreeRangeSingle range)
+ {
+ _range = range;
+ _cursor = range.First();
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (ReachedEnd(_cursor))
+ {
+ _current = null;
+ return false;
+ }
+ _current = _cursor;
+ _cursor = _cursor.Next();
+ return true;
+ }
+
+ public virtual void Reset()
+ {
+ _cursor = _range.First();
+ }
+
+ protected virtual BTreePointer CurrentPointer()
+ {
+ if (null == _current)
+ {
+ throw new InvalidOperationException();
+ }
+ return _current;
+ }
+
+ private bool ReachedEnd(BTreePointer cursor)
+ {
+ if (cursor == null)
+ {
+ return true;
+ }
+ if (_range.End() == null)
+ {
+ return false;
+ }
+ return _range.End().Equals(cursor);
+ }
+
+ public abstract object Current
+ {
+ get;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,137 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ internal class BTreeAlgebra
+ {
+ public static IBTreeRange Intersect(BTreeRangeUnion union, BTreeRangeSingle single
+ )
+ {
+ SortedCollection4 collection = NewBTreeRangeSingleCollection();
+ CollectIntersections(collection, union, single);
+ return ToRange(collection);
+ }
+
+ public static IBTreeRange Intersect(BTreeRangeUnion union1, BTreeRangeUnion union2
+ )
+ {
+ SortedCollection4 collection = NewBTreeRangeSingleCollection();
+ IEnumerator ranges = union1.Ranges();
+ while (ranges.MoveNext())
+ {
+ BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current;
+ CollectIntersections(collection, union2, current);
+ }
+ return ToRange(collection);
+ }
+
+ private static void CollectIntersections(SortedCollection4 collection, BTreeRangeUnion
+ union, BTreeRangeSingle single)
+ {
+ IEnumerator ranges = union.Ranges();
+ while (ranges.MoveNext())
+ {
+ BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current;
+ if (single.Overlaps(current))
+ {
+ collection.Add(single.Intersect(current));
+ }
+ }
+ }
+
+ public static IBTreeRange Intersect(BTreeRangeSingle single1, BTreeRangeSingle single2
+ )
+ {
+ BTreePointer first = BTreePointer.Max(single1.First(), single2.First());
+ BTreePointer end = BTreePointer.Min(single1.End(), single2.End());
+ return single1.NewBTreeRangeSingle(first, end);
+ }
+
+ public static IBTreeRange Union(BTreeRangeUnion union1, BTreeRangeUnion union2)
+ {
+ IEnumerator ranges = union1.Ranges();
+ IBTreeRange merged = union2;
+ while (ranges.MoveNext())
+ {
+ merged = merged.Union((IBTreeRange)ranges.Current);
+ }
+ return merged;
+ }
+
+ public static IBTreeRange Union(BTreeRangeUnion union, BTreeRangeSingle single)
+ {
+ if (single.IsEmpty())
+ {
+ return union;
+ }
+ SortedCollection4 sorted = NewBTreeRangeSingleCollection();
+ sorted.Add(single);
+ BTreeRangeSingle range = single;
+ IEnumerator ranges = union.Ranges();
+ while (ranges.MoveNext())
+ {
+ BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current;
+ if (CanBeMerged(current, range))
+ {
+ sorted.Remove(range);
+ range = Merge(current, range);
+ sorted.Add(range);
+ }
+ else
+ {
+ sorted.Add(current);
+ }
+ }
+ return ToRange(sorted);
+ }
+
+ private static IBTreeRange ToRange(SortedCollection4 sorted)
+ {
+ if (1 == sorted.Size())
+ {
+ return (IBTreeRange)sorted.SingleElement();
+ }
+ return new BTreeRangeUnion(sorted);
+ }
+
+ private static SortedCollection4 NewBTreeRangeSingleCollection()
+ {
+ return new SortedCollection4(BTreeRangeSingle.Comparison);
+ }
+
+ public static IBTreeRange Union(BTreeRangeSingle single1, BTreeRangeSingle single2
+ )
+ {
+ if (single1.IsEmpty())
+ {
+ return single2;
+ }
+ if (single2.IsEmpty())
+ {
+ return single1;
+ }
+ if (CanBeMerged(single1, single2))
+ {
+ return Merge(single1, single2);
+ }
+ return new BTreeRangeUnion(new BTreeRangeSingle[] { single1, single2 });
+ }
+
+ private static BTreeRangeSingle Merge(BTreeRangeSingle range1, BTreeRangeSingle range2
+ )
+ {
+ return range1.NewBTreeRangeSingle(BTreePointer.Min(range1.First(), range2.First()
+ ), BTreePointer.Max(range1.End(), range2.End()));
+ }
+
+ private static bool CanBeMerged(BTreeRangeSingle range1, BTreeRangeSingle range2)
+ {
+ return range1.Overlaps(range2) || range1.Adjacent(range2);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,36 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public abstract class BTreeRangeOperation : IBTreeRangeVisitor
+ {
+ private IBTreeRange _resultingRange;
+
+ public BTreeRangeOperation() : base()
+ {
+ }
+
+ public virtual IBTreeRange Dispatch(IBTreeRange range)
+ {
+ range.Accept(this);
+ return _resultingRange;
+ }
+
+ public void Visit(BTreeRangeSingle single)
+ {
+ _resultingRange = Execute(single);
+ }
+
+ public void Visit(BTreeRangeUnion union)
+ {
+ _resultingRange = Execute(union);
+ }
+
+ protected abstract IBTreeRange Execute(BTreeRangeUnion union);
+
+ protected abstract IBTreeRange Execute(BTreeRangeSingle single);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public class BTreeRangeSingleIntersect : BTreeRangeSingleOperation
+ {
+ public BTreeRangeSingleIntersect(BTreeRangeSingle single) : base(single)
+ {
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeSingle single)
+ {
+ return BTreeAlgebra.Intersect(_single, single);
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeUnion union)
+ {
+ return BTreeAlgebra.Intersect(union, _single);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public abstract class BTreeRangeSingleOperation : BTreeRangeOperation
+ {
+ protected readonly BTreeRangeSingle _single;
+
+ public BTreeRangeSingleOperation(BTreeRangeSingle single)
+ {
+ _single = single;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public class BTreeRangeSingleUnion : BTreeRangeSingleOperation
+ {
+ public BTreeRangeSingleUnion(BTreeRangeSingle single) : base(single)
+ {
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeSingle single)
+ {
+ return BTreeAlgebra.Union(_single, single);
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeUnion union)
+ {
+ return BTreeAlgebra.Union(union, _single);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public class BTreeRangeUnionIntersect : BTreeRangeUnionOperation
+ {
+ public BTreeRangeUnionIntersect(BTreeRangeUnion union) : base(union)
+ {
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeSingle range)
+ {
+ return BTreeAlgebra.Intersect(_union, range);
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeUnion union)
+ {
+ return BTreeAlgebra.Intersect(_union, union);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public abstract class BTreeRangeUnionOperation : BTreeRangeOperation
+ {
+ protected readonly BTreeRangeUnion _union;
+
+ public BTreeRangeUnionOperation(BTreeRangeUnion union)
+ {
+ _union = union;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree.Algebra
+{
+ ///
+ public class BTreeRangeUnionUnion : BTreeRangeUnionOperation
+ {
+ public BTreeRangeUnionUnion(BTreeRangeUnion union) : base(union)
+ {
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeUnion union)
+ {
+ return BTreeAlgebra.Union(_union, union);
+ }
+
+ protected override IBTreeRange Execute(BTreeRangeSingle single)
+ {
+ return BTreeAlgebra.Union(_union, single);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,73 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeAdd : BTreePatch
+ {
+ public BTreeAdd(Transaction transaction, object obj) : base(transaction, obj)
+ {
+ }
+
+ protected virtual object RolledBack(BTree btree)
+ {
+ btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject()));
+ return No4.Instance;
+ }
+
+ public override string ToString()
+ {
+ return "(+) " + base.ToString();
+ }
+
+ public override object Commit(Transaction trans, BTree btree, BTreeNode node)
+ {
+ if (_transaction == trans)
+ {
+ return GetObject();
+ }
+ return this;
+ }
+
+ public override BTreePatch ForTransaction(Transaction trans)
+ {
+ if (_transaction == trans)
+ {
+ return this;
+ }
+ return null;
+ }
+
+ public override object Key(Transaction trans)
+ {
+ if (_transaction != trans)
+ {
+ return No4.Instance;
+ }
+ return GetObject();
+ }
+
+ public override object Rollback(Transaction trans, BTree btree)
+ {
+ if (_transaction == trans)
+ {
+ return RolledBack(btree);
+ }
+ return this;
+ }
+
+ public override bool IsAdd()
+ {
+ return true;
+ }
+
+ public override int SizeDiff(Transaction trans)
+ {
+ return _transaction == trans ? 1 : 0;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,54 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeCancelledRemoval : BTreeUpdate
+ {
+ private readonly object _newKey;
+
+ public BTreeCancelledRemoval(Transaction transaction, object originalKey, object
+ newKey, BTreeUpdate existingPatches) : base(transaction, originalKey)
+ {
+ _newKey = newKey;
+ if (null != existingPatches)
+ {
+ Append(existingPatches);
+ }
+ }
+
+ protected override void Committed(BTree btree)
+ {
+ }
+
+ // do nothing
+ public override bool IsCancelledRemoval()
+ {
+ return true;
+ }
+
+ public override string ToString()
+ {
+ return "(u) " + base.ToString();
+ }
+
+ protected override object GetCommittedObject()
+ {
+ return _newKey;
+ }
+
+ protected override void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode
+ node)
+ {
+ }
+
+ // The other transaction reduces the size, this entry ignores.
+ protected override int SizeDiff()
+ {
+ return 1;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,37 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Ids;
+using Db4objects.Db4o.Internal.Slots;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeConfiguration
+ {
+ public static readonly Db4objects.Db4o.Internal.Btree.BTreeConfiguration Default =
+ new Db4objects.Db4o.Internal.Btree.BTreeConfiguration(null, 20, true);
+
+ public readonly ITransactionalIdSystem _idSystem;
+
+ public readonly SlotChangeFactory _slotChangeFactory;
+
+ public readonly bool _canEnlistWithTransaction;
+
+ public readonly int _cacheSize;
+
+ public BTreeConfiguration(ITransactionalIdSystem idSystem, SlotChangeFactory slotChangeFactory
+ , int cacheSize, bool canEnlistWithTransaction)
+ {
+ _idSystem = idSystem;
+ _slotChangeFactory = slotChangeFactory;
+ _canEnlistWithTransaction = canEnlistWithTransaction;
+ _cacheSize = cacheSize;
+ }
+
+ public BTreeConfiguration(ITransactionalIdSystem idSystem, int cacheSize, bool canEnlistWithTransaction
+ ) : this(idSystem, SlotChangeFactory.SystemObjects, cacheSize, canEnlistWithTransaction
+ )
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,909 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using System.Text;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Defragment;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Caching;
+using Db4objects.Db4o.Internal.Ids;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTree : LocalPersistentBase, ITransactionParticipant, IBTreeStructureListener
+ {
+ private readonly BTreeConfiguration _config;
+
+ private const byte BtreeVersion = (byte)1;
+
+ private const int DefragmentIncrementOffset = 1 + Const4.IntLength * 2;
+
+ private readonly IIndexable4 _keyHandler;
+
+ private BTreeNode _root;
+
+ /// All instantiated nodes are held in this tree.
+ /// All instantiated nodes are held in this tree.
+ private TreeIntObject _nodes;
+
+ private int _size;
+
+ private IVisitor4 _removeListener;
+
+ private sealed class _TransactionLocal_40 : TransactionLocal
+ {
+ public _TransactionLocal_40()
+ {
+ }
+
+ // version byte
+ // size, node size
+ public override object InitialValueFor(Transaction transaction)
+ {
+ return 0;
+ }
+ }
+
+ private readonly TransactionLocal _sizeDeltaInTransaction = new _TransactionLocal_40
+ ();
+
+ protected IQueue4 _processing;
+
+ private int _nodeSize;
+
+ internal int _halfNodeSize;
+
+ private IBTreeStructureListener _structureListener;
+
+ private readonly ICache4 _nodeCache;
+
+ private TreeIntObject _evictedFromCache;
+
+ private bool _disposed;
+
+ public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler
+ , int treeNodeSize) : base(config._idSystem)
+ {
+ _config = config;
+ if (null == keyHandler)
+ {
+ throw new ArgumentNullException();
+ }
+ _nodeSize = treeNodeSize;
+ _nodeCache = CacheFactory.NewLRUIntCache(config._cacheSize);
+ _halfNodeSize = _nodeSize / 2;
+ _nodeSize = _halfNodeSize * 2;
+ _keyHandler = keyHandler;
+ SetID(id);
+ if (IsNew())
+ {
+ SetStateDirty();
+ _root = new BTreeNode(this, 0, true, 0, 0, 0);
+ _root.Write(trans.SystemTransaction());
+ AddNode(_root);
+ Write(trans.SystemTransaction());
+ }
+ else
+ {
+ SetStateDeactivated();
+ }
+ }
+
+ public BTree(Transaction trans, BTreeConfiguration config, IIndexable4 keyHandler
+ ) : this(trans, config, 0, keyHandler)
+ {
+ }
+
+ public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler
+ ) : this(trans, config, id, keyHandler, Config(trans).BTreeNodeSize())
+ {
+ }
+
+ public BTree(Transaction trans, int id, IIndexable4 keyHandler) : this(trans, BTreeConfiguration
+ .Default, id, keyHandler)
+ {
+ }
+
+ public BTree(Transaction trans, int id, IIndexable4 keyHandler, int nodeSize) : this
+ (trans, BTreeConfiguration.Default, id, keyHandler, nodeSize)
+ {
+ }
+
+ public virtual BTreeNode Root()
+ {
+ return _root;
+ }
+
+ public virtual int NodeSize()
+ {
+ return _nodeSize;
+ }
+
+ public virtual void Add(Transaction trans, object key)
+ {
+ KeyCantBeNull(key);
+ IPreparedComparison preparedComparison = _keyHandler.PrepareComparison(trans.Context
+ (), key);
+ Add(trans, preparedComparison, key);
+ }
+
+ public virtual void Add(Transaction trans, IPreparedComparison preparedComparison
+ , object key)
+ {
+ EnsureActive(trans);
+ Enlist(trans);
+ BTreeNode rootOrSplit = _root.Add(trans, preparedComparison, key);
+ if (rootOrSplit != null && rootOrSplit != _root)
+ {
+ EnsureDirty(trans);
+ _root = new BTreeNode(trans, _root, rootOrSplit);
+ _root.Write(trans.SystemTransaction());
+ AddNode(_root);
+ }
+ ConvertCacheEvictedNodesToReadMode();
+ }
+
+ public virtual object Remove(Transaction trans, object key)
+ {
+ BTreePointer bTreePointer = SearchPointer(trans, key);
+ if (bTreePointer == null)
+ {
+ return null;
+ }
+ object result = bTreePointer.Key();
+ Enlist(trans);
+ IPreparedComparison preparedComparison = KeyHandler().PrepareComparison(trans.Context
+ (), key);
+ BTreeNode node = bTreePointer.Node();
+ node.Remove(trans, preparedComparison, key, bTreePointer.Index());
+ ConvertCacheEvictedNodesToReadMode();
+ return result;
+ }
+
+ public virtual IBTreeRange SearchRange(Transaction trans, object key)
+ {
+ KeyCantBeNull(key);
+ return SearchRange(trans, KeyHandler().PrepareComparison(trans.Context(), key));
+ }
+
+ public virtual BTreePointer SearchPointer(Transaction trans, object key)
+ {
+ EnsureActive(trans);
+ KeyCantBeNull(key);
+ IPreparedComparison preparedComparison = KeyHandler().PrepareComparison(trans.Context
+ (), key);
+ BTreeNodeSearchResult start = SearchLeaf(trans, preparedComparison, SearchTarget.
+ Lowest);
+ BTreePointer bTreePointer = start.FirstValidPointer();
+ if (bTreePointer == null)
+ {
+ ConvertCacheEvictedNodesToReadMode();
+ return null;
+ }
+ object found = bTreePointer.Key();
+ ConvertCacheEvictedNodesToReadMode();
+ if (preparedComparison.CompareTo(found) == 0)
+ {
+ return bTreePointer;
+ }
+ return null;
+ }
+
+ public virtual object Search(Transaction trans, object key)
+ {
+ BTreePointer bTreePointer = SearchPointer(trans, key);
+ if (bTreePointer != null)
+ {
+ return bTreePointer.Key();
+ }
+ return null;
+ }
+
+ private IBTreeRange SearchRange(Transaction trans, IPreparedComparison preparedComparison
+ )
+ {
+ EnsureActive(trans);
+ // TODO: Optimize the following.
+ // Part of the search operates against the same nodes.
+ // As long as the bounds are on one node, the search
+ // should walk the nodes in one go.
+ BTreeNodeSearchResult start = SearchLeaf(trans, preparedComparison, SearchTarget.
+ Lowest);
+ BTreeNodeSearchResult end = SearchLeaf(trans, preparedComparison, SearchTarget.Highest
+ );
+ IBTreeRange range = start.CreateIncludingRange(end);
+ ConvertCacheEvictedNodesToReadMode();
+ return range;
+ }
+
+ private void KeyCantBeNull(object key)
+ {
+ if (null == key)
+ {
+ throw new ArgumentNullException();
+ }
+ }
+
+ public virtual IIndexable4 KeyHandler()
+ {
+ return _keyHandler;
+ }
+
+ public virtual BTreeNodeSearchResult SearchLeaf(Transaction trans, object key, SearchTarget
+ target)
+ {
+ return SearchLeaf(trans, _keyHandler.PrepareComparison(trans.Context(), key), target
+ );
+ }
+
+ public virtual BTreeNodeSearchResult SearchLeaf(Transaction trans, IPreparedComparison
+ preparedComparison, SearchTarget target)
+ {
+ EnsureActive(trans);
+ BTreeNodeSearchResult result = _root.SearchLeaf(trans, preparedComparison, target
+ );
+ ConvertCacheEvictedNodesToReadMode();
+ return result;
+ }
+
+ public virtual void Commit(Transaction transaction)
+ {
+ if (_disposed)
+ {
+ return;
+ }
+ UpdateSize(transaction);
+ CommitNodes(transaction);
+ FinishTransaction(transaction);
+ ConvertCacheEvictedNodesToReadMode();
+ }
+
+ private void UpdateSize(Transaction transaction)
+ {
+ ByRef sizeInTransaction = SizeIn(transaction);
+ int sizeModification = (((int)sizeInTransaction.value));
+ if (sizeModification == 0)
+ {
+ return;
+ }
+ EnsureDirty(transaction);
+ _size += sizeModification;
+ sizeInTransaction.value = 0;
+ }
+
+ private ByRef SizeIn(Transaction trans)
+ {
+ return trans.Get(_sizeDeltaInTransaction);
+ }
+
+ private void CommitNodes(Transaction trans)
+ {
+ ProcessEachNode(new _IProcedure4_237(trans));
+ }
+
+ private sealed class _IProcedure4_237 : IProcedure4
+ {
+ public _IProcedure4_237(Transaction trans)
+ {
+ this.trans = trans;
+ }
+
+ public void Apply(object node)
+ {
+ ((BTreeNode)node).Commit(trans);
+ }
+
+ private readonly Transaction trans;
+ }
+
+ private void ProcessEachNode(IProcedure4 action)
+ {
+ if (_nodes == null)
+ {
+ return;
+ }
+ ProcessAllNodes();
+ while (_processing.HasNext())
+ {
+ action.Apply((BTreeNode)_processing.Next());
+ }
+ _processing = null;
+ }
+
+ public virtual void Rollback(Transaction trans)
+ {
+ RollbackNodes(trans);
+ FinishTransaction(trans);
+ ConvertCacheEvictedNodesToReadMode();
+ }
+
+ private void FinishTransaction(Transaction trans)
+ {
+ Transaction systemTransaction = trans.SystemTransaction();
+ WriteAllNodes(systemTransaction);
+ Write(systemTransaction);
+ Purge();
+ }
+
+ private void RollbackNodes(Transaction trans)
+ {
+ ProcessEachNode(new _IProcedure4_266(trans));
+ }
+
+ private sealed class _IProcedure4_266 : IProcedure4
+ {
+ public _IProcedure4_266(Transaction trans)
+ {
+ this.trans = trans;
+ }
+
+ public void Apply(object node)
+ {
+ ((BTreeNode)node).Rollback(trans);
+ }
+
+ private readonly Transaction trans;
+ }
+
+ private void WriteAllNodes(Transaction systemTransaction)
+ {
+ if (_nodes == null)
+ {
+ return;
+ }
+ _nodes.Traverse(new _IVisitor4_275(systemTransaction));
+ }
+
+ private sealed class _IVisitor4_275 : IVisitor4
+ {
+ public _IVisitor4_275(Transaction systemTransaction)
+ {
+ this.systemTransaction = systemTransaction;
+ }
+
+ public void Visit(object obj)
+ {
+ ((BTreeNode)((TreeIntObject)obj).GetObject()).Write(systemTransaction);
+ }
+
+ private readonly Transaction systemTransaction;
+ }
+
+ private void Purge()
+ {
+ if (_nodes == null)
+ {
+ return;
+ }
+ Tree temp = _nodes;
+ _nodes = null;
+ _root.HoldChildrenAsIDs();
+ AddNode(_root);
+ temp.Traverse(new _IVisitor4_294());
+ for (IEnumerator entryIter = _nodeCache.GetEnumerator(); entryIter.MoveNext(); )
+ {
+ BTreeNodeCacheEntry entry = ((BTreeNodeCacheEntry)entryIter.Current);
+ entry._node.HoldChildrenAsIDs();
+ }
+ }
+
+ private sealed class _IVisitor4_294 : IVisitor4
+ {
+ public _IVisitor4_294()
+ {
+ }
+
+ public void Visit(object obj)
+ {
+ BTreeNode node = (BTreeNode)((TreeIntObject)obj).GetObject();
+ node.Purge();
+ }
+ }
+
+ private void ProcessAllNodes()
+ {
+ _processing = new NonblockingQueue();
+ _nodes.Traverse(new _IVisitor4_311(this));
+ }
+
+ private sealed class _IVisitor4_311 : IVisitor4
+ {
+ public _IVisitor4_311(BTree _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void Visit(object node)
+ {
+ this._enclosing._processing.Add(((TreeIntObject)node).GetObject());
+ }
+
+ private readonly BTree _enclosing;
+ }
+
+ private void EnsureActive(Transaction trans)
+ {
+ if (!IsActive())
+ {
+ Read(trans.SystemTransaction());
+ }
+ }
+
+ private void EnsureDirty(Transaction trans)
+ {
+ EnsureActive(trans);
+ Enlist(trans);
+ SetStateDirty();
+ }
+
+ private void Enlist(Transaction trans)
+ {
+ if (CanEnlistWithTransaction())
+ {
+ ((LocalTransaction)trans).Enlist(this);
+ }
+ }
+
+ protected virtual bool CanEnlistWithTransaction()
+ {
+ return _config._canEnlistWithTransaction;
+ }
+
+ public override byte GetIdentifier()
+ {
+ return Const4.Btree;
+ }
+
+ public virtual void SetRemoveListener(IVisitor4 vis)
+ {
+ _removeListener = vis;
+ }
+
+ public override int OwnLength()
+ {
+ return 1 + Const4.ObjectLength + (Const4.IntLength * 2) + Const4.IdLength;
+ }
+
+ public virtual BTreeNode ProduceNode(int id)
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.BtreeProduceNode.Log(id);
+ }
+ TreeIntObject addtio = new TreeIntObject(id);
+ _nodes = (TreeIntObject)((TreeIntObject)Tree.Add(_nodes, addtio));
+ TreeIntObject tio = (TreeIntObject)addtio.AddedOrExisting();
+ BTreeNode node = (BTreeNode)tio.GetObject();
+ if (node == null)
+ {
+ node = CacheEntry(new BTreeNode(id, this))._node;
+ tio.SetObject(node);
+ AddToProcessing(node);
+ }
+ return node;
+ }
+
+ internal virtual void AddNode(BTreeNode node)
+ {
+ _nodes = (TreeIntObject)((TreeIntObject)Tree.Add(_nodes, new TreeIntObject(node.GetID
+ (), node)));
+ AddToProcessing(node);
+ }
+
+ internal virtual void AddToProcessing(BTreeNode node)
+ {
+ if (_processing != null)
+ {
+ _processing.Add(node);
+ }
+ }
+
+ internal virtual void RemoveNode(BTreeNode node)
+ {
+ _nodes = (TreeIntObject)((TreeInt)_nodes.RemoveLike(new TreeInt(node.GetID())));
+ }
+
+ internal virtual void NotifyRemoveListener(object obj)
+ {
+ if (_removeListener != null)
+ {
+ _removeListener.Visit(obj);
+ }
+ }
+
+ public override void ReadThis(Transaction a_trans, ByteArrayBuffer a_reader)
+ {
+ a_reader.IncrementOffset(1);
+ // first byte is version, for possible future format changes
+ _size = a_reader.ReadInt();
+ _nodeSize = a_reader.ReadInt();
+ _halfNodeSize = NodeSize() / 2;
+ _root = ProduceNode(a_reader.ReadInt());
+ }
+
+ public override void WriteThis(Transaction trans, ByteArrayBuffer a_writer)
+ {
+ a_writer.WriteByte(BtreeVersion);
+ a_writer.WriteInt(_size);
+ a_writer.WriteInt(NodeSize());
+ a_writer.WriteIDOf(trans, _root);
+ }
+
+ public virtual int Size(Transaction trans)
+ {
+ // This implementation of size will not work accurately for multiple
+ // transactions. If two transactions call clear and both commit, _size
+ // can end up negative.
+ // For multiple transactions the size patches only are an estimate.
+ EnsureActive(trans);
+ return _size + (((int)SizeIn(trans).value));
+ }
+
+ public virtual void TraverseKeys(Transaction trans, IVisitor4 visitor)
+ {
+ EnsureActive(trans);
+ if (_root == null)
+ {
+ return;
+ }
+ _root.TraverseKeys(trans, visitor);
+ ConvertCacheEvictedNodesToReadMode();
+ }
+
+ public virtual void SizeChanged(Transaction transaction, BTreeNode node, int changeBy
+ )
+ {
+ NotifyCountChanged(transaction, node, changeBy);
+ ByRef sizeInTransaction = SizeIn(transaction);
+ sizeInTransaction.value = (((int)sizeInTransaction.value)) + changeBy;
+ }
+
+ public virtual void Dispose(Transaction transaction)
+ {
+ }
+
+ public virtual BTreePointer FirstPointer(Transaction trans)
+ {
+ EnsureActive(trans);
+ if (null == _root)
+ {
+ return null;
+ }
+ BTreePointer pointer = _root.FirstPointer(trans);
+ ConvertCacheEvictedNodesToReadMode();
+ return pointer;
+ }
+
+ public virtual BTreePointer LastPointer(Transaction trans)
+ {
+ EnsureActive(trans);
+ if (null == _root)
+ {
+ return null;
+ }
+ BTreePointer pointer = _root.LastPointer(trans);
+ ConvertCacheEvictedNodesToReadMode();
+ return pointer;
+ }
+
+ public virtual Db4objects.Db4o.Internal.Btree.BTree DebugLoadFully(Transaction trans
+ )
+ {
+ EnsureActive(trans);
+ _root.DebugLoadFully(trans);
+ return this;
+ }
+
+ private void TraverseAllNodes(Transaction trans, IVisitor4 command)
+ {
+ EnsureActive(trans);
+ _root.TraverseAllNodes(trans, command);
+ }
+
+ public virtual void DefragIndex(DefragmentContextImpl context)
+ {
+ context.IncrementOffset(DefragmentIncrementOffset);
+ context.CopyID();
+ }
+
+ public virtual void DefragIndexNode(DefragmentContextImpl context)
+ {
+ BTreeNode.DefragIndex(context, _keyHandler);
+ }
+
+ public virtual void DefragBTree(IDefragmentServices services)
+ {
+ DefragmentContextImpl.ProcessCopy(services, GetID(), new _ISlotCopyHandler_481(this
+ ));
+ services.TraverseAllIndexSlots(this, new _IVisitor4_486(this, services));
+ ConvertCacheEvictedNodesToReadMode();
+ }
+
+ private sealed class _ISlotCopyHandler_481 : ISlotCopyHandler
+ {
+ public _ISlotCopyHandler_481(BTree _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void ProcessCopy(DefragmentContextImpl context)
+ {
+ this._enclosing.DefragIndex(context);
+ }
+
+ private readonly BTree _enclosing;
+ }
+
+ private sealed class _IVisitor4_486 : IVisitor4
+ {
+ public _IVisitor4_486(BTree _enclosing, IDefragmentServices services)
+ {
+ this._enclosing = _enclosing;
+ this.services = services;
+ }
+
+ public void Visit(object obj)
+ {
+ int id = ((int)obj);
+ DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_489(this));
+ }
+
+ private sealed class _ISlotCopyHandler_489 : ISlotCopyHandler
+ {
+ public _ISlotCopyHandler_489(_IVisitor4_486 _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void ProcessCopy(DefragmentContextImpl context)
+ {
+ this._enclosing._enclosing.DefragIndexNode(context);
+ }
+
+ private readonly _IVisitor4_486 _enclosing;
+ }
+
+ private readonly BTree _enclosing;
+
+ private readonly IDefragmentServices services;
+ }
+
+ internal virtual int CompareKeys(IContext context, object key1, object key2)
+ {
+ IPreparedComparison preparedComparison = _keyHandler.PrepareComparison(context, key1
+ );
+ return preparedComparison.CompareTo(key2);
+ }
+
+ private static Config4Impl Config(Transaction trans)
+ {
+ if (null == trans)
+ {
+ throw new ArgumentNullException();
+ }
+ return trans.Container().ConfigImpl;
+ }
+
+ public override void Free(LocalTransaction systemTrans)
+ {
+ _disposed = true;
+ FreeAllNodeIds(systemTrans, AllNodeIds(systemTrans));
+ base.Free((LocalTransaction)systemTrans);
+ }
+
+ private void FreeAllNodeIds(LocalTransaction systemTrans, IEnumerator allNodeIDs)
+ {
+ ITransactionalIdSystem idSystem = IdSystem(systemTrans);
+ while (allNodeIDs.MoveNext())
+ {
+ int id = ((int)allNodeIDs.Current);
+ idSystem.NotifySlotDeleted(id, SlotChangeFactory());
+ }
+ }
+
+ public virtual IEnumerator AllNodeIds(Transaction systemTrans)
+ {
+ Collection4 allNodeIDs = new Collection4();
+ TraverseAllNodes(systemTrans, new _IVisitor4_527(allNodeIDs));
+ return allNodeIDs.GetEnumerator();
+ }
+
+ private sealed class _IVisitor4_527 : IVisitor4
+ {
+ public _IVisitor4_527(Collection4 allNodeIDs)
+ {
+ this.allNodeIDs = allNodeIDs;
+ }
+
+ public void Visit(object node)
+ {
+ allNodeIDs.Add(((BTreeNode)node).GetID());
+ }
+
+ private readonly Collection4 allNodeIDs;
+ }
+
+ public virtual IBTreeRange AsRange(Transaction trans)
+ {
+ return new BTreeRangeSingle(trans, this, FirstPointer(trans), null);
+ }
+
+ private void TraverseAllNodes(IVisitor4 visitor)
+ {
+ if (_nodes == null)
+ {
+ return;
+ }
+ _nodes.Traverse(new _IVisitor4_543(visitor));
+ }
+
+ private sealed class _IVisitor4_543 : IVisitor4
+ {
+ public _IVisitor4_543(IVisitor4 visitor)
+ {
+ this.visitor = visitor;
+ }
+
+ public void Visit(object obj)
+ {
+ visitor.Visit(((TreeIntObject)obj).GetObject());
+ }
+
+ private readonly IVisitor4 visitor;
+ }
+
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("BTree ");
+ sb.Append(GetID());
+ sb.Append(" Active Nodes: \n");
+ TraverseAllNodes(new _IVisitor4_555(sb));
+ return sb.ToString();
+ }
+
+ private sealed class _IVisitor4_555 : IVisitor4
+ {
+ public _IVisitor4_555(StringBuilder sb)
+ {
+ this.sb = sb;
+ }
+
+ public void Visit(object obj)
+ {
+ sb.Append(obj);
+ sb.Append("\n");
+ }
+
+ private readonly StringBuilder sb;
+ }
+
+ public virtual void StructureListener(IBTreeStructureListener listener)
+ {
+ _structureListener = listener;
+ }
+
+ public virtual void NotifySplit(Transaction trans, BTreeNode originalNode, BTreeNode
+ newRightNode)
+ {
+ if (_structureListener != null)
+ {
+ _structureListener.NotifySplit(trans, originalNode, newRightNode);
+ }
+ }
+
+ public virtual void NotifyDeleted(Transaction trans, BTreeNode node)
+ {
+ if (_structureListener != null)
+ {
+ _structureListener.NotifyDeleted(trans, node);
+ }
+ }
+
+ public virtual void NotifyCountChanged(Transaction trans, BTreeNode node, int diff
+ )
+ {
+ if (_structureListener != null)
+ {
+ _structureListener.NotifyCountChanged(trans, node, diff);
+ }
+ }
+
+ public virtual IEnumerator Iterator(Transaction trans)
+ {
+ return new BTreeIterator(trans, this);
+ }
+
+ public virtual void Clear(Transaction transaction)
+ {
+ BTreePointer currentPointer = FirstPointer(transaction);
+ while (currentPointer != null && currentPointer.IsValid())
+ {
+ BTreeNode node = currentPointer.Node();
+ int index = currentPointer.Index();
+ node.Remove(transaction, index);
+ currentPointer = currentPointer.Next();
+ }
+ }
+
+ public virtual ICache4 NodeCache()
+ {
+ return _nodeCache;
+ }
+
+ internal virtual BTreeNodeCacheEntry CacheEntry(BTreeNode node)
+ {
+ return ((BTreeNodeCacheEntry)_nodeCache.Produce(node.GetID(), new _IFunction4_605
+ (node), new _IProcedure4_609(this)));
+ }
+
+ private sealed class _IFunction4_605 : IFunction4
+ {
+ public _IFunction4_605(BTreeNode node)
+ {
+ this.node = node;
+ }
+
+ public object Apply(object id)
+ {
+ return new BTreeNodeCacheEntry(node);
+ }
+
+ private readonly BTreeNode node;
+ }
+
+ private sealed class _IProcedure4_609 : IProcedure4
+ {
+ public _IProcedure4_609(BTree _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void Apply(object entry)
+ {
+ this._enclosing.EvictedFromCache(((BTreeNodeCacheEntry)entry)._node);
+ }
+
+ private readonly BTree _enclosing;
+ }
+
+ public override Db4objects.Db4o.Internal.Slots.SlotChangeFactory SlotChangeFactory
+ ()
+ {
+ return _config._slotChangeFactory;
+ }
+
+ public virtual void EvictedFromCache(BTreeNode node)
+ {
+ _evictedFromCache = ((TreeIntObject)Tree.Add(_evictedFromCache, new TreeIntObject
+ (node.GetID(), node)));
+ }
+
+ public virtual void ConvertCacheEvictedNodesToReadMode()
+ {
+ if (_evictedFromCache == null)
+ {
+ return;
+ }
+ Tree.Traverse(_evictedFromCache, new _IVisitor4_628());
+ _evictedFromCache = null;
+ }
+
+ private sealed class _IVisitor4_628 : IVisitor4
+ {
+ public _IVisitor4_628()
+ {
+ }
+
+ public void Visit(object treeIntObject)
+ {
+ ((BTreeNode)((TreeIntObject)treeIntObject)._object).ToReadMode();
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,67 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeIterator : IEnumerator
+ {
+ private readonly Transaction _transaction;
+
+ private readonly BTree _bTree;
+
+ private BTreePointer _currentPointer;
+
+ private bool _beyondEnd;
+
+ public BTreeIterator(Transaction trans, BTree bTree)
+ {
+ _transaction = trans;
+ _bTree = bTree;
+ }
+
+ public virtual object Current
+ {
+ get
+ {
+ if (_currentPointer == null)
+ {
+ throw new InvalidOperationException();
+ }
+ return _currentPointer.Key();
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ if (_beyondEnd)
+ {
+ return false;
+ }
+ if (BeforeFirst())
+ {
+ _currentPointer = _bTree.FirstPointer(_transaction);
+ }
+ else
+ {
+ _currentPointer = _currentPointer.Next();
+ }
+ _beyondEnd = (_currentPointer == null);
+ return !_beyondEnd;
+ }
+
+ private bool BeforeFirst()
+ {
+ return _currentPointer == null;
+ }
+
+ public virtual void Reset()
+ {
+ throw new NotSupportedException();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeNodeCacheEntry
+ {
+ public readonly BTreeNode _node;
+
+ private ByteArrayBuffer _buffer;
+
+ public BTreeNodeCacheEntry(BTreeNode node)
+ {
+ _node = node;
+ }
+
+ public virtual ByteArrayBuffer Buffer()
+ {
+ return _buffer;
+ }
+
+ public virtual void Buffer(ByteArrayBuffer buffer)
+ {
+ _buffer = buffer;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,1458 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Ids;
+using Db4objects.Db4o.Marshall;
+using Sharpen;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ /// We work with BTreeNode in two states:
+ /// - deactivated: never read, no valid members, ID correct or 0 if new
+ /// - write: real representation of keys, values and children in arrays
+ /// The write state can be detected with canWrite().
+ ///
+ ///
+ /// We work with BTreeNode in two states:
+ /// - deactivated: never read, no valid members, ID correct or 0 if new
+ /// - write: real representation of keys, values and children in arrays
+ /// The write state can be detected with canWrite(). States can be changed
+ /// as needed with prepareRead() and prepareWrite().
+ ///
+ ///
+ public sealed class BTreeNode : LocalPersistentBase
+ {
+ private const int CountLeafAnd3LinkLength = (Const4.IntLength * 4) + 1;
+
+ private const int SlotLeadingLength = Const4.LeadingLength + CountLeafAnd3LinkLength;
+
+ internal readonly BTree _btree;
+
+ private int _count;
+
+ private bool _isLeaf;
+
+ private object[] _keys;
+
+ /// Can contain BTreeNode or Integer for ID of BTreeNode
+ private object[] _children;
+
+ private int _parentID;
+
+ private int _previousID;
+
+ private int _nextID;
+
+ private bool _dead;
+
+ public BTreeNode(BTree btree, int count, bool isLeaf, int parentID, int previousID
+ , int nextID)
+ {
+ _btree = btree;
+ _parentID = parentID;
+ _previousID = previousID;
+ _nextID = nextID;
+ _count = count;
+ _isLeaf = isLeaf;
+ PrepareArrays();
+ }
+
+ public BTreeNode(int id, BTree btree)
+ {
+ _btree = btree;
+ SetID(id);
+ SetStateDeactivated();
+ }
+
+ public BTreeNode(Transaction trans, Db4objects.Db4o.Internal.Btree.BTreeNode firstChild
+ , Db4objects.Db4o.Internal.Btree.BTreeNode secondChild) : this(firstChild._btree
+ , 2, false, 0, 0, 0)
+ {
+ _keys[0] = firstChild._keys[0];
+ _children[0] = firstChild;
+ _keys[1] = secondChild._keys[0];
+ _children[1] = secondChild;
+ Write(trans.SystemTransaction());
+ firstChild.SetParentID(trans, GetID());
+ secondChild.SetParentID(trans, GetID());
+ }
+
+ public BTree Btree()
+ {
+ return _btree;
+ }
+
+ ///
+ /// the split node if this node is split
+ /// or this if the first key has changed
+ ///
+ public Db4objects.Db4o.Internal.Btree.BTreeNode Add(Transaction trans, IPreparedComparison
+ preparedComparison, object obj)
+ {
+ ByteArrayBuffer reader = PrepareRead(trans);
+ Searcher s = Search(trans, preparedComparison, reader);
+ if (_isLeaf)
+ {
+ PrepareWrite(trans);
+ SetStateDirty();
+ if (WasRemoved(trans, s))
+ {
+ CancelRemoval(trans, obj, s.Cursor());
+ return null;
+ }
+ if (s.Count() > 0 && !s.BeforeFirst())
+ {
+ s.MoveForward();
+ }
+ PrepareInsert(s.Cursor());
+ _keys[s.Cursor()] = ApplyNewAddPatch(trans, obj);
+ }
+ else
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeNode childNode = Child(reader, s.Cursor());
+ Db4objects.Db4o.Internal.Btree.BTreeNode childNodeOrSplit = childNode.Add(trans,
+ preparedComparison, obj);
+ if (childNodeOrSplit == null)
+ {
+ return null;
+ }
+ PrepareWrite(trans);
+ SetStateDirty();
+ _keys[s.Cursor()] = childNode._keys[0];
+ if (childNode != childNodeOrSplit)
+ {
+ int splitCursor = s.Cursor() + 1;
+ PrepareInsert(splitCursor);
+ _keys[splitCursor] = childNodeOrSplit._keys[0];
+ _children[splitCursor] = childNodeOrSplit;
+ }
+ }
+ if (MustSplit())
+ {
+ return Split(trans);
+ }
+ if (s.Cursor() == 0)
+ {
+ return this;
+ }
+ return null;
+ }
+
+ private bool MustSplit()
+ {
+ return _count >= _btree.NodeSize();
+ }
+
+ private BTreeAdd ApplyNewAddPatch(Transaction trans, object obj)
+ {
+ SizeIncrement(trans);
+ return new BTreeAdd(trans, obj);
+ }
+
+ private void CancelRemoval(Transaction trans, object obj, int index)
+ {
+ BTreeUpdate patch = (BTreeUpdate)KeyPatch(index);
+ BTreeUpdate nextPatch = patch.RemoveFor(trans);
+ _keys[index] = NewCancelledRemoval(trans, patch.GetObject(), obj, nextPatch);
+ SizeIncrement(trans);
+ }
+
+ private BTreePatch NewCancelledRemoval(Transaction trans, object originalObject,
+ object currentObject, BTreeUpdate existingPatches)
+ {
+ return new BTreeCancelledRemoval(trans, originalObject, currentObject, existingPatches
+ );
+ }
+
+ private void SizeIncrement(Transaction trans)
+ {
+ _btree.SizeChanged(trans, this, 1);
+ }
+
+ private bool WasRemoved(Transaction trans, Searcher s)
+ {
+ if (!s.FoundMatch())
+ {
+ return false;
+ }
+ BTreePatch patch = KeyPatch(trans, s.Cursor());
+ return patch != null && patch.IsRemove();
+ }
+
+ internal BTreeNodeSearchResult SearchLeaf(Transaction trans, IPreparedComparison
+ preparedComparison, SearchTarget target)
+ {
+ ByteArrayBuffer reader = PrepareRead(trans);
+ Searcher s = Search(trans, preparedComparison, reader, target);
+ if (!_isLeaf)
+ {
+ return Child(reader, s.Cursor()).SearchLeaf(trans, preparedComparison, target);
+ }
+ if (!s.FoundMatch() || target == SearchTarget.Any || target == SearchTarget.Highest)
+ {
+ return new BTreeNodeSearchResult(trans, reader, Btree(), s, this);
+ }
+ if (target == SearchTarget.Lowest)
+ {
+ BTreeNodeSearchResult res = FindLowestLeafMatch(trans, preparedComparison, s.Cursor
+ () - 1);
+ if (res != null)
+ {
+ return res;
+ }
+ return CreateMatchingSearchResult(trans, reader, s.Cursor());
+ }
+ throw new InvalidOperationException();
+ }
+
+ private BTreeNodeSearchResult FindLowestLeafMatch(Transaction trans, IPreparedComparison
+ preparedComparison, int index)
+ {
+ return FindLowestLeafMatch(trans, preparedComparison, PrepareRead(trans), index);
+ }
+
+ private BTreeNodeSearchResult FindLowestLeafMatch(Transaction trans, IPreparedComparison
+ preparedComparison, ByteArrayBuffer reader, int index)
+ {
+ if (index >= 0)
+ {
+ if (!CompareEquals(preparedComparison, trans, reader, index))
+ {
+ return null;
+ }
+ if (index > 0)
+ {
+ BTreeNodeSearchResult res = FindLowestLeafMatch(trans, preparedComparison, reader
+ , index - 1);
+ if (res != null)
+ {
+ return res;
+ }
+ return CreateMatchingSearchResult(trans, reader, index);
+ }
+ }
+ Db4objects.Db4o.Internal.Btree.BTreeNode node = PreviousNode();
+ if (node != null)
+ {
+ ByteArrayBuffer nodeReader = node.PrepareRead(trans);
+ BTreeNodeSearchResult res = node.FindLowestLeafMatch(trans, preparedComparison, nodeReader
+ , node.LastIndex());
+ if (res != null)
+ {
+ return res;
+ }
+ }
+ if (index < 0)
+ {
+ return null;
+ }
+ return CreateMatchingSearchResult(trans, reader, index);
+ }
+
+ private bool CompareEquals(IPreparedComparison preparedComparison, Transaction trans
+ , ByteArrayBuffer reader, int index)
+ {
+ if (CanWrite())
+ {
+ return CompareInWriteMode(preparedComparison, index) == 0;
+ }
+ return CompareInReadMode(trans, preparedComparison, reader, index) == 0;
+ }
+
+ private BTreeNodeSearchResult CreateMatchingSearchResult(Transaction trans, ByteArrayBuffer
+ reader, int index)
+ {
+ return new BTreeNodeSearchResult(trans, reader, Btree(), this, index, true);
+ }
+
+ public bool CanWrite()
+ {
+ return _keys != null;
+ }
+
+ internal Db4objects.Db4o.Internal.Btree.BTreeNode Child(int index)
+ {
+ if (_children[index] is Db4objects.Db4o.Internal.Btree.BTreeNode)
+ {
+ return (Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index];
+ }
+ return ProduceChild(index, ((int)_children[index]));
+ }
+
+ internal Db4objects.Db4o.Internal.Btree.BTreeNode Child(ByteArrayBuffer reader, int
+ index)
+ {
+ if (ChildLoaded(index))
+ {
+ return (Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index];
+ }
+ return ProduceChild(index, ChildID(reader, index));
+ }
+
+ private Db4objects.Db4o.Internal.Btree.BTreeNode ProduceChild(int index, int childID
+ )
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeNode child = _btree.ProduceNode(childID);
+ if (_children != null)
+ {
+ _children[index] = child;
+ }
+ return child;
+ }
+
+ private int ChildID(ByteArrayBuffer reader, int index)
+ {
+ if (_children == null)
+ {
+ SeekChild(reader, index);
+ return reader.ReadInt();
+ }
+ return ChildID(index);
+ }
+
+ private int ChildID(int index)
+ {
+ if (ChildLoaded(index))
+ {
+ return ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index]).GetID();
+ }
+ return ((int)_children[index]);
+ }
+
+ private bool ChildLoaded(int index)
+ {
+ if (_children == null)
+ {
+ return false;
+ }
+ return _children[index] is Db4objects.Db4o.Internal.Btree.BTreeNode;
+ }
+
+ private bool ChildCanSupplyFirstKey(int index)
+ {
+ if (!ChildLoaded(index))
+ {
+ return false;
+ }
+ return ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index]).CanWrite();
+ }
+
+ public void Commit(Transaction trans)
+ {
+ CommitOrRollback(trans, true);
+ }
+
+ internal void CommitOrRollback(Transaction trans, bool isCommit)
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.BtreeNodeCommitOrRollback.Log(GetID());
+ }
+ if (_dead)
+ {
+ return;
+ }
+ if (!_isLeaf)
+ {
+ return;
+ }
+ if (!IsDirty(trans))
+ {
+ return;
+ }
+ object keyZero = _keys[0];
+ object[] tempKeys = new object[_btree.NodeSize()];
+ int count = 0;
+ for (int i = 0; i < _count; i++)
+ {
+ object key = _keys[i];
+ BTreePatch patch = KeyPatch(i);
+ if (patch != null)
+ {
+ key = isCommit ? patch.Commit(trans, _btree, this) : patch.Rollback(trans, _btree
+ );
+ }
+ if (key != No4.Instance)
+ {
+ tempKeys[count] = key;
+ count++;
+ }
+ }
+ _keys = tempKeys;
+ _count = count;
+ if (FreeIfEmpty(trans))
+ {
+ return;
+ }
+ SetStateDirty();
+ // TODO: Merge nodes here on low _count value.
+ if (_keys[0] != keyZero)
+ {
+ TellParentAboutChangedKey(trans);
+ }
+ }
+
+ private bool FreeIfEmpty(Transaction trans)
+ {
+ return FreeIfEmpty(trans, _count);
+ }
+
+ private bool FreeIfEmpty(Transaction trans, int count)
+ {
+ if (count > 0)
+ {
+ return false;
+ }
+ if (IsRoot())
+ {
+ return false;
+ }
+ Free((LocalTransaction)trans);
+ return true;
+ }
+
+ private bool IsRoot()
+ {
+ return _btree.Root() == this;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!(obj is Db4objects.Db4o.Internal.Btree.BTreeNode))
+ {
+ return false;
+ }
+ Db4objects.Db4o.Internal.Btree.BTreeNode other = (Db4objects.Db4o.Internal.Btree.BTreeNode
+ )obj;
+ return GetID() == other.GetID();
+ }
+
+ public override int GetHashCode()
+ {
+ return GetID();
+ }
+
+ public override void Free(LocalTransaction trans)
+ {
+ _dead = true;
+ if (!IsRoot())
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeNode parent = _btree.ProduceNode(_parentID);
+ parent.RemoveChild(trans, this);
+ }
+ PointPreviousTo(trans, _nextID);
+ PointNextTo(trans, _previousID);
+ base.Free((LocalTransaction)trans);
+ _btree.RemoveNode(this);
+ _btree.NotifyDeleted(trans, this);
+ }
+
+ internal void HoldChildrenAsIDs()
+ {
+ if (_children == null)
+ {
+ return;
+ }
+ for (int i = 0; i < _count; i++)
+ {
+ if (_children[i] is Db4objects.Db4o.Internal.Btree.BTreeNode)
+ {
+ _children[i] = ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[i]).GetID();
+ }
+ }
+ }
+
+ private void RemoveChild(Transaction trans, Db4objects.Db4o.Internal.Btree.BTreeNode
+ child)
+ {
+ PrepareWrite(trans);
+ SetStateDirty();
+ int id = child.GetID();
+ for (int i = 0; i < _count; i++)
+ {
+ if (ChildID(i) == id)
+ {
+ if (FreeIfEmpty(trans, _count - 1))
+ {
+ return;
+ }
+ Remove(i);
+ if (i < 1)
+ {
+ TellParentAboutChangedKey(trans);
+ }
+ if (_count == 0)
+ {
+ // root node empty case only, have to turn it into a leaf
+ _isLeaf = true;
+ }
+ return;
+ }
+ }
+ throw new InvalidOperationException("child not found");
+ }
+
+ private void KeyChanged(Transaction trans, Db4objects.Db4o.Internal.Btree.BTreeNode
+ child)
+ {
+ PrepareWrite(trans);
+ SetStateDirty();
+ int id = child.GetID();
+ for (int i = 0; i < _count; i++)
+ {
+ if (ChildID(i) == id)
+ {
+ _keys[i] = child._keys[0];
+ _children[i] = child;
+ KeyChanged(trans, i);
+ return;
+ }
+ }
+ throw new InvalidOperationException("child not found");
+ }
+
+ private void TellParentAboutChangedKey(Transaction trans)
+ {
+ if (!IsRoot())
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeNode parent = _btree.ProduceNode(_parentID);
+ parent.KeyChanged(trans, this);
+ }
+ }
+
+ private bool IsDirty(Transaction trans)
+ {
+ if (!CanWrite())
+ {
+ return false;
+ }
+ for (int i = 0; i < _count; i++)
+ {
+ if (KeyPatch(trans, i) != null)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private int CompareInWriteMode(IPreparedComparison preparedComparison, int index)
+ {
+ return -preparedComparison.CompareTo(Key(index));
+ }
+
+ private int CompareInReadMode(Transaction trans, IPreparedComparison preparedComparison
+ , ByteArrayBuffer reader, int index)
+ {
+ SeekKey(reader, index);
+ return -preparedComparison.CompareTo(KeyHandler().ReadIndexEntry(trans.Context(),
+ reader));
+ }
+
+ public int Count()
+ {
+ return _count;
+ }
+
+ private int EntryLength()
+ {
+ int len = KeyHandler().LinkLength();
+ if (!_isLeaf)
+ {
+ len += Const4.IdLength;
+ }
+ return len;
+ }
+
+ public int FirstKeyIndex(Transaction trans)
+ {
+ for (int ix = 0; ix < _count; ix++)
+ {
+ if (IndexIsValid(trans, ix))
+ {
+ return ix;
+ }
+ }
+ return -1;
+ }
+
+ public int LastKeyIndex(Transaction trans)
+ {
+ for (int ix = _count - 1; ix >= 0; ix--)
+ {
+ if (IndexIsValid(trans, ix))
+ {
+ return ix;
+ }
+ }
+ return -1;
+ }
+
+ public bool IndexIsValid(Transaction trans, int index)
+ {
+ if (!CanWrite())
+ {
+ return true;
+ }
+ BTreePatch patch = KeyPatch(index);
+ if (patch == null)
+ {
+ return true;
+ }
+ return patch.Key(trans) != No4.Instance;
+ }
+
+ private object FirstKey(Transaction trans)
+ {
+ int index = FirstKeyIndex(trans);
+ if (-1 == index)
+ {
+ return No4.Instance;
+ }
+ return InternalKey(trans, index);
+ }
+
+ public override byte GetIdentifier()
+ {
+ return Const4.BtreeNode;
+ }
+
+ private void PrepareInsert(int pos)
+ {
+ if (pos > LastIndex())
+ {
+ _count++;
+ return;
+ }
+ int len = _count - pos;
+ System.Array.Copy(_keys, pos, _keys, pos + 1, len);
+ if (_children != null)
+ {
+ System.Array.Copy(_children, pos, _children, pos + 1, len);
+ }
+ _count++;
+ }
+
+ private void Remove(int pos)
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.BtreeNodeRemove.Log(GetID());
+ }
+ int len = _count - pos;
+ _count--;
+ System.Array.Copy(_keys, pos + 1, _keys, pos, len);
+ _keys[_count] = null;
+ if (_children != null)
+ {
+ System.Array.Copy(_children, pos + 1, _children, pos, len);
+ _children[_count] = null;
+ }
+ }
+
+ internal object Key(int index)
+ {
+ object obj = _keys[index];
+ if (obj is BTreePatch)
+ {
+ return ((BTreePatch)obj).GetObject();
+ }
+ return obj;
+ }
+
+ public object Key(Transaction trans, int index)
+ {
+ return Key(trans, PrepareRead(trans), index);
+ }
+
+ internal object Key(Transaction trans, ByteArrayBuffer reader, int index)
+ {
+ if (CanWrite())
+ {
+ return InternalKey(trans, index);
+ }
+ if (reader == null)
+ {
+ reader = PrepareRead(trans);
+ }
+ if (CanWrite())
+ {
+ return InternalKey(trans, index);
+ }
+ SeekKey(reader, index);
+ return KeyHandler().ReadIndexEntry(trans.Context(), reader);
+ }
+
+ private object InternalKey(Transaction trans, int index)
+ {
+ BTreePatch patch = KeyPatch(index);
+ if (patch == null)
+ {
+ return _keys[index];
+ }
+ return patch.Key(trans);
+ }
+
+ private BTreePatch KeyPatch(int index)
+ {
+ object obj = _keys[index];
+ if (obj is BTreePatch)
+ {
+ return (BTreePatch)obj;
+ }
+ return null;
+ }
+
+ internal BTreePatch KeyPatch(Transaction trans, int index)
+ {
+ object obj = _keys[index];
+ if (obj is BTreePatch)
+ {
+ return ((BTreePatch)obj).ForTransaction(trans);
+ }
+ return null;
+ }
+
+ private IIndexable4 KeyHandler()
+ {
+ return _btree.KeyHandler();
+ }
+
+ public override int OwnLength()
+ {
+ return SlotLeadingLength + (_count * EntryLength()) + Const4.BracketsBytes;
+ }
+
+ internal ByteArrayBuffer PrepareRead(Transaction trans)
+ {
+ BTreeNodeCacheEntry cacheEntry = Btree().CacheEntry(this);
+ if (CanWrite())
+ {
+ return null;
+ }
+ if (IsNew())
+ {
+ return null;
+ }
+ Transaction systemTransaction = trans.SystemTransaction();
+ ByteArrayBuffer buffer = cacheEntry.Buffer();
+ if (buffer != null)
+ {
+ // Cache hit, still unread
+ buffer.Seek(0);
+ Read(systemTransaction, buffer);
+ cacheEntry.Buffer(null);
+ _btree.AddToProcessing(this);
+ return null;
+ }
+ buffer = ProduceReadBuffer(systemTransaction);
+ ReadNodeHeader(buffer);
+ cacheEntry.Buffer(buffer);
+ return buffer;
+ }
+
+ internal void PrepareWrite(Transaction trans)
+ {
+ if (_dead)
+ {
+ return;
+ }
+ BTreeNodeCacheEntry cacheEntry = Btree().CacheEntry(this);
+ if (CanWrite())
+ {
+ return;
+ }
+ ByteArrayBuffer buffer = cacheEntry.Buffer();
+ if (buffer != null)
+ {
+ buffer.Seek(0);
+ Read(trans.SystemTransaction(), buffer);
+ cacheEntry.Buffer(null);
+ }
+ else
+ {
+ Read(trans.SystemTransaction());
+ }
+ _btree.AddToProcessing(this);
+ }
+
+ private void PrepareArrays()
+ {
+ if (CanWrite())
+ {
+ return;
+ }
+ _keys = new object[_btree.NodeSize()];
+ if (!_isLeaf)
+ {
+ _children = new object[_btree.NodeSize()];
+ }
+ }
+
+ private void ReadNodeHeader(ByteArrayBuffer reader)
+ {
+ _count = reader.ReadInt();
+ byte leafByte = reader.ReadByte();
+ _isLeaf = (leafByte == 1);
+ _parentID = reader.ReadInt();
+ _previousID = reader.ReadInt();
+ _nextID = reader.ReadInt();
+ }
+
+ public override void ReadThis(Transaction trans, ByteArrayBuffer reader)
+ {
+ ReadNodeHeader(reader);
+ PrepareArrays();
+ bool isInner = !_isLeaf;
+ for (int i = 0; i < _count; i++)
+ {
+ _keys[i] = KeyHandler().ReadIndexEntry(trans.Context(), reader);
+ if (isInner)
+ {
+ _children[i] = reader.ReadInt();
+ }
+ }
+ }
+
+ public void Remove(Transaction trans, int index)
+ {
+ if (!_isLeaf)
+ {
+ throw new InvalidOperationException();
+ }
+ PrepareWrite(trans);
+ SetStateDirty();
+ object obj = null;
+ BTreePatch patch = KeyPatch(index);
+ if (patch == null)
+ {
+ obj = _keys[index];
+ }
+ else
+ {
+ BTreePatch transPatch = patch.ForTransaction(trans);
+ if (transPatch != null)
+ {
+ obj = transPatch.GetObject();
+ }
+ else
+ {
+ // There could be more than one patch with different object
+ // identities. We have no means to determine a "best" object
+ // so we just take any one. Could be problematic.
+ obj = patch.GetObject();
+ }
+ }
+ Remove(trans, obj, index);
+ }
+
+ public bool Remove(Transaction trans, object obj, int index)
+ {
+ if (!_isLeaf)
+ {
+ throw new InvalidOperationException();
+ }
+ PrepareWrite(trans);
+ SetStateDirty();
+ BTreePatch patch = KeyPatch(index);
+ // no patch, no problem, can remove
+ if (patch == null)
+ {
+ _keys[index] = ApplyNewRemovePatch(trans, obj);
+ KeyChanged(trans, index);
+ return true;
+ }
+ BTreePatch transPatch = patch.ForTransaction(trans);
+ if (transPatch != null)
+ {
+ if (transPatch.IsAdd())
+ {
+ CancelAdding(trans, index);
+ return true;
+ }
+ if (transPatch.IsCancelledRemoval())
+ {
+ BTreeRemove removePatch = ApplyNewRemovePatch(trans, transPatch.GetObject());
+ _keys[index] = ((BTreeUpdate)patch).ReplacePatch(transPatch, removePatch);
+ KeyChanged(trans, index);
+ return true;
+ }
+ }
+ else
+ {
+ // If the patch is a removal of a cancelled removal for another
+ // transaction, we need one for this transaction also.
+ if (!patch.IsAdd())
+ {
+ ((BTreeUpdate)patch).Append(ApplyNewRemovePatch(trans, obj));
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void Remove(Transaction trans, IPreparedComparison preparedComparison, object
+ obj, int index)
+ {
+ if (Remove(trans, obj, index))
+ {
+ return;
+ }
+ // now we try if removal is OK for the next element in this node
+ if (index != LastIndex())
+ {
+ if (CompareInWriteMode(preparedComparison, index + 1) != 0)
+ {
+ return;
+ }
+ Remove(trans, preparedComparison, obj, index + 1);
+ return;
+ }
+ // nothing else worked so far, move on to the next node, try there
+ Db4objects.Db4o.Internal.Btree.BTreeNode node = NextNode();
+ if (node == null)
+ {
+ return;
+ }
+ node.PrepareWrite(trans);
+ if (node.CompareInWriteMode(preparedComparison, 0) != 0)
+ {
+ return;
+ }
+ node.Remove(trans, preparedComparison, obj, 0);
+ }
+
+ private void CancelAdding(Transaction trans, int index)
+ {
+ _btree.NotifyRemoveListener(new TransactionContext(trans, KeyPatch(index).GetObject
+ ()));
+ if (FreeIfEmpty(trans, _count - 1))
+ {
+ SizeDecrement(trans);
+ return;
+ }
+ Remove(index);
+ KeyChanged(trans, index);
+ SizeDecrement(trans);
+ }
+
+ private void SizeDecrement(Transaction trans)
+ {
+ _btree.SizeChanged(trans, this, -1);
+ }
+
+ private int LastIndex()
+ {
+ return _count - 1;
+ }
+
+ private BTreeRemove ApplyNewRemovePatch(Transaction trans, object key)
+ {
+ SizeDecrement(trans);
+ return new BTreeRemove(trans, key);
+ }
+
+ private void KeyChanged(Transaction trans, int index)
+ {
+ if (index == 0)
+ {
+ TellParentAboutChangedKey(trans);
+ }
+ }
+
+ internal void Rollback(Transaction trans)
+ {
+ CommitOrRollback(trans, false);
+ }
+
+ private Searcher Search(Transaction trans, IPreparedComparison preparedComparison
+ , ByteArrayBuffer reader)
+ {
+ return Search(trans, preparedComparison, reader, SearchTarget.Any);
+ }
+
+ private Searcher Search(Transaction trans, IPreparedComparison preparedComparison
+ , ByteArrayBuffer reader, SearchTarget target)
+ {
+ Searcher s = new Searcher(target, _count);
+ if (CanWrite())
+ {
+ while (s.Incomplete())
+ {
+ s.ResultIs(CompareInWriteMode(preparedComparison, s.Cursor()));
+ }
+ }
+ else
+ {
+ while (s.Incomplete())
+ {
+ s.ResultIs(CompareInReadMode(trans, preparedComparison, reader, s.Cursor()));
+ }
+ }
+ return s;
+ }
+
+ private void SeekAfterKey(ByteArrayBuffer reader, int ix)
+ {
+ SeekKey(reader, ix);
+ reader._offset += KeyHandler().LinkLength();
+ }
+
+ private void SeekChild(ByteArrayBuffer reader, int ix)
+ {
+ SeekAfterKey(reader, ix);
+ }
+
+ private void SeekKey(ByteArrayBuffer reader, int ix)
+ {
+ reader._offset = SlotLeadingLength + (EntryLength() * ix);
+ }
+
+ private Db4objects.Db4o.Internal.Btree.BTreeNode Split(Transaction trans)
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeNode res = new Db4objects.Db4o.Internal.Btree.BTreeNode
+ (_btree, _btree._halfNodeSize, _isLeaf, _parentID, GetID(), _nextID);
+ System.Array.Copy(_keys, _btree._halfNodeSize, res._keys, 0, _btree._halfNodeSize
+ );
+ for (int i = _btree._halfNodeSize; i < _keys.Length; i++)
+ {
+ _keys[i] = null;
+ }
+ if (_children != null)
+ {
+ res._children = new object[_btree.NodeSize()];
+ System.Array.Copy(_children, _btree._halfNodeSize, res._children, 0, _btree._halfNodeSize
+ );
+ for (int i = _btree._halfNodeSize; i < _children.Length; i++)
+ {
+ _children[i] = null;
+ }
+ }
+ _count = _btree._halfNodeSize;
+ res.Write(trans.SystemTransaction());
+ _btree.AddNode(res);
+ int splitID = res.GetID();
+ PointNextTo(trans, splitID);
+ SetNextID(trans, splitID);
+ if (_children != null)
+ {
+ for (int i = 0; i < _btree._halfNodeSize; i++)
+ {
+ if (res._children[i] == null)
+ {
+ break;
+ }
+ res.Child(i).SetParentID(trans, splitID);
+ }
+ }
+ _btree.NotifySplit(trans, this, res);
+ return res;
+ }
+
+ private void PointNextTo(Transaction trans, int id)
+ {
+ if (_nextID != 0)
+ {
+ NextNode().SetPreviousID(trans, id);
+ }
+ }
+
+ private void PointPreviousTo(Transaction trans, int id)
+ {
+ if (_previousID != 0)
+ {
+ PreviousNode().SetNextID(trans, id);
+ }
+ }
+
+ public Db4objects.Db4o.Internal.Btree.BTreeNode PreviousNode()
+ {
+ if (_previousID == 0)
+ {
+ return null;
+ }
+ return _btree.ProduceNode(_previousID);
+ }
+
+ public Db4objects.Db4o.Internal.Btree.BTreeNode NextNode()
+ {
+ if (_nextID == 0)
+ {
+ return null;
+ }
+ return _btree.ProduceNode(_nextID);
+ }
+
+ internal BTreePointer FirstPointer(Transaction trans)
+ {
+ ByteArrayBuffer reader = PrepareRead(trans);
+ if (_isLeaf)
+ {
+ return LeafFirstPointer(trans, reader);
+ }
+ return BranchFirstPointer(trans, reader);
+ }
+
+ private BTreePointer BranchFirstPointer(Transaction trans, ByteArrayBuffer reader
+ )
+ {
+ for (int i = 0; i < _count; i++)
+ {
+ BTreePointer childFirstPointer = Child(reader, i).FirstPointer(trans);
+ if (childFirstPointer != null)
+ {
+ return childFirstPointer;
+ }
+ }
+ return null;
+ }
+
+ private BTreePointer LeafFirstPointer(Transaction trans, ByteArrayBuffer reader)
+ {
+ int index = FirstKeyIndex(trans);
+ if (index == -1)
+ {
+ return null;
+ }
+ return new BTreePointer(trans, reader, this, index);
+ }
+
+ public BTreePointer LastPointer(Transaction trans)
+ {
+ ByteArrayBuffer reader = PrepareRead(trans);
+ if (_isLeaf)
+ {
+ return LeafLastPointer(trans, reader);
+ }
+ return BranchLastPointer(trans, reader);
+ }
+
+ private BTreePointer BranchLastPointer(Transaction trans, ByteArrayBuffer reader)
+ {
+ for (int i = _count - 1; i >= 0; i--)
+ {
+ BTreePointer childLastPointer = Child(reader, i).LastPointer(trans);
+ if (childLastPointer != null)
+ {
+ return childLastPointer;
+ }
+ }
+ return null;
+ }
+
+ private BTreePointer LeafLastPointer(Transaction trans, ByteArrayBuffer reader)
+ {
+ int index = LastKeyIndex(trans);
+ if (index == -1)
+ {
+ return null;
+ }
+ return new BTreePointer(trans, reader, this, index);
+ }
+
+ public void Purge()
+ {
+ if (_dead)
+ {
+ _keys = null;
+ _children = null;
+ return;
+ }
+ if (!IsPatched())
+ {
+ return;
+ }
+ HoldChildrenAsIDs();
+ _btree.AddNode(this);
+ }
+
+ private bool IsPatched()
+ {
+ if (_dead)
+ {
+ return false;
+ }
+ if (!CanWrite())
+ {
+ return false;
+ }
+ for (int i = 0; i < _count; i++)
+ {
+ if (_keys[i] is BTreePatch)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void SetParentID(Transaction trans, int id)
+ {
+ PrepareWrite(trans);
+ SetStateDirty();
+ _parentID = id;
+ }
+
+ private void SetPreviousID(Transaction trans, int id)
+ {
+ PrepareWrite(trans);
+ SetStateDirty();
+ _previousID = id;
+ }
+
+ private void SetNextID(Transaction trans, int id)
+ {
+ PrepareWrite(trans);
+ SetStateDirty();
+ _nextID = id;
+ }
+
+ public void TraverseKeys(Transaction trans, IVisitor4 visitor)
+ {
+ ByteArrayBuffer reader = PrepareRead(trans);
+ if (_isLeaf)
+ {
+ for (int i = 0; i < _count; i++)
+ {
+ object obj = Key(trans, reader, i);
+ if (obj != No4.Instance)
+ {
+ visitor.Visit(obj);
+ }
+ }
+ }
+ else
+ {
+ for (int i = 0; i < _count; i++)
+ {
+ Child(reader, i).TraverseKeys(trans, visitor);
+ }
+ }
+ }
+
+ public override bool WriteObjectBegin()
+ {
+ if (_dead)
+ {
+ return false;
+ }
+ if (!CanWrite())
+ {
+ return false;
+ }
+ return base.WriteObjectBegin();
+ }
+
+ public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
+ {
+ int count = 0;
+ int startOffset = buffer._offset;
+ IContext context = trans.Context();
+ buffer.IncrementOffset(CountLeafAnd3LinkLength);
+ if (_isLeaf)
+ {
+ for (int i = 0; i < _count; i++)
+ {
+ object obj = InternalKey(trans, i);
+ if (obj != No4.Instance)
+ {
+ count++;
+ KeyHandler().WriteIndexEntry(context, buffer, obj);
+ }
+ }
+ }
+ else
+ {
+ for (int i = 0; i < _count; i++)
+ {
+ if (ChildCanSupplyFirstKey(i))
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeNode child = (Db4objects.Db4o.Internal.Btree.BTreeNode
+ )_children[i];
+ object childKey = child.FirstKey(trans);
+ if (childKey != No4.Instance)
+ {
+ count++;
+ KeyHandler().WriteIndexEntry(context, buffer, childKey);
+ buffer.WriteIDOf(trans, child);
+ }
+ }
+ else
+ {
+ count++;
+ KeyHandler().WriteIndexEntry(context, buffer, Key(i));
+ buffer.WriteIDOf(trans, _children[i]);
+ }
+ }
+ }
+ int endOffset = buffer._offset;
+ buffer._offset = startOffset;
+ buffer.WriteInt(count);
+ buffer.WriteByte(_isLeaf ? (byte)1 : (byte)0);
+ buffer.WriteInt(_parentID);
+ buffer.WriteInt(_previousID);
+ buffer.WriteInt(_nextID);
+ buffer._offset = endOffset;
+ }
+
+ public override string ToString()
+ {
+ if (_count == 0)
+ {
+ return "Node " + GetID() + " not loaded";
+ }
+ string str = "\nBTreeNode";
+ str += "\nid: " + GetID();
+ str += "\nparent: " + _parentID;
+ str += "\nprevious: " + _previousID;
+ str += "\nnext: " + _nextID;
+ str += "\ncount:" + _count;
+ str += "\nleaf:" + _isLeaf + "\n";
+ if (CanWrite())
+ {
+ str += " { ";
+ bool first = true;
+ for (int i = 0; i < _count; i++)
+ {
+ if (_keys[i] != null)
+ {
+ if (!first)
+ {
+ str += ", ";
+ }
+ str += _keys[i].ToString();
+ first = false;
+ }
+ }
+ str += " }";
+ }
+ return str;
+ }
+
+ public void DebugLoadFully(Transaction trans)
+ {
+ PrepareWrite(trans);
+ if (_isLeaf)
+ {
+ return;
+ }
+ for (int i = 0; i < _count; ++i)
+ {
+ if (_children[i] is int)
+ {
+ _children[i] = Btree().ProduceNode(((int)_children[i]));
+ }
+ ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[i]).DebugLoadFully(trans);
+ }
+ }
+
+ public static void DefragIndex(DefragmentContextImpl context, IIndexable4 keyHandler
+ )
+ {
+ // count
+ int count = context.ReadInt();
+ // leafByte
+ byte leafByte = context.ReadByte();
+ bool isLeaf = (leafByte == 1);
+ context.CopyID();
+ // parent ID
+ context.CopyID();
+ // previous ID
+ context.CopyID();
+ // next ID
+ for (int i = 0; i < count; i++)
+ {
+ keyHandler.DefragIndexEntry(context);
+ if (!isLeaf)
+ {
+ context.CopyID();
+ }
+ }
+ }
+
+ public bool IsLeaf()
+ {
+ return _isLeaf;
+ }
+
+ /// This traversal goes over all nodes, not just leafs
+ internal void TraverseAllNodes(Transaction trans, IVisitor4 command)
+ {
+ ByteArrayBuffer reader = PrepareRead(trans);
+ command.Visit(this);
+ if (_isLeaf)
+ {
+ return;
+ }
+ for (int childIdx = 0; childIdx < _count; childIdx++)
+ {
+ Child(reader, childIdx).TraverseAllNodes(trans, command);
+ }
+ }
+
+ public int Size(Transaction trans)
+ {
+ PrepareRead(trans);
+ if (!CanWrite())
+ {
+ return _count;
+ }
+ int size = 0;
+ for (int i = 0; i < _count; i++)
+ {
+ BTreePatch keyPatch = KeyPatch(i);
+ if (keyPatch != null)
+ {
+ size += keyPatch.SizeDiff(trans);
+ }
+ else
+ {
+ size++;
+ }
+ }
+ return size;
+ }
+
+ public override Db4objects.Db4o.Internal.Slots.SlotChangeFactory SlotChangeFactory
+ ()
+ {
+ return _btree.SlotChangeFactory();
+ }
+
+ public override ITransactionalIdSystem IdSystem(Transaction trans)
+ {
+ return _btree.IdSystem(trans);
+ }
+
+ public void ToReadMode()
+ {
+ if (IsNew())
+ {
+ return;
+ }
+ if (!CanWrite())
+ {
+ return;
+ }
+ if (IsDirty())
+ {
+ return;
+ }
+ if (IsPatched())
+ {
+ return;
+ }
+ _keys = null;
+ _children = null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,87 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeNodeSearchResult
+ {
+ private readonly Transaction _transaction;
+
+ private readonly BTree _btree;
+
+ private readonly BTreePointer _pointer;
+
+ private readonly bool _foundMatch;
+
+ internal BTreeNodeSearchResult(Transaction transaction, BTree btree, BTreePointer
+ pointer, bool foundMatch)
+ {
+ if (null == transaction || null == btree)
+ {
+ throw new ArgumentNullException();
+ }
+ _transaction = transaction;
+ _btree = btree;
+ _pointer = pointer;
+ _foundMatch = foundMatch;
+ }
+
+ internal BTreeNodeSearchResult(Transaction trans, ByteArrayBuffer nodeReader, BTree
+ btree, BTreeNode node, int cursor, bool foundMatch) : this(trans, btree, PointerOrNull
+ (trans, nodeReader, node, cursor), foundMatch)
+ {
+ }
+
+ internal BTreeNodeSearchResult(Transaction trans, ByteArrayBuffer nodeReader, BTree
+ btree, Searcher searcher, BTreeNode node) : this(trans, btree, NextPointerIf(PointerOrNull
+ (trans, nodeReader, node, searcher.Cursor()), searcher.IsGreater()), searcher.FoundMatch
+ ())
+ {
+ }
+
+ private static BTreePointer NextPointerIf(BTreePointer pointer, bool condition)
+ {
+ if (null == pointer)
+ {
+ return null;
+ }
+ if (condition)
+ {
+ return pointer.Next();
+ }
+ return pointer;
+ }
+
+ private static BTreePointer PointerOrNull(Transaction trans, ByteArrayBuffer nodeReader
+ , BTreeNode node, int cursor)
+ {
+ return node == null ? null : new BTreePointer(trans, nodeReader, node, cursor);
+ }
+
+ public virtual IBTreeRange CreateIncludingRange(Db4objects.Db4o.Internal.Btree.BTreeNodeSearchResult
+ end)
+ {
+ BTreePointer firstPointer = FirstValidPointer();
+ BTreePointer endPointer = end._foundMatch ? end._pointer.Next() : end.FirstValidPointer
+ ();
+ return new BTreeRangeSingle(_transaction, _btree, firstPointer, endPointer);
+ }
+
+ public virtual BTreePointer FirstValidPointer()
+ {
+ if (null == _pointer)
+ {
+ return null;
+ }
+ if (_pointer.IsValid())
+ {
+ return _pointer;
+ }
+ return _pointer.Next();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,60 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public abstract class BTreePatch
+ {
+ protected readonly Transaction _transaction;
+
+ protected object _object;
+
+ public BTreePatch(Transaction transaction, object obj)
+ {
+ _transaction = transaction;
+ _object = obj;
+ }
+
+ public abstract object Commit(Transaction trans, BTree btree, BTreeNode node);
+
+ public abstract Db4objects.Db4o.Internal.Btree.BTreePatch ForTransaction(Transaction
+ trans);
+
+ public virtual object GetObject()
+ {
+ return _object;
+ }
+
+ public virtual bool IsAdd()
+ {
+ return false;
+ }
+
+ public virtual bool IsCancelledRemoval()
+ {
+ return false;
+ }
+
+ public virtual bool IsRemove()
+ {
+ return false;
+ }
+
+ public abstract object Key(Transaction trans);
+
+ public abstract object Rollback(Transaction trans, BTree btree);
+
+ public override string ToString()
+ {
+ if (_object == null)
+ {
+ return "[NULL]";
+ }
+ return _object.ToString();
+ }
+
+ public abstract int SizeDiff(Transaction trans);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,212 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public sealed class BTreePointer
+ {
+ public static Db4objects.Db4o.Internal.Btree.BTreePointer Max(Db4objects.Db4o.Internal.Btree.BTreePointer
+ x, Db4objects.Db4o.Internal.Btree.BTreePointer y)
+ {
+ if (x == null)
+ {
+ return x;
+ }
+ if (y == null)
+ {
+ return y;
+ }
+ if (x.CompareTo(y) > 0)
+ {
+ return x;
+ }
+ return y;
+ }
+
+ public static Db4objects.Db4o.Internal.Btree.BTreePointer Min(Db4objects.Db4o.Internal.Btree.BTreePointer
+ x, Db4objects.Db4o.Internal.Btree.BTreePointer y)
+ {
+ if (x == null)
+ {
+ return y;
+ }
+ if (y == null)
+ {
+ return x;
+ }
+ if (x.CompareTo(y) < 0)
+ {
+ return x;
+ }
+ return y;
+ }
+
+ private readonly BTreeNode _node;
+
+ private readonly int _index;
+
+ private readonly Transaction _transaction;
+
+ private readonly ByteArrayBuffer _nodeReader;
+
+ public BTreePointer(Transaction transaction, ByteArrayBuffer nodeReader, BTreeNode
+ node, int index)
+ {
+ if (transaction == null || node == null)
+ {
+ throw new ArgumentNullException();
+ }
+ _transaction = transaction;
+ _nodeReader = nodeReader;
+ _node = node;
+ _index = index;
+ }
+
+ public int Index()
+ {
+ return _index;
+ }
+
+ public BTreeNode Node()
+ {
+ return _node;
+ }
+
+ public object Key()
+ {
+ return _node.Key(_transaction, _nodeReader, _index);
+ }
+
+ public Db4objects.Db4o.Internal.Btree.BTreePointer Next()
+ {
+ int indexInMyNode = _index + 1;
+ while (indexInMyNode < _node.Count())
+ {
+ if (_node.IndexIsValid(_transaction, indexInMyNode))
+ {
+ return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, _nodeReader,
+ _node, indexInMyNode);
+ }
+ indexInMyNode++;
+ }
+ int newIndex = -1;
+ BTreeNode nextNode = _node;
+ ByteArrayBuffer nextReader = null;
+ while (newIndex == -1)
+ {
+ nextNode = nextNode.NextNode();
+ if (nextNode == null)
+ {
+ return null;
+ }
+ nextReader = nextNode.PrepareRead(_transaction);
+ newIndex = nextNode.FirstKeyIndex(_transaction);
+ }
+ Btree().ConvertCacheEvictedNodesToReadMode();
+ return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, nextReader,
+ nextNode, newIndex);
+ }
+
+ public Db4objects.Db4o.Internal.Btree.BTreePointer Previous()
+ {
+ int indexInMyNode = _index - 1;
+ while (indexInMyNode >= 0)
+ {
+ if (_node.IndexIsValid(_transaction, indexInMyNode))
+ {
+ return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, _nodeReader,
+ _node, indexInMyNode);
+ }
+ indexInMyNode--;
+ }
+ int newIndex = -1;
+ BTreeNode previousNode = _node;
+ ByteArrayBuffer previousReader = null;
+ while (newIndex == -1)
+ {
+ previousNode = previousNode.PreviousNode();
+ if (previousNode == null)
+ {
+ return null;
+ }
+ previousReader = previousNode.PrepareRead(_transaction);
+ newIndex = previousNode.LastKeyIndex(_transaction);
+ }
+ return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, previousReader
+ , previousNode, newIndex);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!(obj is Db4objects.Db4o.Internal.Btree.BTreePointer))
+ {
+ return false;
+ }
+ Db4objects.Db4o.Internal.Btree.BTreePointer other = (Db4objects.Db4o.Internal.Btree.BTreePointer
+ )obj;
+ if (_index != other._index)
+ {
+ return false;
+ }
+ return _node.Equals(other._node);
+ }
+
+ public override int GetHashCode()
+ {
+ return _node.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return "BTreePointer(index=" + _index + ", node=" + _node + ")";
+ }
+
+ public int CompareTo(Db4objects.Db4o.Internal.Btree.BTreePointer y)
+ {
+ if (null == y)
+ {
+ throw new ArgumentNullException();
+ }
+ if (Btree() != y.Btree())
+ {
+ throw new ArgumentException();
+ }
+ return Btree().CompareKeys(_transaction.Context(), Key(), y.Key());
+ }
+
+ private BTree Btree()
+ {
+ return _node.Btree();
+ }
+
+ public static bool LessThan(Db4objects.Db4o.Internal.Btree.BTreePointer x, Db4objects.Db4o.Internal.Btree.BTreePointer
+ y)
+ {
+ return Db4objects.Db4o.Internal.Btree.BTreePointer.Min(x, y) == x && !Equals(x, y
+ );
+ }
+
+ public static bool Equals(Db4objects.Db4o.Internal.Btree.BTreePointer x, Db4objects.Db4o.Internal.Btree.BTreePointer
+ y)
+ {
+ if (x == null)
+ {
+ return y == null;
+ }
+ return x.Equals(y);
+ }
+
+ public bool IsValid()
+ {
+ return _node.IndexIsValid(_transaction, _index);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ internal class BTreeRangeKeyIterator : AbstractBTreeRangeIterator
+ {
+ public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range)
+ {
+ }
+
+ public override object Current
+ {
+ get
+ {
+ return CurrentPointer().Key();
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public class BTreeRangePointerIterator : AbstractBTreeRangeIterator
+ {
+ public BTreeRangePointerIterator(BTreeRangeSingle range) : base(range)
+ {
+ }
+
+ public override object Current
+ {
+ get
+ {
+ return CurrentPointer();
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,239 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeRangeSingle : IBTreeRange
+ {
+ private sealed class _IComparison4_14 : IComparison4
+ {
+ public _IComparison4_14()
+ {
+ }
+
+ public int Compare(object x, object y)
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeRangeSingle xRange = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
+ )x;
+ Db4objects.Db4o.Internal.Btree.BTreeRangeSingle yRange = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
+ )y;
+ return xRange.First().CompareTo(yRange.First());
+ }
+ }
+
+ public static readonly IComparison4 Comparison = new _IComparison4_14();
+
+ private readonly Db4objects.Db4o.Internal.Transaction _transaction;
+
+ private readonly BTree _btree;
+
+ private readonly BTreePointer _first;
+
+ private readonly BTreePointer _end;
+
+ public BTreeRangeSingle(Db4objects.Db4o.Internal.Transaction transaction, BTree btree
+ , BTreePointer first, BTreePointer end)
+ {
+ if (transaction == null || btree == null)
+ {
+ throw new ArgumentNullException();
+ }
+ _transaction = transaction;
+ _btree = btree;
+ _first = first;
+ _end = end;
+ }
+
+ public virtual void Accept(IBTreeRangeVisitor visitor)
+ {
+ visitor.Visit(this);
+ }
+
+ public virtual bool IsEmpty()
+ {
+ return BTreePointer.Equals(_first, _end);
+ }
+
+ public virtual int Size()
+ {
+ if (IsEmpty())
+ {
+ return 0;
+ }
+ // TODO: This was an attempt to improve size calculation.
+ // Since all nodes are read, there is no improvement.
+ // BTreeNode currentNode = _first.node();
+ // int sizeOnFirst = currentNode.count() - _first.index();
+ //
+ // BTreeNode endNode = _end == null ? null : _end.node();
+ // int substractForEnd =
+ // (endNode == null) ? 0 : (endNode.count() - _end.index());
+ //
+ // int size = sizeOnFirst - substractForEnd;
+ // while(! currentNode.equals(endNode)){
+ // currentNode = currentNode.nextNode();
+ // if(currentNode == null){
+ // break;
+ // }
+ // currentNode.prepareRead(transaction());
+ // size += currentNode.count();
+ // }
+ // return size;
+ int size = 0;
+ IEnumerator i = Keys();
+ while (i.MoveNext())
+ {
+ ++size;
+ }
+ return size;
+ }
+
+ public virtual IEnumerator Pointers()
+ {
+ return new BTreeRangePointerIterator(this);
+ }
+
+ public virtual IEnumerator Keys()
+ {
+ return new BTreeRangeKeyIterator(this);
+ }
+
+ public BTreePointer End()
+ {
+ return _end;
+ }
+
+ public virtual Db4objects.Db4o.Internal.Transaction Transaction()
+ {
+ return _transaction;
+ }
+
+ public virtual BTreePointer First()
+ {
+ return _first;
+ }
+
+ public virtual IBTreeRange Greater()
+ {
+ return NewBTreeRangeSingle(_end, null);
+ }
+
+ public virtual IBTreeRange Union(IBTreeRange other)
+ {
+ if (null == other)
+ {
+ throw new ArgumentNullException();
+ }
+ return new BTreeRangeSingleUnion(this).Dispatch(other);
+ }
+
+ public virtual bool Adjacent(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range
+ )
+ {
+ return BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end,
+ _first);
+ }
+
+ public virtual bool Overlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range
+ )
+ {
+ return FirstOverlaps(this, range) || FirstOverlaps(range, this);
+ }
+
+ private bool FirstOverlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle x, Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
+ y)
+ {
+ return BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first,
+ y._end);
+ }
+
+ public virtual IBTreeRange ExtendToFirst()
+ {
+ return NewBTreeRangeSingle(FirstBTreePointer(), _end);
+ }
+
+ public virtual IBTreeRange ExtendToLast()
+ {
+ return NewBTreeRangeSingle(_first, null);
+ }
+
+ public virtual IBTreeRange Smaller()
+ {
+ return NewBTreeRangeSingle(FirstBTreePointer(), _first);
+ }
+
+ public virtual Db4objects.Db4o.Internal.Btree.BTreeRangeSingle NewBTreeRangeSingle
+ (BTreePointer first, BTreePointer end)
+ {
+ return new Db4objects.Db4o.Internal.Btree.BTreeRangeSingle(Transaction(), _btree,
+ first, end);
+ }
+
+ public virtual IBTreeRange NewEmptyRange()
+ {
+ return NewBTreeRangeSingle(null, null);
+ }
+
+ private BTreePointer FirstBTreePointer()
+ {
+ return Btree().FirstPointer(Transaction());
+ }
+
+ private BTree Btree()
+ {
+ return _btree;
+ }
+
+ public virtual IBTreeRange Intersect(IBTreeRange range)
+ {
+ if (null == range)
+ {
+ throw new ArgumentNullException();
+ }
+ return new BTreeRangeSingleIntersect(this).Dispatch(range);
+ }
+
+ public virtual IBTreeRange ExtendToLastOf(IBTreeRange range)
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = CheckRangeArgument(range
+ );
+ return NewBTreeRangeSingle(_first, rangeImpl._end);
+ }
+
+ public override string ToString()
+ {
+ return "BTreeRangeSingle(first=" + _first + ", end=" + _end + ")";
+ }
+
+ private Db4objects.Db4o.Internal.Btree.BTreeRangeSingle CheckRangeArgument(IBTreeRange
+ range)
+ {
+ if (null == range)
+ {
+ throw new ArgumentNullException();
+ }
+ Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
+ )range;
+ if (Btree() != rangeImpl.Btree())
+ {
+ throw new ArgumentException();
+ }
+ return rangeImpl;
+ }
+
+ public virtual BTreePointer LastPointer()
+ {
+ if (_end == null)
+ {
+ return Btree().LastPointer(Transaction());
+ }
+ return _end.Previous();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,167 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Btree.Algebra;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public class BTreeRangeUnion : IBTreeRange
+ {
+ private readonly BTreeRangeSingle[] _ranges;
+
+ public BTreeRangeUnion(BTreeRangeSingle[] ranges) : this(ToSortedCollection(ranges
+ ))
+ {
+ }
+
+ public BTreeRangeUnion(SortedCollection4 sorted)
+ {
+ if (null == sorted)
+ {
+ throw new ArgumentNullException();
+ }
+ _ranges = ToArray(sorted);
+ }
+
+ public virtual void Accept(IBTreeRangeVisitor visitor)
+ {
+ visitor.Visit(this);
+ }
+
+ public virtual bool IsEmpty()
+ {
+ for (int i = 0; i < _ranges.Length; i++)
+ {
+ if (!_ranges[i].IsEmpty())
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static SortedCollection4 ToSortedCollection(BTreeRangeSingle[] ranges)
+ {
+ if (null == ranges)
+ {
+ throw new ArgumentNullException();
+ }
+ SortedCollection4 collection = new SortedCollection4(BTreeRangeSingle.Comparison);
+ for (int i = 0; i < ranges.Length; i++)
+ {
+ BTreeRangeSingle range = ranges[i];
+ if (!range.IsEmpty())
+ {
+ collection.Add(range);
+ }
+ }
+ return collection;
+ }
+
+ private static BTreeRangeSingle[] ToArray(SortedCollection4 collection)
+ {
+ return (BTreeRangeSingle[])collection.ToArray(new BTreeRangeSingle[collection.Size
+ ()]);
+ }
+
+ public virtual IBTreeRange ExtendToFirst()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual IBTreeRange ExtendToLast()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual IBTreeRange ExtendToLastOf(IBTreeRange upperRange)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual IBTreeRange Greater()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual IBTreeRange Intersect(IBTreeRange range)
+ {
+ if (null == range)
+ {
+ throw new ArgumentNullException();
+ }
+ return new BTreeRangeUnionIntersect(this).Dispatch(range);
+ }
+
+ public virtual IEnumerator Pointers()
+ {
+ return Iterators.Concat(Iterators.Map(_ranges, new _IFunction4_77()));
+ }
+
+ private sealed class _IFunction4_77 : IFunction4
+ {
+ public _IFunction4_77()
+ {
+ }
+
+ public object Apply(object range)
+ {
+ return ((IBTreeRange)range).Pointers();
+ }
+ }
+
+ public virtual IEnumerator Keys()
+ {
+ return Iterators.Concat(Iterators.Map(_ranges, new _IFunction4_85()));
+ }
+
+ private sealed class _IFunction4_85 : IFunction4
+ {
+ public _IFunction4_85()
+ {
+ }
+
+ public object Apply(object range)
+ {
+ return ((IBTreeRange)range).Keys();
+ }
+ }
+
+ public virtual int Size()
+ {
+ int size = 0;
+ for (int i = 0; i < _ranges.Length; i++)
+ {
+ size += _ranges[i].Size();
+ }
+ return size;
+ }
+
+ public virtual IBTreeRange Smaller()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual IBTreeRange Union(IBTreeRange other)
+ {
+ if (null == other)
+ {
+ throw new ArgumentNullException();
+ }
+ return new BTreeRangeUnionUnion(this).Dispatch(other);
+ }
+
+ public virtual IEnumerator Ranges()
+ {
+ return new ArrayIterator4(_ranges);
+ }
+
+ public virtual BTreePointer LastPointer()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class BTreeRemove : BTreeUpdate
+ {
+ public BTreeRemove(Transaction transaction, object obj) : base(transaction, obj)
+ {
+ }
+
+ protected override void Committed(BTree btree)
+ {
+ btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject()));
+ }
+
+ public override string ToString()
+ {
+ return "(-) " + base.ToString();
+ }
+
+ public override bool IsRemove()
+ {
+ return true;
+ }
+
+ protected override object GetCommittedObject()
+ {
+ return No4.Instance;
+ }
+
+ protected override void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode
+ node)
+ {
+ // The size was reduced for this entry, let's change back.
+ btree.SizeChanged(_transaction, node, +1);
+ }
+
+ protected override int SizeDiff()
+ {
+ return 0;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,206 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public abstract class BTreeUpdate : BTreePatch
+ {
+ protected Db4objects.Db4o.Internal.Btree.BTreeUpdate _next;
+
+ public BTreeUpdate(Transaction transaction, object obj) : base(transaction, obj)
+ {
+ }
+
+ protected virtual bool HasNext()
+ {
+ return _next != null;
+ }
+
+ public override BTreePatch ForTransaction(Transaction trans)
+ {
+ if (_transaction == trans)
+ {
+ return this;
+ }
+ if (_next == null)
+ {
+ return null;
+ }
+ return _next.ForTransaction(trans);
+ }
+
+ public virtual Db4objects.Db4o.Internal.Btree.BTreeUpdate RemoveFor(Transaction trans
+ )
+ {
+ if (_transaction == trans)
+ {
+ return _next;
+ }
+ if (_next == null)
+ {
+ return this;
+ }
+ return _next.RemoveFor(trans);
+ }
+
+ public virtual void Append(Db4objects.Db4o.Internal.Btree.BTreeUpdate patch)
+ {
+ if (_transaction == patch._transaction)
+ {
+ // don't allow two patches for the same transaction
+ throw new ArgumentException();
+ }
+ if (!HasNext())
+ {
+ _next = patch;
+ }
+ else
+ {
+ _next.Append(patch);
+ }
+ }
+
+ protected virtual void ApplyKeyChange(object obj)
+ {
+ _object = obj;
+ if (HasNext())
+ {
+ _next.ApplyKeyChange(obj);
+ }
+ }
+
+ protected abstract void Committed(BTree btree);
+
+ public override object Commit(Transaction trans, BTree btree, BTreeNode node)
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeUpdate patch = (Db4objects.Db4o.Internal.Btree.BTreeUpdate
+ )ForTransaction(trans);
+ if (patch is BTreeCancelledRemoval)
+ {
+ object obj = patch.GetCommittedObject();
+ ApplyKeyChange(obj);
+ }
+ else
+ {
+ if (patch is BTreeRemove)
+ {
+ RemovedBy(trans, btree, node);
+ patch.Committed(btree);
+ return No4.Instance;
+ }
+ }
+ return InternalCommit(trans, btree);
+ }
+
+ protected object InternalCommit(Transaction trans, BTree btree)
+ {
+ if (_transaction == trans)
+ {
+ Committed(btree);
+ if (HasNext())
+ {
+ return _next;
+ }
+ return GetCommittedObject();
+ }
+ if (HasNext())
+ {
+ SetNextIfPatch(_next.InternalCommit(trans, btree));
+ }
+ return this;
+ }
+
+ private void SetNextIfPatch(object newNext)
+ {
+ if (newNext is Db4objects.Db4o.Internal.Btree.BTreeUpdate)
+ {
+ _next = (Db4objects.Db4o.Internal.Btree.BTreeUpdate)newNext;
+ }
+ else
+ {
+ _next = null;
+ }
+ }
+
+ protected abstract object GetCommittedObject();
+
+ public override object Rollback(Transaction trans, BTree btree)
+ {
+ if (_transaction == trans)
+ {
+ if (HasNext())
+ {
+ return _next;
+ }
+ return GetObject();
+ }
+ if (HasNext())
+ {
+ SetNextIfPatch(_next.Rollback(trans, btree));
+ }
+ return this;
+ }
+
+ public override object Key(Transaction trans)
+ {
+ BTreePatch patch = ForTransaction(trans);
+ if (patch == null)
+ {
+ return GetObject();
+ }
+ if (patch.IsRemove())
+ {
+ return No4.Instance;
+ }
+ return patch.GetObject();
+ }
+
+ public virtual Db4objects.Db4o.Internal.Btree.BTreeUpdate ReplacePatch(BTreePatch
+ patch, Db4objects.Db4o.Internal.Btree.BTreeUpdate update)
+ {
+ if (patch == this)
+ {
+ update._next = _next;
+ return update;
+ }
+ if (_next == null)
+ {
+ throw new InvalidOperationException();
+ }
+ _next = _next.ReplacePatch(patch, update);
+ return this;
+ }
+
+ public virtual void RemovedBy(Transaction trans, BTree btree, BTreeNode node)
+ {
+ if (trans != _transaction)
+ {
+ AdjustSizeOnRemovalByOtherTransaction(btree, node);
+ }
+ if (HasNext())
+ {
+ _next.RemovedBy(trans, btree, node);
+ }
+ }
+
+ protected abstract void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode
+ node);
+
+ public override int SizeDiff(Transaction trans)
+ {
+ Db4objects.Db4o.Internal.Btree.BTreeUpdate patchForTransaction = (Db4objects.Db4o.Internal.Btree.BTreeUpdate
+ )ForTransaction(trans);
+ if (patchForTransaction == null)
+ {
+ return 1;
+ }
+ return patchForTransaction.SizeDiff();
+ }
+
+ protected abstract int SizeDiff();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,115 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public class FieldIndexKeyHandler : IIndexable4
+ {
+ private readonly IIndexable4 _valueHandler;
+
+ private readonly IDHandler _parentIdHandler;
+
+ public FieldIndexKeyHandler(IIndexable4 delegate_)
+ {
+ _parentIdHandler = new IDHandler();
+ _valueHandler = delegate_;
+ }
+
+ public virtual int LinkLength()
+ {
+ return _valueHandler.LinkLength() + Const4.IntLength;
+ }
+
+ public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer a_reader)
+ {
+ // TODO: could read int directly here with a_reader.readInt()
+ int parentID = ReadParentID(context, a_reader);
+ object objPart = _valueHandler.ReadIndexEntry(context, a_reader);
+ if (parentID < 0)
+ {
+ objPart = null;
+ parentID = -parentID;
+ }
+ return new FieldIndexKeyImpl(parentID, objPart);
+ }
+
+ private int ReadParentID(IContext context, ByteArrayBuffer a_reader)
+ {
+ return ((int)_parentIdHandler.ReadIndexEntry(context, a_reader));
+ }
+
+ public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
+ obj)
+ {
+ IFieldIndexKey composite = (IFieldIndexKey)obj;
+ int parentID = composite.ParentID();
+ object value = composite.Value();
+ if (value == null)
+ {
+ parentID = -parentID;
+ }
+ _parentIdHandler.Write(parentID, writer);
+ _valueHandler.WriteIndexEntry(context, writer, composite.Value());
+ }
+
+ public virtual IIndexable4 ValueHandler()
+ {
+ return _valueHandler;
+ }
+
+ public virtual void DefragIndexEntry(DefragmentContextImpl context)
+ {
+ _parentIdHandler.DefragIndexEntry(context);
+ _valueHandler.DefragIndexEntry(context);
+ }
+
+ public virtual IPreparedComparison PrepareComparison(IContext context, object fieldIndexKey
+ )
+ {
+ IFieldIndexKey source = (IFieldIndexKey)fieldIndexKey;
+ IPreparedComparison preparedValueComparison = _valueHandler.PrepareComparison(context
+ , source.Value());
+ IPreparedComparison preparedParentIdComparison = _parentIdHandler.NewPrepareCompare
+ (source.ParentID());
+ return new _IPreparedComparison_67(preparedValueComparison, preparedParentIdComparison
+ );
+ }
+
+ private sealed class _IPreparedComparison_67 : IPreparedComparison
+ {
+ public _IPreparedComparison_67(IPreparedComparison preparedValueComparison, IPreparedComparison
+ preparedParentIdComparison)
+ {
+ this.preparedValueComparison = preparedValueComparison;
+ this.preparedParentIdComparison = preparedParentIdComparison;
+ }
+
+ public int CompareTo(object obj)
+ {
+ IFieldIndexKey target = (IFieldIndexKey)obj;
+ try
+ {
+ int delegateResult = preparedValueComparison.CompareTo(target.Value());
+ if (delegateResult != 0)
+ {
+ return delegateResult;
+ }
+ }
+ catch (IllegalComparisonException)
+ {
+ }
+ // can happen, is expected
+ return preparedParentIdComparison.CompareTo(target.ParentID());
+ }
+
+ private readonly IPreparedComparison preparedValueComparison;
+
+ private readonly IPreparedComparison preparedParentIdComparison;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,54 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ /// Composite key for field indexes, first compares on the actual
+ /// indexed field _value and then on the _parentID (which is a
+ /// reference to the containing object).
+ ///
+ ///
+ /// Composite key for field indexes, first compares on the actual
+ /// indexed field _value and then on the _parentID (which is a
+ /// reference to the containing object).
+ ///
+ ///
+ public class FieldIndexKeyImpl : IFieldIndexKey
+ {
+ private readonly object _value;
+
+ private readonly int _parentID;
+
+ public FieldIndexKeyImpl(int parentID, object value)
+ {
+ _parentID = parentID;
+ _value = value;
+ }
+
+ public virtual int ParentID()
+ {
+ return _parentID;
+ }
+
+ public virtual object Value()
+ {
+ return _value;
+ }
+
+ public override string ToString()
+ {
+ return "FieldIndexKey(" + _parentID + ", " + SafeString(_value) + ")";
+ }
+
+ private string SafeString(object value)
+ {
+ if (null == value)
+ {
+ return "null";
+ }
+ return value.ToString();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,45 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public interface IBTreeRange
+ {
+ ///
+ /// Iterates through all the valid pointers in
+ /// this range.
+ ///
+ ///
+ /// Iterates through all the valid pointers in
+ /// this range.
+ ///
+ /// an Iterator4 over BTreePointer value
+ IEnumerator Pointers();
+
+ IEnumerator Keys();
+
+ int Size();
+
+ IBTreeRange Greater();
+
+ IBTreeRange Union(IBTreeRange other);
+
+ IBTreeRange ExtendToLast();
+
+ IBTreeRange Smaller();
+
+ IBTreeRange ExtendToFirst();
+
+ IBTreeRange Intersect(IBTreeRange range);
+
+ IBTreeRange ExtendToLastOf(IBTreeRange upperRange);
+
+ bool IsEmpty();
+
+ void Accept(IBTreeRangeVisitor visitor);
+
+ BTreePointer LastPointer();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,14 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public interface IBTreeRangeVisitor
+ {
+ void Visit(BTreeRangeSingle range);
+
+ void Visit(BTreeRangeUnion union);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public interface IBTreeStructureListener
+ {
+ void NotifySplit(Transaction trans, BTreeNode originalNode, BTreeNode newRightNode
+ );
+
+ void NotifyDeleted(Transaction trans, BTreeNode node);
+
+ void NotifyCountChanged(Transaction trans, BTreeNode node, int diff);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ public interface IFieldIndexKey
+ {
+ int ParentID();
+
+ object Value();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,171 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Internal.Btree;
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public sealed class Searcher
+ {
+ private int _lower;
+
+ private int _upper;
+
+ private int _cursor;
+
+ private int _cmp;
+
+ private readonly SearchTarget _target;
+
+ private readonly int _count;
+
+ public Searcher(SearchTarget target, int count)
+ {
+ if (count < 0)
+ {
+ throw new ArgumentException();
+ }
+ _target = target;
+ _count = count;
+ _cmp = -1;
+ if (count == 0)
+ {
+ Complete();
+ return;
+ }
+ _cursor = -1;
+ _upper = count - 1;
+ AdjustCursor();
+ }
+
+ private void AdjustBounds()
+ {
+ if (_cmp > 0)
+ {
+ _upper = _cursor - 1;
+ if (_upper < _lower)
+ {
+ _upper = _lower;
+ }
+ return;
+ }
+ if (_cmp < 0)
+ {
+ if (_lower == _cursor && _lower < _upper)
+ {
+ _lower++;
+ }
+ else
+ {
+ _lower = _cursor;
+ }
+ return;
+ }
+ if (_target == SearchTarget.Any)
+ {
+ _lower = _cursor;
+ _upper = _cursor;
+ }
+ else
+ {
+ if (_target == SearchTarget.Highest)
+ {
+ _lower = _cursor;
+ }
+ else
+ {
+ if (_target == SearchTarget.Lowest)
+ {
+ _upper = _cursor;
+ }
+ else
+ {
+ throw new InvalidOperationException("Unknown target");
+ }
+ }
+ }
+ }
+
+ private void AdjustCursor()
+ {
+ int oldCursor = _cursor;
+ if (_upper - _lower <= 1)
+ {
+ if ((_target == SearchTarget.Lowest) && (_cmp == 0))
+ {
+ _cursor = _lower;
+ }
+ else
+ {
+ _cursor = _upper;
+ }
+ }
+ else
+ {
+ _cursor = _lower + ((_upper - _lower) / 2);
+ }
+ if (_cursor == oldCursor)
+ {
+ Complete();
+ }
+ }
+
+ public bool AfterLast()
+ {
+ if (_count == 0)
+ {
+ return false;
+ }
+ // _cursor is 0: not after last
+ return (_cursor == _count - 1) && _cmp < 0;
+ }
+
+ public bool BeforeFirst()
+ {
+ return (_cursor == 0) && (_cmp > 0);
+ }
+
+ private void Complete()
+ {
+ _upper = -2;
+ }
+
+ public int Count()
+ {
+ return _count;
+ }
+
+ public int Cursor()
+ {
+ return _cursor;
+ }
+
+ public bool FoundMatch()
+ {
+ return _cmp == 0;
+ }
+
+ public bool Incomplete()
+ {
+ return _upper >= _lower;
+ }
+
+ public void MoveForward()
+ {
+ _cursor++;
+ }
+
+ public void ResultIs(int cmp)
+ {
+ _cmp = cmp;
+ AdjustBounds();
+ AdjustCursor();
+ }
+
+ public bool IsGreater()
+ {
+ return _cmp < 0;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Btree
+{
+ ///
+ public sealed class SearchTarget
+ {
+ public static readonly Db4objects.Db4o.Internal.Btree.SearchTarget Lowest = new Db4objects.Db4o.Internal.Btree.SearchTarget
+ ("Lowest");
+
+ public static readonly Db4objects.Db4o.Internal.Btree.SearchTarget Any = new Db4objects.Db4o.Internal.Btree.SearchTarget
+ ("Any");
+
+ public static readonly Db4objects.Db4o.Internal.Btree.SearchTarget Highest = new
+ Db4objects.Db4o.Internal.Btree.SearchTarget("Highest");
+
+ private readonly string _target;
+
+ public SearchTarget(string target)
+ {
+ _target = target;
+ }
+
+ public override string ToString()
+ {
+ return _target;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,305 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Handlers;
+using Sharpen;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class ByteArrayBuffer : IReadWriteBuffer
+ {
+ private static readonly ThreadLocal _checkXBytes = Debug4.xbytes ? new ThreadLocal
+ () : null;
+
+ public byte[] _buffer;
+
+ public int _offset;
+
+ internal ByteArrayBuffer()
+ {
+ }
+
+ public ByteArrayBuffer(int length) : this()
+ {
+ // for coding convenience, we allow objects to grab into the buffer
+ _buffer = new byte[length];
+ }
+
+ public ByteArrayBuffer(byte[] buffer) : this()
+ {
+ _buffer = buffer;
+ }
+
+ public virtual void Seek(int offset)
+ {
+ _offset = offset;
+ }
+
+ public virtual void WriteBytes(byte[] bytes)
+ {
+ System.Array.Copy(bytes, 0, _buffer, _offset, bytes.Length);
+ _offset += bytes.Length;
+ }
+
+ // TODO: Change all callers to call writeBytes directly.
+ public virtual void Append(byte[] bytes)
+ {
+ WriteBytes(bytes);
+ }
+
+ public bool ContainsTheSame(Db4objects.Db4o.Internal.ByteArrayBuffer other)
+ {
+ if (other != null)
+ {
+ return Arrays4.Equals(_buffer, other._buffer);
+ }
+ return false;
+ }
+
+ public virtual void CopyTo(Db4objects.Db4o.Internal.ByteArrayBuffer to, int fromOffset
+ , int toOffset, int length)
+ {
+ System.Array.Copy(_buffer, fromOffset, to._buffer, toOffset, length);
+ }
+
+ public virtual int Length()
+ {
+ return _buffer.Length;
+ }
+
+ public virtual void IncrementOffset(int a_by)
+ {
+ _offset += a_by;
+ }
+
+ /// non-encrypted read, used for indexes
+ public virtual void Read(ObjectContainerBase stream, int address, int addressOffset
+ )
+ {
+ stream.ReadBytes(_buffer, address, addressOffset, Length());
+ }
+
+ public void ReadBegin(byte identifier)
+ {
+ }
+
+ public virtual BitMap4 ReadBitMap(int bitCount)
+ {
+ BitMap4 map = new BitMap4(_buffer, _offset, bitCount);
+ _offset += map.MarshalledLength();
+ return map;
+ }
+
+ public virtual byte ReadByte()
+ {
+ return _buffer[_offset++];
+ }
+
+ public virtual byte[] ReadBytes(int a_length)
+ {
+ byte[] bytes = new byte[a_length];
+ ReadBytes(bytes);
+ return bytes;
+ }
+
+ public virtual void ReadBytes(byte[] bytes)
+ {
+ int length = bytes.Length;
+ System.Array.Copy(_buffer, _offset, bytes, 0, length);
+ _offset += length;
+ }
+
+ ///
+ public Db4objects.Db4o.Internal.ByteArrayBuffer ReadEmbeddedObject(Transaction trans
+ )
+ {
+ int address = ReadInt();
+ int length = ReadInt();
+ if (address == 0)
+ {
+ return null;
+ }
+ return trans.Container().DecryptedBufferByAddress(address, length);
+ }
+
+ ///
+ public virtual void ReadEncrypt(ObjectContainerBase stream, int address)
+ {
+ stream.ReadBytes(_buffer, address, Length());
+ stream._handlers.Decrypt(this);
+ }
+
+ public virtual void ReadEnd()
+ {
+ }
+
+ public int ReadInt()
+ {
+ int o = (_offset += 4) - 1;
+ return (_buffer[o] & 255) | (_buffer[--o] & 255) << 8 | (_buffer[--o] & 255) << 16
+ | _buffer[--o] << 24;
+ }
+
+ public virtual long ReadLong()
+ {
+ return LongHandler.ReadLong(this);
+ }
+
+ public virtual Db4objects.Db4o.Internal.ByteArrayBuffer ReadPayloadReader(int offset
+ , int length)
+ {
+ Db4objects.Db4o.Internal.ByteArrayBuffer payLoad = new Db4objects.Db4o.Internal.ByteArrayBuffer
+ (length);
+ System.Array.Copy(_buffer, offset, payLoad._buffer, 0, length);
+ return payLoad;
+ }
+
+ internal virtual void ReplaceWith(byte[] a_bytes)
+ {
+ System.Array.Copy(a_bytes, 0, _buffer, 0, Length());
+ }
+
+ public override string ToString()
+ {
+ string str = string.Empty;
+ for (int i = 0; i < _buffer.Length; i++)
+ {
+ if (i > 0)
+ {
+ str += " , ";
+ }
+ str += _buffer[i];
+ }
+ return str;
+ }
+
+ public virtual void WriteBegin(byte a_identifier)
+ {
+ }
+
+ public void WriteBitMap(BitMap4 nullBitMap)
+ {
+ nullBitMap.WriteTo(_buffer, _offset);
+ _offset += nullBitMap.MarshalledLength();
+ }
+
+ public void WriteByte(byte a_byte)
+ {
+ _buffer[_offset++] = a_byte;
+ }
+
+ public virtual void WriteEnd()
+ {
+ if (Deploy.debug && Deploy.brackets)
+ {
+ WriteByte(Const4.Yapend);
+ }
+ }
+
+ public void WriteInt(int a_int)
+ {
+ int o = _offset + 4;
+ _offset = o;
+ byte[] b = _buffer;
+ b[--o] = (byte)a_int;
+ b[--o] = (byte)(a_int >>= 8);
+ b[--o] = (byte)(a_int >>= 8);
+ b[--o] = (byte)(a_int >> 8);
+ }
+
+ public virtual void WriteIDOf(Transaction trans, object obj)
+ {
+ if (obj == null)
+ {
+ WriteInt(0);
+ return;
+ }
+ if (obj is PersistentBase)
+ {
+ WriteIDOf(trans, (PersistentBase)obj);
+ return;
+ }
+ WriteInt(((int)obj));
+ }
+
+ public virtual void WriteIDOf(Transaction trans, PersistentBase persistent)
+ {
+ if (persistent == null)
+ {
+ WriteInt(0);
+ return;
+ }
+ if (CanWritePersistentBase())
+ {
+ persistent.WriteOwnID(trans, this);
+ }
+ else
+ {
+ WriteInt(persistent.GetID());
+ }
+ }
+
+ protected virtual bool CanWritePersistentBase()
+ {
+ return true;
+ }
+
+ public virtual void WriteShortString(Transaction trans, string a_string)
+ {
+ trans.Container()._handlers._stringHandler.WriteShort(trans, a_string, this);
+ }
+
+ public virtual void WriteLong(long l)
+ {
+ LongHandler.WriteLong(this, l);
+ }
+
+ public virtual void IncrementIntSize()
+ {
+ IncrementOffset(Const4.IntLength);
+ }
+
+ public virtual int Offset()
+ {
+ return _offset;
+ }
+
+ public virtual void EnsureSize(int size)
+ {
+ if (size == _buffer.Length)
+ {
+ return;
+ }
+ _buffer = new byte[size];
+ }
+
+ public virtual void Skip(int length)
+ {
+ Seek(_offset + length);
+ }
+
+ public virtual void CheckXBytes(bool flag)
+ {
+ }
+
+ public virtual bool CheckXBytes()
+ {
+ throw new InvalidOperationException();
+ }
+
+ public virtual bool Eof()
+ {
+ return _offset == _buffer.Length;
+ }
+
+ public virtual int RemainingByteCount()
+ {
+ return _buffer.Length - _offset;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,40 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ public class CacheFactory
+ {
+ public static ICache4 New2QCache(int size)
+ {
+ return new LRU2QCache(size);
+ }
+
+ public static ICache4 New2QLongCache(int size)
+ {
+ return new LRU2QLongCache(size);
+ }
+
+ public static ICache4 New2QXCache(int size)
+ {
+ return new LRU2QXCache(size);
+ }
+
+ public static IPurgeableCache4 NewLRUCache(int size)
+ {
+ return new LRUCache(size);
+ }
+
+ public static IPurgeableCache4 NewLRUIntCache(int size)
+ {
+ return new LRUIntCache(size);
+ }
+
+ public static IPurgeableCache4 NewLRULongCache(int size)
+ {
+ return new LRULongCache(size);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,70 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ public class CacheStatistics : ICache4
+ {
+ private readonly ICache4 _delegate;
+
+ private int _calls;
+
+ private int _misses;
+
+ public CacheStatistics(ICache4 delegate_)
+ {
+ _delegate = delegate_;
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard
+ )
+ {
+ _calls++;
+ IFunction4 delegateProducer = new _IFunction4_26(this, producer);
+ return _delegate.Produce(key, delegateProducer, onDiscard);
+ }
+
+ private sealed class _IFunction4_26 : IFunction4
+ {
+ public _IFunction4_26(CacheStatistics _enclosing, IFunction4 producer)
+ {
+ this._enclosing = _enclosing;
+ this.producer = producer;
+ }
+
+ public object Apply(object arg)
+ {
+ this._enclosing._misses++;
+ return producer.Apply(arg);
+ }
+
+ private readonly CacheStatistics _enclosing;
+
+ private readonly IFunction4 producer;
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _delegate.GetEnumerator();
+ }
+
+ public virtual int Calls()
+ {
+ return _calls;
+ }
+
+ public virtual int Misses()
+ {
+ return _misses;
+ }
+
+ public override string ToString()
+ {
+ return "Cache statistics Calls:" + _calls + " Misses:" + _misses;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ public interface ICache4 : IEnumerable
+ {
+ ///
+ /// Retrieves the value associated to the
+ /// key
+ /// from the cache. If the value is not yet
+ /// cached
+ /// producer
+ /// will be called to produce it. If the cache needs to discard a value
+ /// finalizer
+ /// will be given a chance to process it.
+ ///
+ /// the key for the value - must never change - cannot be null
+ /// will be called if value not yet in the cache - can only be null when the value is found in the cache
+ ///
+ /// will be called if a page needs to be discarded - can be null
+ ///
+ /// the cached value
+ object Produce(object key, IFunction4 producer, IProcedure4 finalizer);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,16 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ public interface IPurgeableCache4 : ICache4
+ {
+ /// Removes the cached value with the specified key from this cache.
+ /// Removes the cached value with the specified key from this cache.
+ ///
+ /// the purged value or null
+ object Purge(object key);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,103 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ /// Simplified version of the algorithm taken from here:
+ /// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2641
+ ///
+ internal class LRU2QCache : ICache4
+ {
+ private readonly CircularBuffer4 _am;
+
+ private readonly CircularBuffer4 _a1;
+
+ private readonly IDictionary _slots;
+
+ private readonly int _maxSize;
+
+ private readonly int _a1_threshold;
+
+ internal LRU2QCache(int maxSize)
+ {
+ _maxSize = maxSize;
+ _a1_threshold = _maxSize / 4;
+ _am = new CircularBuffer4(_maxSize);
+ _a1 = new CircularBuffer4(_maxSize);
+ _slots = new Hashtable(maxSize);
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
+ )
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (_am.Remove(key))
+ {
+ _am.AddFirst(key);
+ return _slots[key];
+ }
+ if (_a1.Remove(key))
+ {
+ _am.AddFirst(key);
+ return _slots[key];
+ }
+ if (_slots.Count >= _maxSize)
+ {
+ DiscardPage(finalizer);
+ }
+ object value = producer.Apply(key);
+ _slots[key] = value;
+ _a1.AddFirst(key);
+ return value;
+ }
+
+ private void DiscardPage(IProcedure4 finalizer)
+ {
+ if (_a1.Size() >= _a1_threshold)
+ {
+ DiscardPageFrom(_a1, finalizer);
+ }
+ else
+ {
+ DiscardPageFrom(_am, finalizer);
+ }
+ }
+
+ private void DiscardPageFrom(CircularBuffer4 list, IProcedure4 finalizer)
+ {
+ Discard(list.RemoveLast(), finalizer);
+ }
+
+ private void Discard(object key, IProcedure4 finalizer)
+ {
+ if (null != finalizer)
+ {
+ finalizer.Apply(_slots[key]);
+ }
+ Sharpen.Collections.Remove(_slots, key);
+ }
+
+ public override string ToString()
+ {
+ return "LRU2QCache(am=" + ToString(_am) + ", a1=" + ToString(_a1) + ")";
+ }
+
+ private string ToString(IEnumerable buffer)
+ {
+ return Iterators.ToString(buffer);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _slots.Values.GetEnumerator();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,98 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ /// Simplified version of the algorithm taken from here:
+ /// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2641
+ ///
+ internal class LRU2QLongCache : ICache4
+ {
+ private readonly CircularLongBuffer4 _am;
+
+ private readonly CircularLongBuffer4 _a1;
+
+ private readonly IDictionary _slots;
+
+ private readonly int _maxSize;
+
+ private readonly int _a1_threshold;
+
+ internal LRU2QLongCache(int maxSize)
+ {
+ _maxSize = maxSize;
+ _a1_threshold = _maxSize / 4;
+ _am = new CircularLongBuffer4(_maxSize);
+ _a1 = new CircularLongBuffer4(_maxSize);
+ _slots = new Hashtable(maxSize);
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
+ )
+ {
+ if (_am.Remove((((long)key))))
+ {
+ _am.AddFirst((((long)key)));
+ return _slots[((long)key)];
+ }
+ if (_a1.Remove((((long)key))))
+ {
+ _am.AddFirst((((long)key)));
+ return _slots[((long)key)];
+ }
+ if (_slots.Count >= _maxSize)
+ {
+ DiscardPage(finalizer);
+ }
+ object value = producer.Apply(((long)key));
+ _slots[((long)key)] = value;
+ _a1.AddFirst((((long)key)));
+ return value;
+ }
+
+ private void DiscardPage(IProcedure4 finalizer)
+ {
+ if (_a1.Size() >= _a1_threshold)
+ {
+ DiscardPageFrom(_a1, finalizer);
+ }
+ else
+ {
+ DiscardPageFrom(_am, finalizer);
+ }
+ }
+
+ private void DiscardPageFrom(CircularLongBuffer4 list, IProcedure4 finalizer)
+ {
+ Discard(list.RemoveLast(), finalizer);
+ }
+
+ private void Discard(long key, IProcedure4 finalizer)
+ {
+ if (null != finalizer)
+ {
+ finalizer.Apply(_slots[key]);
+ }
+ Sharpen.Collections.Remove(_slots, key);
+ }
+
+ public override string ToString()
+ {
+ return "LRU2QCache(am=" + ToString(_am) + ", a1=" + ToString(_a1) + ")";
+ }
+
+ private string ToString(IEnumerable buffer)
+ {
+ return Iterators.ToString(buffer);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _slots.Values.GetEnumerator();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,119 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ /// Full version of the algorithm taken from here:
+ /// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2641
+ ///
+ internal class LRU2QXCache : ICache4
+ {
+ private readonly IDictionary _slots;
+
+ private readonly CircularBuffer4 _am;
+
+ private readonly CircularBuffer4 _a1in;
+
+ private readonly CircularBuffer4 _a1out;
+
+ private readonly int _maxSize;
+
+ private readonly int _inSize;
+
+ public LRU2QXCache(int maxSize)
+ {
+ // 'eden': long-term lru queue
+ // 'nursery': short-term fifo queue, entry point for all new items
+ // 'backlog': fifo queue, elements may not be backed in _slots or may overlap with _am
+ // invariant: |_slots| = |_am| + |_a1in| <= _maxSize
+ _maxSize = maxSize;
+ _inSize = _maxSize / 4;
+ _slots = new Hashtable(_maxSize);
+ _am = new CircularBuffer4(_maxSize);
+ _a1in = new CircularBuffer4(_maxSize);
+ _a1out = new CircularBuffer4(_maxSize / 2);
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
+ )
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (_am.Remove(key))
+ {
+ _am.AddFirst(key);
+ return _slots[key];
+ }
+ if (_a1out.Contains(key))
+ {
+ ReclaimFor(key, producer, finalizer);
+ _am.AddFirst(key);
+ return _slots[key];
+ }
+ if (_a1in.Contains(key))
+ {
+ return _slots[key];
+ }
+ ReclaimFor(key, producer, finalizer);
+ _a1in.AddFirst(key);
+ return _slots[key];
+ }
+
+ private void ReclaimFor(object key, IFunction4 producer, IProcedure4 finalizer)
+ {
+ if (_slots.Count < _maxSize)
+ {
+ _slots[key] = producer.Apply(key);
+ return;
+ }
+ if (_a1in.Size() > _inSize)
+ {
+ object lastKey = _a1in.RemoveLast();
+ Discard(lastKey, finalizer);
+ if (_a1out.IsFull())
+ {
+ _a1out.RemoveLast();
+ }
+ _a1out.AddFirst(lastKey);
+ }
+ else
+ {
+ object lastKey = _am.RemoveLast();
+ Discard(lastKey, finalizer);
+ }
+ _slots[key] = producer.Apply(key);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _slots.Values.GetEnumerator();
+ }
+
+ public override string ToString()
+ {
+ return "LRU2QXCache(am=" + ToString(_am) + ", a1in=" + ToString(_a1in) + ", a1out="
+ + ToString(_a1out) + ")" + " - " + _slots.Count;
+ }
+
+ private void Discard(object key, IProcedure4 finalizer)
+ {
+ object removed = Sharpen.Collections.Remove(_slots, key);
+ if (finalizer != null)
+ {
+ finalizer.Apply(removed);
+ }
+ }
+
+ private string ToString(IEnumerable buffer)
+ {
+ return Iterators.ToString(buffer);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,70 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ internal class LRUCache : IPurgeableCache4
+ {
+ private readonly IDictionary _slots;
+
+ private readonly CircularBuffer4 _lru;
+
+ private readonly int _maxSize;
+
+ internal LRUCache(int size)
+ {
+ _maxSize = size;
+ _slots = new Hashtable(size);
+ _lru = new CircularBuffer4(size);
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
+ )
+ {
+ object value = _slots[key];
+ if (value == null)
+ {
+ object newValue = producer.Apply(key);
+ if (newValue == null)
+ {
+ return null;
+ }
+ if (_slots.Count >= _maxSize)
+ {
+ object discarded = Sharpen.Collections.Remove(_slots, _lru.RemoveLast());
+ if (null != finalizer)
+ {
+ finalizer.Apply(discarded);
+ }
+ }
+ _slots[key] = newValue;
+ _lru.AddFirst(key);
+ return newValue;
+ }
+ _lru.Remove(key);
+ // O(N)
+ _lru.AddFirst(key);
+ return value;
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return _slots.Values.GetEnumerator();
+ }
+
+ public virtual object Purge(object key)
+ {
+ object removed = Sharpen.Collections.Remove(_slots, key);
+ if (removed == null)
+ {
+ return null;
+ }
+ _lru.Remove(key);
+ return removed;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,191 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ internal class LRUIntCache : IPurgeableCache4
+ {
+ private class Entry
+ {
+ internal readonly int _key;
+
+ internal readonly object _value;
+
+ internal LRUIntCache.Entry _previous;
+
+ internal LRUIntCache.Entry _next;
+
+ public Entry(int key, object value)
+ {
+ _key = key;
+ _value = value;
+ }
+
+ public override string ToString()
+ {
+ return string.Empty + _key;
+ }
+ }
+
+ private readonly Hashtable4 _slots;
+
+ private readonly int _maxSize;
+
+ private int _size;
+
+ private LRUIntCache.Entry _first;
+
+ private LRUIntCache.Entry _last;
+
+ internal LRUIntCache(int size)
+ {
+ _maxSize = size;
+ _slots = new Hashtable4(size);
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
+ )
+ {
+ int intKey = (((int)key));
+ if (_last == null)
+ {
+ object lastValue = producer.Apply(((int)key));
+ if (lastValue == null)
+ {
+ return null;
+ }
+ _size = 1;
+ LRUIntCache.Entry lastEntry = new LRUIntCache.Entry(intKey, lastValue);
+ _slots.Put(intKey, lastEntry);
+ _first = lastEntry;
+ _last = lastEntry;
+ return lastValue;
+ }
+ LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Get(intKey);
+ if (entry == null)
+ {
+ if (_size >= _maxSize)
+ {
+ LRUIntCache.Entry oldEntry = (LRUIntCache.Entry)_slots.Remove(_last._key);
+ _last = oldEntry._previous;
+ _last._next = null;
+ if (null != finalizer)
+ {
+ finalizer.Apply((object)oldEntry._value);
+ }
+ _size--;
+ }
+ object newValue = producer.Apply(((int)key));
+ if (newValue == null)
+ {
+ return null;
+ }
+ _size++;
+ LRUIntCache.Entry newEntry = new LRUIntCache.Entry(intKey, newValue);
+ _slots.Put(intKey, newEntry);
+ _first._previous = newEntry;
+ newEntry._next = _first;
+ _first = newEntry;
+ return newValue;
+ }
+ if (_first == entry)
+ {
+ return ((object)entry._value);
+ }
+ LRUIntCache.Entry previous = entry._previous;
+ entry._previous = null;
+ if (_last == entry)
+ {
+ _last = previous;
+ }
+ previous._next = entry._next;
+ if (previous._next != null)
+ {
+ previous._next._previous = previous;
+ }
+ _first._previous = entry;
+ entry._next = _first;
+ _first = entry;
+ return ((object)entry._value);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ IEnumerator i = new _IEnumerator_108(this);
+ return i;
+ }
+
+ private sealed class _IEnumerator_108 : IEnumerator
+ {
+ public _IEnumerator_108(LRUIntCache _enclosing)
+ {
+ this._enclosing = _enclosing;
+ this._cursor = this._enclosing._first;
+ }
+
+ private LRUIntCache.Entry _cursor;
+
+ private LRUIntCache.Entry _current;
+
+ public object Current
+ {
+ get
+ {
+ return this._current._value;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._cursor == null)
+ {
+ this._current = null;
+ return false;
+ }
+ this._current = this._cursor;
+ this._cursor = this._cursor._next;
+ return true;
+ }
+
+ public void Reset()
+ {
+ this._cursor = this._enclosing._first;
+ this._current = null;
+ }
+
+ private readonly LRUIntCache _enclosing;
+ }
+
+ public virtual object Purge(object key)
+ {
+ int intKey = (((int)key));
+ LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Remove(intKey);
+ if (entry == null)
+ {
+ return null;
+ }
+ _size--;
+ if (_first == entry)
+ {
+ _first = entry._next;
+ }
+ if (_last == entry)
+ {
+ _last = entry._previous;
+ }
+ if (entry._previous != null)
+ {
+ entry._previous._next = entry._next;
+ }
+ if (entry._next != null)
+ {
+ entry._next._previous = entry._previous;
+ }
+ return ((object)entry._value);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,191 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ internal class LRULongCache : IPurgeableCache4
+ {
+ private class Entry
+ {
+ internal readonly long _key;
+
+ internal readonly object _value;
+
+ internal LRULongCache.Entry _previous;
+
+ internal LRULongCache.Entry _next;
+
+ public Entry(long key, object value)
+ {
+ _key = key;
+ _value = value;
+ }
+
+ public override string ToString()
+ {
+ return string.Empty + _key;
+ }
+ }
+
+ private readonly Hashtable4 _slots;
+
+ private readonly int _maxSize;
+
+ private int _size;
+
+ private LRULongCache.Entry _first;
+
+ private LRULongCache.Entry _last;
+
+ internal LRULongCache(int size)
+ {
+ _maxSize = size;
+ _slots = new Hashtable4(size);
+ }
+
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
+ )
+ {
+ long longKey = (((long)key));
+ if (_last == null)
+ {
+ object lastValue = producer.Apply(((long)key));
+ if (lastValue == null)
+ {
+ return null;
+ }
+ _size = 1;
+ LRULongCache.Entry lastEntry = new LRULongCache.Entry(longKey, lastValue);
+ _slots.Put(longKey, lastEntry);
+ _first = lastEntry;
+ _last = lastEntry;
+ return lastValue;
+ }
+ LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Get(longKey);
+ if (entry == null)
+ {
+ if (_size >= _maxSize)
+ {
+ LRULongCache.Entry oldEntry = (LRULongCache.Entry)_slots.Remove(_last._key);
+ _last = oldEntry._previous;
+ _last._next = null;
+ if (null != finalizer)
+ {
+ finalizer.Apply((object)oldEntry._value);
+ }
+ _size--;
+ }
+ object newValue = producer.Apply(((long)key));
+ if (newValue == null)
+ {
+ return null;
+ }
+ _size++;
+ LRULongCache.Entry newEntry = new LRULongCache.Entry(longKey, newValue);
+ _slots.Put(longKey, newEntry);
+ _first._previous = newEntry;
+ newEntry._next = _first;
+ _first = newEntry;
+ return newValue;
+ }
+ if (_first == entry)
+ {
+ return ((object)entry._value);
+ }
+ LRULongCache.Entry previous = entry._previous;
+ entry._previous = null;
+ if (_last == entry)
+ {
+ _last = previous;
+ }
+ previous._next = entry._next;
+ if (previous._next != null)
+ {
+ previous._next._previous = previous;
+ }
+ _first._previous = entry;
+ entry._next = _first;
+ _first = entry;
+ return ((object)entry._value);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ IEnumerator i = new _IEnumerator_108(this);
+ return i;
+ }
+
+ private sealed class _IEnumerator_108 : IEnumerator
+ {
+ public _IEnumerator_108(LRULongCache _enclosing)
+ {
+ this._enclosing = _enclosing;
+ this._cursor = this._enclosing._first;
+ }
+
+ private LRULongCache.Entry _cursor;
+
+ private LRULongCache.Entry _current;
+
+ public object Current
+ {
+ get
+ {
+ return this._current._value;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if (this._cursor == null)
+ {
+ this._current = null;
+ return false;
+ }
+ this._current = this._cursor;
+ this._cursor = this._cursor._next;
+ return true;
+ }
+
+ public void Reset()
+ {
+ this._cursor = this._enclosing._first;
+ this._current = null;
+ }
+
+ private readonly LRULongCache _enclosing;
+ }
+
+ public virtual object Purge(object key)
+ {
+ long longKey = (((long)key));
+ LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Remove(longKey);
+ if (entry == null)
+ {
+ return null;
+ }
+ _size--;
+ if (_first == entry)
+ {
+ _first = entry._next;
+ }
+ if (_last == entry)
+ {
+ _last = entry._previous;
+ }
+ if (entry._previous != null)
+ {
+ entry._previous._next = entry._next;
+ }
+ if (entry._next != null)
+ {
+ entry._next._previous = entry._previous;
+ }
+ return ((object)entry._value);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal.Caching;
+
+namespace Db4objects.Db4o.Internal.Caching
+{
+ ///
+ public class NullCache4 : ICache4
+ {
+ public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard
+ )
+ {
+ return producer.Apply(key);
+ }
+
+ public virtual IEnumerator GetEnumerator()
+ {
+ return Iterators.EmptyIterator;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal
+{
+ public sealed class CallBackMode
+ {
+ public static readonly Db4objects.Db4o.Internal.CallBackMode All = new Db4objects.Db4o.Internal.CallBackMode
+ ("ALL");
+
+ public static readonly Db4objects.Db4o.Internal.CallBackMode DeleteOnly = new Db4objects.Db4o.Internal.CallBackMode
+ ("DELETE_ONLY");
+
+ public static readonly Db4objects.Db4o.Internal.CallBackMode None = new Db4objects.Db4o.Internal.CallBackMode
+ ("NONE");
+
+ private string _desc;
+
+ private CallBackMode(string desc)
+ {
+ _desc = desc;
+ }
+
+ public override string ToString()
+ {
+ return _desc;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,34 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class CallbackObjectInfoCollections
+ {
+ public readonly IObjectInfoCollection added;
+
+ public readonly IObjectInfoCollection updated;
+
+ public readonly IObjectInfoCollection deleted;
+
+ public static readonly Db4objects.Db4o.Internal.CallbackObjectInfoCollections Emtpy
+ = Empty();
+
+ public CallbackObjectInfoCollections(IObjectInfoCollection added_, IObjectInfoCollection
+ updated_, IObjectInfoCollection deleted_)
+ {
+ added = added_;
+ updated = updated_;
+ deleted = deleted_;
+ }
+
+ private static Db4objects.Db4o.Internal.CallbackObjectInfoCollections Empty()
+ {
+ return new Db4objects.Db4o.Internal.CallbackObjectInfoCollections(ObjectInfoCollectionImpl
+ .Empty, ObjectInfoCollectionImpl.Empty, ObjectInfoCollectionImpl.Empty);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,58 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Query;
+
+namespace Db4objects.Db4o.Internal.Callbacks
+{
+ public interface ICallbacks
+ {
+ bool ObjectCanNew(Transaction transaction, object obj);
+
+ bool ObjectCanActivate(Transaction transaction, object obj);
+
+ bool ObjectCanUpdate(Transaction transaction, IObjectInfo objectInfo);
+
+ bool ObjectCanDelete(Transaction transaction, IObjectInfo objectInfo);
+
+ bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo);
+
+ void ObjectOnActivate(Transaction transaction, IObjectInfo obj);
+
+ void ObjectOnNew(Transaction transaction, IObjectInfo obj);
+
+ void ObjectOnUpdate(Transaction transaction, IObjectInfo obj);
+
+ void ObjectOnDelete(Transaction transaction, IObjectInfo obj);
+
+ void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj);
+
+ void ObjectOnInstantiate(Transaction transaction, IObjectInfo obj);
+
+ void QueryOnStarted(Transaction transaction, IQuery query);
+
+ void QueryOnFinished(Transaction transaction, IQuery query);
+
+ bool CaresAboutCommitting();
+
+ bool CaresAboutCommitted();
+
+ void ClassOnRegistered(ClassMetadata clazz);
+
+ void CommitOnStarted(Transaction transaction, CallbackObjectInfoCollections objectInfoCollections
+ );
+
+ void CommitOnCompleted(Transaction transaction, CallbackObjectInfoCollections objectInfoCollections
+ , bool isOwnCommit);
+
+ bool CaresAboutDeleting();
+
+ bool CaresAboutDeleted();
+
+ void OpenOnFinished(IObjectContainer container);
+
+ void CloseOnStarted(IObjectContainer container);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,115 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Callbacks;
+using Db4objects.Db4o.Query;
+
+namespace Db4objects.Db4o.Internal.Callbacks
+{
+ public class NullCallbacks : ICallbacks
+ {
+ public virtual void QueryOnFinished(Transaction transaction, IQuery query)
+ {
+ }
+
+ public virtual void QueryOnStarted(Transaction transaction, IQuery query)
+ {
+ }
+
+ public virtual bool ObjectCanNew(Transaction transaction, object obj)
+ {
+ return true;
+ }
+
+ public virtual bool ObjectCanActivate(Transaction transaction, object obj)
+ {
+ return true;
+ }
+
+ public virtual bool ObjectCanUpdate(Transaction transaction, IObjectInfo objectInfo
+ )
+ {
+ return true;
+ }
+
+ public virtual bool ObjectCanDelete(Transaction transaction, IObjectInfo objectInfo
+ )
+ {
+ return true;
+ }
+
+ public virtual bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo
+ )
+ {
+ return true;
+ }
+
+ public virtual void ObjectOnNew(Transaction transaction, IObjectInfo obj)
+ {
+ }
+
+ public virtual void ObjectOnActivate(Transaction transaction, IObjectInfo obj)
+ {
+ }
+
+ public virtual void ObjectOnUpdate(Transaction transaction, IObjectInfo obj)
+ {
+ }
+
+ public virtual void ObjectOnDelete(Transaction transaction, IObjectInfo obj)
+ {
+ }
+
+ public virtual void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj)
+ {
+ }
+
+ public virtual void ObjectOnInstantiate(Transaction transaction, IObjectInfo obj)
+ {
+ }
+
+ public virtual void CommitOnStarted(Transaction transaction, CallbackObjectInfoCollections
+ objectInfoCollections)
+ {
+ }
+
+ public virtual void CommitOnCompleted(Transaction transaction, CallbackObjectInfoCollections
+ objectInfoCollections, bool isOwnCommit)
+ {
+ }
+
+ public virtual bool CaresAboutCommitting()
+ {
+ return false;
+ }
+
+ public virtual bool CaresAboutCommitted()
+ {
+ return false;
+ }
+
+ public virtual void ClassOnRegistered(ClassMetadata clazz)
+ {
+ }
+
+ public virtual bool CaresAboutDeleting()
+ {
+ return false;
+ }
+
+ public virtual bool CaresAboutDeleted()
+ {
+ return false;
+ }
+
+ public virtual void CloseOnStarted(IObjectContainer container)
+ {
+ }
+
+ public virtual void OpenOnFinished(IObjectContainer container)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,79 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Delete;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Marshall;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public abstract class ClassAspect
+ {
+ protected int _handle;
+
+ private int _disabledFromAspectCountVersion = AspectVersionContextImpl.AlwaysEnabled
+ .DeclaredAspectCount();
+
+ // used for identification when sending in C/S mode
+ public abstract Db4objects.Db4o.Internal.Marshall.AspectType AspectType();
+
+ public abstract string GetName();
+
+ public abstract void CascadeActivation(IActivationContext context);
+
+ public abstract int LinkLength();
+
+ public void IncrementOffset(IReadBuffer buffer)
+ {
+ buffer.Seek(buffer.Offset() + LinkLength());
+ }
+
+ public abstract void DefragAspect(IDefragmentContext context);
+
+ public abstract void Marshall(MarshallingContext context, object child);
+
+ public abstract void CollectIDs(CollectIdContext context);
+
+ public virtual void SetHandle(int handle)
+ {
+ _handle = handle;
+ }
+
+ public abstract void Activate(UnmarshallingContext context);
+
+ public abstract void Delete(DeleteContextImpl context, bool isUpdate);
+
+ public abstract bool CanBeDisabled();
+
+ protected virtual bool CheckEnabled(IAspectVersionContext context)
+ {
+ if (!IsEnabledOn(context))
+ {
+ IncrementOffset((IReadBuffer)context);
+ return false;
+ }
+ return true;
+ }
+
+ public virtual void DisableFromAspectCountVersion(int aspectCount)
+ {
+ if (!CanBeDisabled())
+ {
+ return;
+ }
+ if (aspectCount < _disabledFromAspectCountVersion)
+ {
+ _disabledFromAspectCountVersion = aspectCount;
+ }
+ }
+
+ public bool IsEnabledOn(IAspectVersionContext context)
+ {
+ return _disabledFromAspectCountVersion > context.DeclaredAspectCount();
+ }
+
+ public abstract void Deactivate(IActivationContext context);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,82 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Classindex;
+
+namespace Db4objects.Db4o.Internal.Classindex
+{
+ ///
+ public abstract class AbstractClassIndexStrategy : IClassIndexStrategy
+ {
+ protected readonly ClassMetadata _classMetadata;
+
+ public AbstractClassIndexStrategy(ClassMetadata classMetadata)
+ {
+ _classMetadata = classMetadata;
+ }
+
+ protected virtual int ClassMetadataID()
+ {
+ return _classMetadata.GetID();
+ }
+
+ public virtual int OwnLength()
+ {
+ return Const4.IdLength;
+ }
+
+ protected abstract void InternalAdd(Transaction trans, int id);
+
+ public void Add(Transaction trans, int id)
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.AddToClassIndex.Log(id);
+ }
+ CheckId(id);
+ InternalAdd(trans, id);
+ }
+
+ protected abstract void InternalRemove(Transaction ta, int id);
+
+ public void Remove(Transaction ta, int id)
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.RemoveFromClassIndex.Log(id);
+ }
+ CheckId(id);
+ InternalRemove(ta, id);
+ }
+
+ private void CheckId(int id)
+ {
+ }
+
+ public abstract IEnumerator AllSlotIDs(Transaction arg1);
+
+ public abstract void DefragIndex(DefragmentContextImpl arg1);
+
+ public abstract void DefragReference(ClassMetadata arg1, DefragmentContextImpl arg2
+ , int arg3);
+
+ public abstract void DontDelete(Transaction arg1, int arg2);
+
+ public abstract int EntryCount(Transaction arg1);
+
+ public abstract int Id();
+
+ public abstract void Initialize(ObjectContainerBase arg1);
+
+ public abstract void Purge();
+
+ public abstract void Read(ObjectContainerBase arg1, int arg2);
+
+ public abstract void TraverseAll(Transaction arg1, IVisitor4 arg2);
+
+ public abstract int Write(Transaction arg1);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,160 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Classindex;
+using Db4objects.Db4o.Internal.References;
+
+namespace Db4objects.Db4o.Internal.Classindex
+{
+ ///
+ public class BTreeClassIndexStrategy : AbstractClassIndexStrategy
+ {
+ private BTree _btreeIndex;
+
+ public BTreeClassIndexStrategy(ClassMetadata classMetadata) : base(classMetadata)
+ {
+ }
+
+ public virtual BTree Btree()
+ {
+ return _btreeIndex;
+ }
+
+ public override int EntryCount(Transaction ta)
+ {
+ return _btreeIndex != null ? _btreeIndex.Size(ta) : 0;
+ }
+
+ public override void Initialize(ObjectContainerBase stream)
+ {
+ CreateBTreeIndex(stream, 0);
+ }
+
+ public override void Purge()
+ {
+ }
+
+ public override void Read(ObjectContainerBase stream, int indexID)
+ {
+ ReadBTreeIndex(stream, indexID);
+ }
+
+ public override int Write(Transaction trans)
+ {
+ if (_btreeIndex == null)
+ {
+ return 0;
+ }
+ _btreeIndex.Write(trans);
+ return _btreeIndex.GetID();
+ }
+
+ public override void TraverseAll(Transaction ta, IVisitor4 command)
+ {
+ if (_btreeIndex != null)
+ {
+ _btreeIndex.TraverseKeys(ta, command);
+ }
+ }
+
+ private void CreateBTreeIndex(ObjectContainerBase stream, int btreeID)
+ {
+ if (stream.IsClient)
+ {
+ return;
+ }
+ _btreeIndex = ((LocalObjectContainer)stream).CreateBTreeClassIndex(btreeID);
+ _btreeIndex.SetRemoveListener(new _IVisitor4_61(this));
+ }
+
+ private sealed class _IVisitor4_61 : IVisitor4
+ {
+ public _IVisitor4_61(BTreeClassIndexStrategy _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void Visit(object obj)
+ {
+ this._enclosing.RemoveId((TransactionContext)obj);
+ }
+
+ private readonly BTreeClassIndexStrategy _enclosing;
+ }
+
+ private void RemoveId(TransactionContext context)
+ {
+ IReferenceSystem referenceSystem = context._transaction.ReferenceSystem();
+ ObjectReference reference = referenceSystem.ReferenceForId(((int)context._object)
+ );
+ if (reference != null)
+ {
+ referenceSystem.RemoveReference(reference);
+ }
+ }
+
+ private void ReadBTreeIndex(ObjectContainerBase stream, int indexId)
+ {
+ if (!stream.IsClient && _btreeIndex == null)
+ {
+ CreateBTreeIndex(stream, indexId);
+ }
+ }
+
+ protected override void InternalAdd(Transaction trans, int id)
+ {
+ _btreeIndex.Add(trans, id);
+ }
+
+ protected override void InternalRemove(Transaction ta, int id)
+ {
+ _btreeIndex.Remove(ta, id);
+ }
+
+ public override void DontDelete(Transaction transaction, int id)
+ {
+ }
+
+ public override void DefragReference(ClassMetadata classMetadata, DefragmentContextImpl
+ context, int classIndexID)
+ {
+ int newID = -classIndexID;
+ context.WriteInt(newID);
+ }
+
+ public override int Id()
+ {
+ return _btreeIndex.GetID();
+ }
+
+ public override IEnumerator AllSlotIDs(Transaction trans)
+ {
+ return _btreeIndex.AllNodeIds(trans);
+ }
+
+ public override void DefragIndex(DefragmentContextImpl context)
+ {
+ _btreeIndex.DefragIndex(context);
+ }
+
+ public static BTree Btree(ClassMetadata clazz)
+ {
+ IClassIndexStrategy index = clazz.Index();
+ if (!(index is Db4objects.Db4o.Internal.Classindex.BTreeClassIndexStrategy))
+ {
+ throw new InvalidOperationException();
+ }
+ return ((Db4objects.Db4o.Internal.Classindex.BTreeClassIndexStrategy)index).Btree
+ ();
+ }
+
+ public static IEnumerator Iterate(ClassMetadata clazz, Transaction trans)
+ {
+ return Btree(clazz).AsRange(trans).Keys();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,45 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal.Classindex
+{
+ ///
+ public interface IClassIndexStrategy
+ {
+ void Initialize(ObjectContainerBase stream);
+
+ void Read(ObjectContainerBase stream, int indexID);
+
+ int Write(Transaction transaction);
+
+ void Add(Transaction transaction, int id);
+
+ void Remove(Transaction transaction, int id);
+
+ int EntryCount(Transaction transaction);
+
+ int OwnLength();
+
+ void Purge();
+
+ /// Traverses all index entries (java.lang.Integer references).
+ /// Traverses all index entries (java.lang.Integer references).
+ void TraverseAll(Transaction transaction, IVisitor4 command);
+
+ void DontDelete(Transaction transaction, int id);
+
+ IEnumerator AllSlotIDs(Transaction trans);
+
+ // FIXME: Why is this never called?
+ void DefragReference(ClassMetadata classMetadata, DefragmentContextImpl context,
+ int classIndexID);
+
+ int Id();
+
+ // FIXME: Why is this never called?
+ void DefragIndex(DefragmentContextImpl context);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,2735 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Internal.Classindex;
+using Db4objects.Db4o.Internal.Delete;
+using Db4objects.Db4o.Internal.Diagnostic;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Internal.Handlers;
+using Db4objects.Db4o.Internal.Handlers.Array;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Internal.Metadata;
+using Db4objects.Db4o.Internal.Query.Processor;
+using Db4objects.Db4o.Internal.Reflect;
+using Db4objects.Db4o.Marshall;
+using Db4objects.Db4o.Query;
+using Db4objects.Db4o.Reflect;
+using Db4objects.Db4o.Reflect.Core;
+using Db4objects.Db4o.Reflect.Generic;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class ClassMetadata : PersistentBase, IStoredClass
+ {
+ ///
+ /// For reference types, _typeHandler always holds a StandardReferenceTypeHandler
+ /// that will use the _aspects of this class to take care of its business.
+ ///
+ ///
+ /// For reference types, _typeHandler always holds a StandardReferenceTypeHandler
+ /// that will use the _aspects of this class to take care of its business. A custom
+ /// type handler would appear as a TypeHandlerAspect in that case.
+ /// For value types, _typeHandler always holds the actual value type handler be it
+ /// a custom type handler or a builtin one.
+ ///
+ protected ITypeHandler4 _typeHandler;
+
+ public Db4objects.Db4o.Internal.ClassMetadata _ancestor;
+
+ private Config4Class _config;
+
+ public ClassAspect[] _aspects;
+
+ private IClassIndexStrategy _index;
+
+ private string i_name;
+
+ private readonly ObjectContainerBase _container;
+
+ internal byte[] i_nameBytes;
+
+ private ByteArrayBuffer i_reader;
+
+ private bool _classIndexed;
+
+ private IReflectClass _classReflector;
+
+ private IEventDispatcher _eventDispatcher;
+
+ private bool _internal;
+
+ private bool _unversioned;
+
+ private TernaryBool _canUpdateFast = TernaryBool.Unspecified;
+
+ private TranslatedAspect _translator;
+
+ private IModificationAware _modificationChecker = ClassMetadata.AlwaysModified.Instance;
+
+ private IFieldAccessor _fieldAccessor;
+
+ private IFunction4 _constructor;
+
+ private TypeHandlerAspect _customTypeHandlerAspect;
+
+ private IAspectTraversalStrategy _aspectTraversalStrategy;
+
+ internal bool CanUpdateFast()
+ {
+ if (_canUpdateFast == TernaryBool.Unspecified)
+ {
+ _canUpdateFast = TernaryBool.ForBoolean(CheckCanUpdateFast());
+ }
+ return _canUpdateFast.BooleanValue(false);
+ }
+
+ private bool CheckCanUpdateFast()
+ {
+ if (_ancestor != null && !_ancestor.CanUpdateFast())
+ {
+ return false;
+ }
+ if (_config != null && _config.CascadeOnDelete() == TernaryBool.Yes)
+ {
+ return false;
+ }
+ BooleanByRef hasIndex = new BooleanByRef(false);
+ TraverseDeclaredFields(new _IProcedure4_101(hasIndex));
+ return !hasIndex.value;
+ }
+
+ private sealed class _IProcedure4_101 : IProcedure4
+ {
+ public _IProcedure4_101(BooleanByRef hasIndex)
+ {
+ this.hasIndex = hasIndex;
+ }
+
+ public void Apply(object arg)
+ {
+ if (((FieldMetadata)arg).HasIndex())
+ {
+ hasIndex.value = true;
+ }
+ }
+
+ private readonly BooleanByRef hasIndex;
+ }
+
+ public virtual bool IsInternal()
+ {
+ return _internal;
+ }
+
+ private IClassIndexStrategy CreateIndexStrategy()
+ {
+ return new BTreeClassIndexStrategy(this);
+ }
+
+ protected ClassMetadata(ObjectContainerBase container)
+ {
+ if (null == container)
+ {
+ throw new ArgumentNullException();
+ }
+ _container = container;
+ _index = CreateIndexStrategy();
+ _classIndexed = true;
+ _fieldAccessor = new StrictFieldAccessor();
+ }
+
+ public ClassMetadata(ObjectContainerBase container, IReflectClass classReflector)
+ {
+ if (null == container)
+ {
+ throw new ArgumentNullException();
+ }
+ _container = container;
+ ClassReflector(classReflector);
+ _index = CreateIndexStrategy();
+ _classIndexed = true;
+ if (_container.Config().ExceptionsOnNotStorable())
+ {
+ _fieldAccessor = new StrictFieldAccessor();
+ }
+ else
+ {
+ _fieldAccessor = new LenientFieldAccessor();
+ }
+ }
+
+ internal virtual IFieldAccessor FieldAccessor()
+ {
+ return _fieldAccessor;
+ }
+
+ private ITypeHandler4 CreateDefaultTypeHandler()
+ {
+ // TODO: make sure initializeAspects has been executed
+ // before the actual type handler is required
+ // and remove this method
+ return new StandardReferenceTypeHandler(this);
+ }
+
+ public virtual void CascadeActivation(IActivationContext context)
+ {
+ if (!ObjectCanActivate(context.Transaction(), context.TargetObject()))
+ {
+ return;
+ }
+ TraverseAllAspects(new _ITraverseAspectCommand_160(context));
+ }
+
+ private sealed class _ITraverseAspectCommand_160 : ITraverseAspectCommand
+ {
+ public _ITraverseAspectCommand_160(IActivationContext context)
+ {
+ this.context = context;
+ }
+
+ public void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot)
+ {
+ }
+
+ // do nothing
+ public void ProcessAspect(ClassAspect aspect, int currentSlot)
+ {
+ aspect.CascadeActivation(context);
+ }
+
+ public int DeclaredAspectCount(Db4objects.Db4o.Internal.ClassMetadata classMetadata
+ )
+ {
+ return classMetadata.DeclaredAspectCount();
+ }
+
+ public bool Cancelled()
+ {
+ return false;
+ }
+
+ private readonly IActivationContext context;
+ }
+
+ public void AddFieldIndices(StatefulBuffer buffer)
+ {
+ if (!StandardReferenceTypeHandlerIsUsed())
+ {
+ return;
+ }
+ if (HasClassIndex() || HasVirtualAttributes())
+ {
+ ObjectHeader oh = new ObjectHeader(this, buffer);
+ ObjectIdContextImpl context = new ObjectIdContextImpl(buffer.Transaction(), buffer
+ , oh, buffer.GetID());
+ Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).AddFieldIndices(context
+ );
+ }
+ }
+
+ // FIXME: This method wants to be removed.
+ private bool StandardReferenceTypeHandlerIsUsed()
+ {
+ return _typeHandler is StandardReferenceTypeHandler;
+ }
+
+ internal virtual void InitializeAspects()
+ {
+ BitTrue(Const4.CheckedChanges);
+ Collection4 aspects = new Collection4();
+ if (null != _aspects)
+ {
+ aspects.AddAll(_aspects);
+ }
+ ITypeHandler4 customTypeHandler = Container().Handlers.ConfiguredTypeHandler(ClassReflector
+ ());
+ bool dirty = IsDirty();
+ if (InstallTranslator(aspects, customTypeHandler))
+ {
+ dirty = true;
+ }
+ if (Container().DetectSchemaChanges())
+ {
+ if (GenerateCommitTimestamps())
+ {
+ if (!HasCommitTimestampField())
+ {
+ aspects.Add(Container().CommitTimestampIndex());
+ dirty = true;
+ }
+ }
+ if (GenerateUUIDs())
+ {
+ if (!HasUUIDField())
+ {
+ aspects.Add(Container().UUIDIndex());
+ dirty = true;
+ }
+ }
+ }
+ if (InstallCustomTypehandler(aspects, customTypeHandler))
+ {
+ dirty = true;
+ }
+ bool defaultFieldBehaviour = _translator == null && customTypeHandler == null;
+ if (Container().DetectSchemaChanges())
+ {
+ if (defaultFieldBehaviour)
+ {
+ if (CollectReflectFields(aspects))
+ {
+ dirty = true;
+ }
+ }
+ if (dirty)
+ {
+ _container.SetDirtyInSystemTransaction(this);
+ }
+ }
+ if (dirty || !defaultFieldBehaviour)
+ {
+ _aspects = ToClassAspectArray(aspects);
+ }
+ DiagnosticProcessor dp = _container._handlers.DiagnosticProcessor();
+ if (dp.Enabled())
+ {
+ dp.CheckClassHasFields(this);
+ }
+ if (_aspects == null)
+ {
+ _aspects = new FieldMetadata[0];
+ }
+ InitializeConstructor(customTypeHandler);
+ if (StateDead())
+ {
+ return;
+ }
+ _container.Callbacks().ClassOnRegistered(this);
+ SetStateOK();
+ }
+
+ private ClassAspect[] ToClassAspectArray(Collection4 aspects)
+ {
+ ClassAspect[] array = new ClassAspect[aspects.Size()];
+ aspects.ToArray(array);
+ for (int i = 0; i < array.Length; i++)
+ {
+ array[i].SetHandle(i);
+ }
+ return array;
+ }
+
+ private bool InstallCustomTypehandler(Collection4 aspects, ITypeHandler4 customTypeHandler
+ )
+ {
+ if (customTypeHandler == null)
+ {
+ return false;
+ }
+ if (customTypeHandler is IModificationAware)
+ {
+ _modificationChecker = (IModificationAware)customTypeHandler;
+ }
+ if (Handlers4.IsStandaloneTypeHandler(customTypeHandler))
+ {
+ _typeHandler = customTypeHandler;
+ return false;
+ }
+ bool dirty = false;
+ TypeHandlerAspect typeHandlerAspect = new TypeHandlerAspect(this, customTypeHandler
+ );
+ if (!ReplaceAspectByName(aspects, typeHandlerAspect))
+ {
+ aspects.Add(typeHandlerAspect);
+ dirty = true;
+ }
+ DisableAspectsBefore(aspects, typeHandlerAspect);
+ _customTypeHandlerAspect = typeHandlerAspect;
+ return dirty;
+ }
+
+ private void DisableAspectsBefore(Collection4 aspects, TypeHandlerAspect typeHandlerAspect
+ )
+ {
+ int disableFromVersion = aspects.IndexOf(typeHandlerAspect) + 1;
+ IEnumerator i = aspects.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ClassAspect aspect = (ClassAspect)i.Current;
+ if (aspect == typeHandlerAspect)
+ {
+ break;
+ }
+ aspect.DisableFromAspectCountVersion(disableFromVersion);
+ }
+ }
+
+ private bool InstallTranslator(Collection4 aspects, ITypeHandler4 customTypeHandler
+ )
+ {
+ if (_config == null)
+ {
+ return false;
+ }
+ IObjectTranslator translator = _config.GetTranslator();
+ if (translator == null)
+ {
+ return false;
+ }
+ ClassAspect existingAspect = AspectByName(aspects, TranslatedAspect.FieldNameFor(
+ translator));
+ if (null != existingAspect)
+ {
+ return InstallTranslatorOnExistingAspect(translator, existingAspect, aspects);
+ }
+ if (customTypeHandler == null)
+ {
+ return InstallTranslatorOnNewAspect(translator, aspects);
+ }
+ return false;
+ }
+
+ private bool InstallTranslatorOnNewAspect(IObjectTranslator translator, Collection4
+ aspects)
+ {
+ TranslatedAspect translatedAspect = new TranslatedAspect(this, translator);
+ aspects.Add(translatedAspect);
+ _translator = translatedAspect;
+ return true;
+ }
+
+ private bool InstallTranslatorOnExistingAspect(IObjectTranslator translator, ClassAspect
+ existingAspect, Collection4 aspects)
+ {
+ if (existingAspect is TranslatedAspect)
+ {
+ TranslatedAspect translatedAspect = (TranslatedAspect)existingAspect;
+ translatedAspect.InitializeTranslator(translator);
+ _translator = translatedAspect;
+ return false;
+ }
+ // older versions didn't store the aspect type properly
+ _translator = new TranslatedAspect(this, translator);
+ aspects.ReplaceByIdentity(existingAspect, _translator);
+ return true;
+ }
+
+ private bool ReplaceAspectByName(Collection4 aspects, ClassAspect aspect)
+ {
+ ClassAspect existing = AspectByName(aspects, aspect.GetName());
+ if (existing == null)
+ {
+ return false;
+ }
+ aspects.ReplaceByIdentity(existing, aspect);
+ return true;
+ }
+
+ private ClassAspect AspectByName(Collection4 aspects, string aspectName)
+ {
+ IEnumerator i = aspects.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ClassAspect current = (ClassAspect)i.Current;
+ if (current.GetName().Equals(aspectName))
+ {
+ return current;
+ }
+ }
+ return null;
+ }
+
+ public virtual bool AspectsAreInitialized()
+ {
+ if (_aspects == null)
+ {
+ return false;
+ }
+ if (_ancestor != null)
+ {
+ return _ancestor.AspectsAreInitialized();
+ }
+ return true;
+ }
+
+ private bool CollectReflectFields(Collection4 collectedAspects)
+ {
+ bool dirty = false;
+ IReflectField[] reflectFieldArray = ReflectFields();
+ for (int reflectFieldIndex = 0; reflectFieldIndex < reflectFieldArray.Length; ++reflectFieldIndex)
+ {
+ IReflectField reflectField = reflectFieldArray[reflectFieldIndex];
+ if (!StoreField(reflectField))
+ {
+ continue;
+ }
+ Db4objects.Db4o.Internal.ClassMetadata classMetadata = Handlers4.ErasedFieldType(
+ Container(), reflectField.GetFieldType());
+ if (classMetadata == null)
+ {
+ continue;
+ }
+ FieldMetadata field = new FieldMetadata(this, reflectField, classMetadata);
+ if (Contains(collectedAspects, field))
+ {
+ continue;
+ }
+ dirty = true;
+ collectedAspects.Add(field);
+ }
+ return dirty;
+ }
+
+ private bool Contains(Collection4 collectedAspects, FieldMetadata field)
+ {
+ IEnumerator aspectIterator = collectedAspects.GetEnumerator();
+ while (aspectIterator.MoveNext())
+ {
+ if (((ClassAspect)aspectIterator.Current).Equals(field))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ internal virtual void AddToIndex(Transaction trans, int id)
+ {
+ if (!trans.Container().MaintainsIndices())
+ {
+ return;
+ }
+ AddToIndex1(trans, id);
+ }
+
+ internal void AddToIndex1(Transaction a_trans, int a_id)
+ {
+ if (_ancestor != null)
+ {
+ _ancestor.AddToIndex1(a_trans, a_id);
+ }
+ if (HasClassIndex())
+ {
+ _index.Add(a_trans, a_id);
+ }
+ }
+
+ internal virtual bool AllowsQueries()
+ {
+ return HasClassIndex();
+ }
+
+ public virtual bool DescendOnCascadingActivation()
+ {
+ return true;
+ }
+
+ internal virtual void CheckChanges()
+ {
+ if (StateOK())
+ {
+ if (!BitIsTrue(Const4.CheckedChanges))
+ {
+ BitTrue(Const4.CheckedChanges);
+ if (_ancestor != null)
+ {
+ _ancestor.CheckChanges();
+ }
+ // Ancestor first, so the object length calculates
+ // correctly
+ if (_classReflector != null)
+ {
+ InitializeAspects();
+ if (!_container.IsClient && !IsReadOnlyContainer())
+ {
+ Write(_container.SystemTransaction());
+ }
+ }
+ }
+ }
+ }
+
+ public virtual void CheckType()
+ {
+ IReflectClass claxx = ClassReflector();
+ if (claxx == null)
+ {
+ return;
+ }
+ if (_container._handlers.IclassInternal.IsAssignableFrom(claxx))
+ {
+ _internal = true;
+ }
+ if (_container._handlers.IclassUnversioned.IsAssignableFrom(claxx))
+ {
+ _unversioned = true;
+ }
+ if (IsDb4oTypeImpl())
+ {
+ IDb4oTypeImpl db4oTypeImpl = (IDb4oTypeImpl)claxx.NewInstance();
+ _classIndexed = (db4oTypeImpl == null || db4oTypeImpl.HasClassIndex());
+ }
+ else
+ {
+ if (_config != null)
+ {
+ _classIndexed = _config.Indexed();
+ }
+ }
+ }
+
+ public virtual bool IsDb4oTypeImpl()
+ {
+ return _container._handlers.IclassDb4otypeimpl.IsAssignableFrom(ClassReflector());
+ }
+
+ public IUpdateDepth AdjustUpdateDepth(Transaction trans, IUpdateDepth depth)
+ {
+ return depth.Adjust(this);
+ }
+
+ public virtual bool CascadesOnDeleteOrUpdate()
+ {
+ Config4Class config = ConfigOrAncestorConfig();
+ if (config == null)
+ {
+ return false;
+ }
+ bool cascadeOnDelete = config.CascadeOnDelete() == TernaryBool.Yes;
+ bool cascadeOnUpdate = config.CascadeOnUpdate() == TernaryBool.Yes;
+ return cascadeOnDelete || cascadeOnUpdate;
+ }
+
+ public virtual FixedActivationDepth AdjustCollectionDepthToBorders(FixedActivationDepth
+ depth)
+ {
+ if (!ClassReflector().IsCollection())
+ {
+ return depth;
+ }
+ return depth.AdjustDepthToBorders();
+ }
+
+ public int UpdateDepthFromConfig()
+ {
+ if (_config != null && _config.UpdateDepth() != Const4.Unspecified)
+ {
+ return _config.UpdateDepth();
+ }
+ Config4Impl config = ConfigImpl();
+ int depth = config.UpdateDepth();
+ if (_ancestor != null)
+ {
+ int ancestordepth = _ancestor.UpdateDepthFromConfig();
+ if (ancestordepth > depth)
+ {
+ return ancestordepth;
+ }
+ }
+ return depth;
+ }
+
+ public virtual void CollectConstraints(Transaction trans, QConObject parentConstraint
+ , object obj, IVisitor4 visitor)
+ {
+ TraverseAllAspects(new _TraverseFieldCommand_534(trans, parentConstraint, obj, visitor
+ ));
+ }
+
+ private sealed class _TraverseFieldCommand_534 : TraverseFieldCommand
+ {
+ public _TraverseFieldCommand_534(Transaction trans, QConObject parentConstraint,
+ object obj, IVisitor4 visitor)
+ {
+ this.trans = trans;
+ this.parentConstraint = parentConstraint;
+ this.obj = obj;
+ this.visitor = visitor;
+ }
+
+ protected override void Process(FieldMetadata field)
+ {
+ if (field.IsEnabledOn(AspectVersionContextImpl.CheckAlwaysEnabled))
+ {
+ field.CollectConstraints(trans, parentConstraint, obj, visitor);
+ }
+ }
+
+ private readonly Transaction trans;
+
+ private readonly QConObject parentConstraint;
+
+ private readonly object obj;
+
+ private readonly IVisitor4 visitor;
+ }
+
+ public void CollectIDs(CollectIdContext context, string fieldName)
+ {
+ CollectIDs(context, new _IPredicate4_544(fieldName));
+ }
+
+ private sealed class _IPredicate4_544 : IPredicate4
+ {
+ public _IPredicate4_544(string fieldName)
+ {
+ this.fieldName = fieldName;
+ }
+
+ public bool Match(object candidate)
+ {
+ return fieldName.Equals(((ClassAspect)candidate).GetName());
+ }
+
+ private readonly string fieldName;
+ }
+
+ public void CollectIDs(CollectIdContext context)
+ {
+ CollectIDs(context, new _IPredicate4_553());
+ }
+
+ private sealed class _IPredicate4_553 : IPredicate4
+ {
+ public _IPredicate4_553()
+ {
+ }
+
+ public bool Match(object candidate)
+ {
+ return true;
+ }
+ }
+
+ private void CollectIDs(CollectIdContext context, IPredicate4 predicate)
+ {
+ if (!StandardReferenceTypeHandlerIsUsed())
+ {
+ throw new InvalidOperationException();
+ }
+ ((StandardReferenceTypeHandler)CorrectHandlerVersion(context)).CollectIDs(context
+ , predicate);
+ }
+
+ public virtual void CollectIDs(QueryingReadContext context)
+ {
+ if (!StandardReferenceTypeHandlerIsUsed())
+ {
+ throw new InvalidOperationException();
+ }
+ Handlers4.CollectIDs(context, CorrectHandlerVersion(context));
+ }
+
+ public virtual Config4Class Config()
+ {
+ return _config;
+ }
+
+ public virtual Config4Class ConfigOrAncestorConfig()
+ {
+ if (_config != null)
+ {
+ return _config;
+ }
+ if (_ancestor != null)
+ {
+ return _ancestor.ConfigOrAncestorConfig();
+ }
+ return null;
+ }
+
+ private void ResolveClassReflector(string className)
+ {
+ IReflectClass reflectClass = _container.Reflector().ForName(className);
+ if (null == reflectClass)
+ {
+ throw new InvalidOperationException("Cannot initialize ClassMetadata for '" + className
+ + "'.");
+ }
+ ClassReflector(reflectClass);
+ }
+
+ private void InitializeConstructor(ITypeHandler4 customTypeHandler)
+ {
+ if (IsTransient())
+ {
+ _container.LogMsg(23, GetName());
+ SetStateDead();
+ return;
+ }
+ if (IsInterface() || IsAbstract())
+ {
+ return;
+ }
+ IFunction4 constructor = CreateConstructor(customTypeHandler);
+ if (constructor != null)
+ {
+ _constructor = constructor;
+ return;
+ }
+ NotStorable();
+ }
+
+ private bool IsAbstract()
+ {
+ return ClassReflector().IsAbstract();
+ }
+
+ private bool IsInterface()
+ {
+ return ClassReflector().IsInterface();
+ }
+
+ private IFunction4 CreateConstructor(ITypeHandler4 customTypeHandler)
+ {
+ if (customTypeHandler is IInstantiatingTypeHandler)
+ {
+ return new _IFunction4_632(this);
+ }
+ if (HasObjectConstructor())
+ {
+ return new _IFunction4_640(this);
+ }
+ if (ClassReflector().EnsureCanBeInstantiated())
+ {
+ return new _IFunction4_648(this);
+ }
+ return null;
+ }
+
+ private sealed class _IFunction4_632 : IFunction4
+ {
+ public _IFunction4_632(ClassMetadata _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Apply(object context)
+ {
+ return this._enclosing.InstantiateWithCustomTypeHandlerIfEnabled(((UnmarshallingContext
+ )context));
+ }
+
+ private readonly ClassMetadata _enclosing;
+ }
+
+ private sealed class _IFunction4_640 : IFunction4
+ {
+ public _IFunction4_640(ClassMetadata _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Apply(object context)
+ {
+ return this._enclosing._translator.Construct(((UnmarshallingContext)context));
+ }
+
+ private readonly ClassMetadata _enclosing;
+ }
+
+ private sealed class _IFunction4_648 : IFunction4
+ {
+ public _IFunction4_648(ClassMetadata _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Apply(object context)
+ {
+ return this._enclosing.InstantiateFromReflector(((UnmarshallingContext)context).Container
+ ());
+ }
+
+ private readonly ClassMetadata _enclosing;
+ }
+
+ private void NotStorable()
+ {
+ _container.LogMsg(7, GetName());
+ SetStateDead();
+ }
+
+ private bool IsTransient()
+ {
+ return _container._handlers.IsTransient(ClassReflector());
+ }
+
+ private void ClassReflector(IReflectClass claxx)
+ {
+ _classReflector = claxx;
+ if (claxx == null)
+ {
+ _typeHandler = null;
+ return;
+ }
+ _typeHandler = CreateDefaultTypeHandler();
+ }
+
+ public virtual void Deactivate(Transaction trans, IObjectInfo reference, IActivationDepth
+ depth)
+ {
+ object obj = reference.GetObject();
+ if (ObjectCanDeactivate(trans, reference))
+ {
+ ForceDeactivation(trans, depth, obj);
+ ObjectOnDeactivate(trans, reference);
+ }
+ }
+
+ public virtual void ForceDeactivation(Transaction trans, IActivationDepth depth,
+ object obj)
+ {
+ DeactivateFields(trans.Container().ActivationContextFor(trans, obj, depth));
+ }
+
+ private void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj)
+ {
+ ObjectContainerBase container = transaction.Container();
+ container.Callbacks().ObjectOnDeactivate(transaction, obj);
+ DispatchEvent(transaction, obj.GetObject(), EventDispatchers.Deactivate);
+ }
+
+ private bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo)
+ {
+ ObjectContainerBase container = transaction.Container();
+ return container.Callbacks().ObjectCanDeactivate(transaction, objectInfo) && DispatchEvent
+ (transaction, objectInfo.GetObject(), EventDispatchers.CanDeactivate);
+ }
+
+ internal void DeactivateFields(IActivationContext context)
+ {
+ TraverseAllAspects(new _ITraverseAspectCommand_701(context));
+ }
+
+ private sealed class _ITraverseAspectCommand_701 : ITraverseAspectCommand
+ {
+ public _ITraverseAspectCommand_701(IActivationContext context)
+ {
+ this.context = context;
+ }
+
+ public void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot)
+ {
+ }
+
+ // do nothing
+ public void ProcessAspect(ClassAspect aspect, int currentSlot)
+ {
+ if (aspect.IsEnabledOn(AspectVersionContextImpl.CheckAlwaysEnabled))
+ {
+ aspect.Deactivate(context);
+ }
+ }
+
+ public int DeclaredAspectCount(Db4objects.Db4o.Internal.ClassMetadata classMetadata
+ )
+ {
+ return classMetadata.DeclaredAspectCount();
+ }
+
+ public bool Cancelled()
+ {
+ return false;
+ }
+
+ private readonly IActivationContext context;
+ }
+
+ internal void Delete(StatefulBuffer buffer, object obj)
+ {
+ RemoveFromIndex(buffer.Transaction(), buffer.GetID());
+ CascadeDeletion(buffer, obj);
+ }
+
+ private void CascadeDeletion(StatefulBuffer buffer, object obj)
+ {
+ ObjectHeader oh = new ObjectHeader(this, buffer);
+ DeleteContextImpl context = new DeleteContextImpl(buffer, oh, ClassReflector(), null
+ );
+ DeleteMembers(context, ArrayTypeFor(buffer, obj), false);
+ }
+
+ private ArrayType ArrayTypeFor(StatefulBuffer buffer, object obj)
+ {
+ return buffer.Transaction().Container()._handlers.ArrayType(obj);
+ }
+
+ ///
+ public virtual void Delete(IDeleteContext context)
+ {
+ CorrectHandlerVersion(context).Delete(context);
+ }
+
+ internal virtual void DeleteMembers(DeleteContextImpl context, ArrayType arrayType
+ , bool isUpdate)
+ {
+ StatefulBuffer buffer = (StatefulBuffer)context.Buffer();
+ int preserveCascade = context.CascadeDeleteDepth();
+ try
+ {
+ if (CascadeOnDelete())
+ {
+ if (ClassReflector().IsCollection())
+ {
+ buffer.SetCascadeDeletes(CollectionDeleteDepth(context));
+ }
+ else
+ {
+ buffer.SetCascadeDeletes(1);
+ }
+ }
+ Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).DeleteMembers(context
+ , isUpdate);
+ }
+ catch (Exception e)
+ {
+ // This a catch for changed class hierarchies.
+ // It's very ugly to catch all here but it does
+ // help to heal migration from earlier db4o
+ // versions.
+ DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor();
+ if (dp.Enabled())
+ {
+ dp.DeletionFailed();
+ }
+ }
+ buffer.SetCascadeDeletes(preserveCascade);
+ }
+
+ private int CollectionDeleteDepth(DeleteContextImpl context)
+ {
+ return 1;
+ }
+
+ public virtual TernaryBool CascadeOnDeleteTernary()
+ {
+ Config4Class config = Config();
+ TernaryBool cascadeOnDelete = TernaryBool.Unspecified;
+ if (config != null && (cascadeOnDelete = config.CascadeOnDelete()) != TernaryBool
+ .Unspecified)
+ {
+ return cascadeOnDelete;
+ }
+ if (_ancestor == null)
+ {
+ return cascadeOnDelete;
+ }
+ return _ancestor.CascadeOnDeleteTernary();
+ }
+
+ public virtual bool CascadeOnDelete()
+ {
+ return CascadeOnDeleteTernary() == TernaryBool.Yes;
+ }
+
+ public bool DispatchEvent(Transaction trans, object obj, int message)
+ {
+ return EventDispatcher().Dispatch(trans, obj, message);
+ }
+
+ public bool HasEventRegistered(Transaction trans, int eventID)
+ {
+ return EventDispatcher().HasEventRegistered(eventID);
+ }
+
+ private IEventDispatcher EventDispatcher()
+ {
+ if (null != _eventDispatcher)
+ {
+ return _eventDispatcher;
+ }
+ _eventDispatcher = EventDispatchers.ForClass(_container, ClassReflector());
+ return _eventDispatcher;
+ }
+
+ public int DeclaredAspectCount()
+ {
+ if (_aspects == null)
+ {
+ return 0;
+ }
+ return _aspects.Length;
+ }
+
+ public int AspectCount()
+ {
+ int count = DeclaredAspectCount();
+ if (_ancestor != null)
+ {
+ count += _ancestor.AspectCount();
+ }
+ return count;
+ }
+
+ // Scrolls offset in passed reader to the offset the passed field should
+ // be read at.
+ public HandlerVersion SeekToField(Transaction trans, ByteArrayBuffer buffer, FieldMetadata
+ field)
+ {
+ if (buffer == null)
+ {
+ return HandlerVersion.Invalid;
+ }
+ if (!StandardReferenceTypeHandlerIsUsed())
+ {
+ return HandlerVersion.Invalid;
+ }
+ buffer.Seek(0);
+ ObjectHeader oh = new ObjectHeader(_container, buffer);
+ bool res = oh.ClassMetadata().SeekToField(new ObjectHeaderContext(trans, buffer,
+ oh), field);
+ if (!res)
+ {
+ return HandlerVersion.Invalid;
+ }
+ return new HandlerVersion(oh.HandlerVersion());
+ }
+
+ public bool SeekToField(ObjectHeaderContext context, ClassAspect field)
+ {
+ if (!StandardReferenceTypeHandlerIsUsed())
+ {
+ return false;
+ }
+ return Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).SeekToField
+ (context, field);
+ }
+
+ public virtual bool GenerateUUIDs()
+ {
+ if (!GenerateVirtual())
+ {
+ return false;
+ }
+ TernaryBool configValue = (_config == null) ? TernaryBool.Unspecified : _config.GenerateUUIDs
+ ();
+ return Generate1(_container.Config().GenerateUUIDs(), configValue);
+ }
+
+ public virtual bool GenerateCommitTimestamps()
+ {
+ return _container.Config().GenerateCommitTimestamps().DefiniteYes();
+ }
+
+ private bool GenerateVirtual()
+ {
+ if (_unversioned)
+ {
+ return false;
+ }
+ if (_internal)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private bool Generate1(ConfigScope globalConfig, TernaryBool individualConfig)
+ {
+ return globalConfig.ApplyConfig(individualConfig);
+ }
+
+ public virtual Db4objects.Db4o.Internal.ClassMetadata GetAncestor()
+ {
+ return _ancestor;
+ }
+
+ public virtual object GetComparableObject(object forObject)
+ {
+ if (_config != null)
+ {
+ if (_config.QueryAttributeProvider() != null)
+ {
+ return _config.QueryAttributeProvider().Attribute(forObject);
+ }
+ }
+ return forObject;
+ }
+
+ public virtual Db4objects.Db4o.Internal.ClassMetadata GetHigherHierarchy(Db4objects.Db4o.Internal.ClassMetadata
+ a_classMetadata)
+ {
+ Db4objects.Db4o.Internal.ClassMetadata yc = GetHigherHierarchy1(a_classMetadata);
+ if (yc != null)
+ {
+ return yc;
+ }
+ return a_classMetadata.GetHigherHierarchy1(this);
+ }
+
+ private Db4objects.Db4o.Internal.ClassMetadata GetHigherHierarchy1(Db4objects.Db4o.Internal.ClassMetadata
+ a_classMetadata)
+ {
+ if (a_classMetadata == this)
+ {
+ return this;
+ }
+ if (_ancestor != null)
+ {
+ return _ancestor.GetHigherHierarchy1(a_classMetadata);
+ }
+ return null;
+ }
+
+ public virtual Db4objects.Db4o.Internal.ClassMetadata GetHigherOrCommonHierarchy(
+ Db4objects.Db4o.Internal.ClassMetadata a_classMetadata)
+ {
+ Db4objects.Db4o.Internal.ClassMetadata yc = GetHigherHierarchy1(a_classMetadata);
+ if (yc != null)
+ {
+ return yc;
+ }
+ if (_ancestor != null)
+ {
+ yc = _ancestor.GetHigherOrCommonHierarchy(a_classMetadata);
+ if (yc != null)
+ {
+ return yc;
+ }
+ }
+ return a_classMetadata.GetHigherHierarchy1(this);
+ }
+
+ public override byte GetIdentifier()
+ {
+ return Const4.Yapclass;
+ }
+
+ public virtual long[] GetIDs()
+ {
+ lock (Lock())
+ {
+ if (!StateOK())
+ {
+ return new long[0];
+ }
+ return GetIDs(_container.Transaction);
+ }
+ }
+
+ public virtual long[] GetIDs(Transaction trans)
+ {
+ lock (Lock())
+ {
+ if (!StateOK())
+ {
+ return new long[0];
+ }
+ if (!HasClassIndex())
+ {
+ return new long[0];
+ }
+ return trans.Container().GetIDsForClass(trans, this);
+ }
+ }
+
+ public virtual bool HasClassIndex()
+ {
+ if (!_classIndexed)
+ {
+ return false;
+ }
+ return StandardReferenceTypeHandlerIsUsed() || !(Handlers4.IsValueType(_typeHandler
+ ));
+ }
+
+ private bool AncestorHasUUIDField()
+ {
+ if (_ancestor == null)
+ {
+ return false;
+ }
+ return _ancestor.HasUUIDField();
+ }
+
+ private bool HasUUIDField()
+ {
+ if (AncestorHasUUIDField())
+ {
+ return true;
+ }
+ return Arrays4.ContainsInstanceOf(_aspects, typeof(UUIDFieldMetadata));
+ }
+
+ private bool AncestorHasVersionField()
+ {
+ if (_ancestor == null)
+ {
+ return false;
+ }
+ return _ancestor.HasVersionField();
+ }
+
+ private bool AncestorHasCommitTimestampField()
+ {
+ if (_ancestor == null)
+ {
+ return false;
+ }
+ return _ancestor.HasCommitTimestampField();
+ }
+
+ public virtual bool HasVersionField()
+ {
+ if (AncestorHasVersionField())
+ {
+ return true;
+ }
+ return Arrays4.ContainsInstanceOf(_aspects, typeof(VersionFieldMetadata));
+ }
+
+ private bool HasCommitTimestampField()
+ {
+ if (AncestorHasCommitTimestampField())
+ {
+ return true;
+ }
+ return Arrays4.ContainsInstanceOf(_aspects, typeof(CommitTimestampFieldMetadata));
+ }
+
+ public virtual IClassIndexStrategy Index()
+ {
+ return _index;
+ }
+
+ public virtual int IndexEntryCount(Transaction ta)
+ {
+ if (!StateOK())
+ {
+ return 0;
+ }
+ return _index.EntryCount(ta);
+ }
+
+ public virtual IReflectClass ClassReflector()
+ {
+ return _classReflector;
+ }
+
+ public virtual string GetName()
+ {
+ if (i_name == null)
+ {
+ if (_classReflector != null)
+ {
+ SetName(_classReflector.GetName());
+ }
+ }
+ return i_name;
+ }
+
+ public virtual IStoredClass GetParentStoredClass()
+ {
+ return GetAncestor();
+ }
+
+ public virtual IStoredField[] GetStoredFields()
+ {
+ lock (Lock())
+ {
+ if (_aspects == null)
+ {
+ return new IStoredField[0];
+ }
+ Collection4 storedFields = new Collection4();
+ TraverseDeclaredFields(new _IProcedure4_1037(storedFields));
+ IStoredField[] fields = new IStoredField[storedFields.Size()];
+ storedFields.ToArray(fields);
+ return fields;
+ }
+ }
+
+ private sealed class _IProcedure4_1037 : IProcedure4
+ {
+ public _IProcedure4_1037(Collection4 storedFields)
+ {
+ this.storedFields = storedFields;
+ }
+
+ public void Apply(object field)
+ {
+ storedFields.Add(field);
+ }
+
+ private readonly Collection4 storedFields;
+ }
+
+ public ObjectContainerBase Container()
+ {
+ return _container;
+ }
+
+ public virtual FieldMetadata FieldMetadataForName(string name)
+ {
+ ByRef byReference = new ByRef();
+ TraverseAllAspects(new _TraverseFieldCommand_1054(name, byReference));
+ return (FieldMetadata)byReference.value;
+ }
+
+ private sealed class _TraverseFieldCommand_1054 : TraverseFieldCommand
+ {
+ public _TraverseFieldCommand_1054(string name, ByRef byReference)
+ {
+ this.name = name;
+ this.byReference = byReference;
+ }
+
+ protected override void Process(FieldMetadata field)
+ {
+ if (name.Equals(field.GetName()))
+ {
+ byReference.value = field;
+ }
+ }
+
+ private readonly string name;
+
+ private readonly ByRef byReference;
+ }
+
+ ///
+ public virtual bool HasField(ObjectContainerBase container, string fieldName)
+ {
+ if (ClassReflector().IsCollection())
+ {
+ return true;
+ }
+ return FieldMetadataForName(fieldName) != null;
+ }
+
+ internal virtual bool HasVirtualAttributes()
+ {
+ if (_internal)
+ {
+ return false;
+ }
+ return HasVersionField() || HasUUIDField();
+ }
+
+ public virtual bool HoldsAnyClass()
+ {
+ return ClassReflector().IsCollection();
+ }
+
+ internal virtual void IncrementFieldsOffset1(ByteArrayBuffer a_bytes)
+ {
+ int length = ReadAspectCount(a_bytes);
+ for (int i = 0; i < length; i++)
+ {
+ _aspects[i].IncrementOffset(a_bytes);
+ }
+ }
+
+ internal bool Init(Db4objects.Db4o.Internal.ClassMetadata ancestor)
+ {
+ if (DTrace.enabled)
+ {
+ DTrace.ClassmetadataInit.Log(GetID());
+ }
+ SetConfig(ConfigImpl().ConfigClass(GetName()));
+ SetAncestor(ancestor);
+ CheckType();
+ if (AllowsQueries())
+ {
+ _index.Initialize(_container);
+ }
+ BitTrue(Const4.CheckedChanges);
+ return true;
+ }
+
+ internal void InitConfigOnUp(Transaction systemTrans)
+ {
+ Config4Class extendedConfig = Platform4.ExtendConfiguration(_classReflector, _container
+ .Configure(), _config);
+ if (extendedConfig != null)
+ {
+ _config = extendedConfig;
+ }
+ if (_config == null)
+ {
+ return;
+ }
+ if (!StateOK())
+ {
+ return;
+ }
+ InitializeFieldsConfiguration(systemTrans, extendedConfig);
+ CheckAllConfiguredFieldsExist(extendedConfig);
+ }
+
+ private void InitializeFieldsConfiguration(Transaction systemTrans, Config4Class
+ extendedConfig)
+ {
+ if (_aspects == null)
+ {
+ return;
+ }
+ for (int i = 0; i < _aspects.Length; i++)
+ {
+ if (_aspects[i] is FieldMetadata)
+ {
+ FieldMetadata field = (FieldMetadata)_aspects[i];
+ string fieldName = field.GetName();
+ if (!field.HasConfig() && extendedConfig != null && extendedConfig.ConfigField(fieldName
+ ) != null)
+ {
+ field.InitConfiguration(fieldName);
+ }
+ field.InitConfigOnUp(systemTrans);
+ }
+ }
+ }
+
+ private void CheckAllConfiguredFieldsExist(Config4Class config)
+ {
+ Hashtable4 exceptionalFields = config.ExceptionalFieldsOrNull();
+ if (exceptionalFields == null)
+ {
+ return;
+ }
+ IEnumerator i = exceptionalFields.ValuesIterator();
+ while (i.MoveNext())
+ {
+ Config4Field fieldConfig = (Config4Field)i.Current;
+ if (!fieldConfig.Used())
+ {
+ ConfigImpl().DiagnosticProcessor().ObjectFieldDoesNotExist(GetName(), fieldConfig
+ .GetName());
+ }
+ }
+ }
+
+ internal virtual void InitOnUp(Transaction systemTrans)
+ {
+ if (!StateOK())
+ {
+ return;
+ }
+ InitConfigOnUp(systemTrans);
+ StoreStaticFieldValues(systemTrans, false);
+ }
+
+ public virtual object Instantiate(UnmarshallingContext context)
+ {
+ // overridden in PrimitiveTypeMetadata
+ // never called for primitive YapAny
+ // FIXME: [TA] no longer necessary?
+ // context.adjustInstantiationDepth();
+ object obj = context.PersistentObject();
+ bool instantiating = (obj == null);
+ if (instantiating)
+ {
+ obj = InstantiateObject(context);
+ if (obj == null)
+ {
+ return null;
+ }
+ ShareTransaction(obj, context.Transaction());
+ ShareObjectReference(obj, context.ObjectReference());
+ OnInstantiate(context, obj);
+ if (context.ActivationDepth().Mode().IsPrefetch())
+ {
+ context.ObjectReference().SetStateDeactivated();
+ return obj;
+ }
+ if (!context.ActivationDepth().RequiresActivation())
+ {
+ context.ObjectReference().SetStateDeactivated();
+ return obj;
+ }
+ return Activate(context);
+ }
+ if (ActivatingActiveObject(context.ActivationDepth().Mode(), context.ObjectReference
+ ()))
+ {
+ IActivationDepth child = context.ActivationDepth().Descend(this);
+ if (child.RequiresActivation())
+ {
+ CascadeActivation(new ActivationContext4(context.Transaction(), obj, child));
+ }
+ return obj;
+ }
+ return Activate(context);
+ }
+
+ protected void OnInstantiate(UnmarshallingContext context, object obj)
+ {
+ context.SetObjectWeak(obj);
+ context.Transaction().ReferenceSystem().AddExistingReference(context.ObjectReference
+ ());
+ ObjectOnInstantiate(context.Transaction(), context.ObjectReference());
+ }
+
+ public virtual object InstantiateTransient(UnmarshallingContext context)
+ {
+ // overridden in YapClassPrimitive
+ // never called for primitive YapAny
+ object obj = InstantiateObject(context);
+ if (obj == null)
+ {
+ return null;
+ }
+ context.Container().Peeked(context.ObjectId(), obj);
+ if (context.ActivationDepth().RequiresActivation())
+ {
+ InstantiateFields(context);
+ }
+ return obj;
+ }
+
+ private bool ActivatingActiveObject(ActivationMode mode, ObjectReference @ref)
+ {
+ return !mode.IsRefresh() && @ref.IsActive();
+ }
+
+ private object Activate(UnmarshallingContext context)
+ {
+ object obj = context.PersistentObject();
+ ObjectReference objectReference = context.ObjectReference();
+ if (!ObjectCanActivate(context.Transaction(), obj))
+ {
+ objectReference.SetStateDeactivated();
+ return obj;
+ }
+ objectReference.SetStateClean();
+ if (context.ActivationDepth().RequiresActivation())
+ {
+ InstantiateFields(context);
+ }
+ ObjectOnActivate(context.Transaction(), objectReference);
+ return obj;
+ }
+
+ public virtual bool HasObjectConstructor()
+ {
+ return _translator != null && _translator.IsObjectConstructor();
+ }
+
+ public virtual bool IsTranslated()
+ {
+ return _translator != null;
+ }
+
+ private object InstantiateObject(UnmarshallingContext context)
+ {
+ object obj = _constructor.Apply(context);
+ context.PersistentObject(obj);
+ return obj;
+ }
+
+ private void ObjectOnInstantiate(Transaction transaction, IObjectInfo reference)
+ {
+ transaction.Container().Callbacks().ObjectOnInstantiate(transaction, reference);
+ }
+
+ private object InstantiateFromReflector(ObjectContainerBase stream)
+ {
+ if (_classReflector == null)
+ {
+ throw new InvalidOperationException();
+ }
+ try
+ {
+ return _classReflector.NewInstance();
+ }
+ catch (MissingMethodException)
+ {
+ Container().LogMsg(7, ClassReflector().GetName());
+ return null;
+ }
+ catch (Exception)
+ {
+ // TODO: be more helpful here
+ return null;
+ }
+ }
+
+ private void ShareObjectReference(object obj, ObjectReference @ref)
+ {
+ if (obj is IDb4oTypeImpl)
+ {
+ ((IDb4oTypeImpl)obj).SetObjectReference(@ref);
+ }
+ }
+
+ private void ShareTransaction(object obj, Transaction transaction)
+ {
+ if (obj is ITransactionAware)
+ {
+ ((ITransactionAware)obj).SetTrans(transaction);
+ }
+ }
+
+ private void ObjectOnActivate(Transaction transaction, IObjectInfo obj)
+ {
+ ObjectContainerBase container = transaction.Container();
+ container.Callbacks().ObjectOnActivate(transaction, obj);
+ DispatchEvent(transaction, obj.GetObject(), EventDispatchers.Activate);
+ }
+
+ private bool ObjectCanActivate(Transaction transaction, object obj)
+ {
+ ObjectContainerBase container = transaction.Container();
+ return container.Callbacks().ObjectCanActivate(transaction, obj) && DispatchEvent
+ (transaction, obj, EventDispatchers.CanActivate);
+ }
+
+ internal virtual void InstantiateFields(UnmarshallingContext context)
+ {
+ ITypeHandler4 handler = CorrectHandlerVersion((IHandlerVersionContext)context);
+ Handlers4.Activate(context, handler);
+ }
+
+ public virtual bool IsArray()
+ {
+ return ClassReflector().IsCollection();
+ }
+
+ internal virtual bool IsCollection(object obj)
+ {
+ return Reflector().ForObject(obj).IsCollection();
+ }
+
+ public override bool IsDirty()
+ {
+ if (!StateOK())
+ {
+ return false;
+ }
+ return base.IsDirty();
+ }
+
+ internal virtual bool IsEnum()
+ {
+ return Platform4.IsJavaEnum(Reflector(), ClassReflector());
+ }
+
+ public virtual bool HasIdentity()
+ {
+ return true;
+ }
+
+ /// no any, primitive, array or other tricks.
+ ///
+ /// no any, primitive, array or other tricks. overridden in YapClassAny and
+ /// YapClassPrimitive
+ ///
+ public virtual bool IsStronglyTyped()
+ {
+ return true;
+ }
+
+ public virtual bool IsValueType()
+ {
+ return Handlers4.HoldsValueType(_typeHandler);
+ }
+
+ private object Lock()
+ {
+ return _container.Lock();
+ }
+
+ public virtual string NameToWrite()
+ {
+ if (_config != null && _config.WriteAs() != null)
+ {
+ return _config.WriteAs();
+ }
+ if (i_name == null)
+ {
+ return string.Empty;
+ }
+ return ConfigImpl().ResolveAliasRuntimeName(i_name);
+ }
+
+ public bool CallConstructor()
+ {
+ TernaryBool specialized = CallConstructorSpecialized();
+ // FIXME: If specified, return yes?!?
+ if (!specialized.IsUnspecified())
+ {
+ return specialized.DefiniteYes();
+ }
+ return ConfigImpl().CallConstructors().DefiniteYes();
+ }
+
+ private Config4Impl ConfigImpl()
+ {
+ return _container.ConfigImpl;
+ }
+
+ private TernaryBool CallConstructorSpecialized()
+ {
+ if (_config != null)
+ {
+ TernaryBool res = _config.CallConstructor();
+ if (!res.IsUnspecified())
+ {
+ return res;
+ }
+ }
+ if (IsEnum())
+ {
+ return TernaryBool.No;
+ }
+ if (_ancestor != null)
+ {
+ return _ancestor.CallConstructorSpecialized();
+ }
+ return TernaryBool.Unspecified;
+ }
+
+ public override int OwnLength()
+ {
+ return MarshallerFamily.Current()._class.MarshalledLength(_container, this);
+ }
+
+ internal virtual void Purge()
+ {
+ _index.Purge();
+ }
+
+ // TODO: may want to add manual purge to Btree
+ // indexes here
+ public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
+ {
+ ITypeHandler4 typeHandler = CorrectHandlerVersion(context);
+ if (typeHandler is ICascadingTypeHandler)
+ {
+ return ((ICascadingTypeHandler)typeHandler).ReadCandidateHandler(context);
+ }
+ return null;
+ }
+
+ public virtual ITypeHandler4 SeekCandidateHandler(QueryingReadContext context)
+ {
+ if (IsArray())
+ {
+ if (Platform4.IsCollectionTranslator(this._config))
+ {
+ context.Seek(context.Offset() + Const4.IntLength);
+ return new ArrayHandler(null, false);
+ }
+ IncrementFieldsOffset1((ByteArrayBuffer)context.Buffer());
+ if (_ancestor != null)
+ {
+ return _ancestor.SeekCandidateHandler(context);
+ }
+ }
+ return null;
+ }
+
+ public int ReadAspectCount(IReadBuffer buffer)
+ {
+ int count = buffer.ReadInt();
+ if (count > _aspects.Length)
+ {
+ return _aspects.Length;
+ }
+ return count;
+ }
+
+ internal virtual byte[] ReadName(Transaction a_trans)
+ {
+ i_reader = a_trans.Container().ReadBufferById(a_trans, GetID());
+ return ReadName1(a_trans, i_reader);
+ }
+
+ public byte[] ReadName1(Transaction trans, ByteArrayBuffer reader)
+ {
+ if (reader == null)
+ {
+ return null;
+ }
+ i_reader = reader;
+ bool ok = false;
+ try
+ {
+ ClassMarshaller marshaller = MarshallerFamily.Current()._class;
+ i_nameBytes = marshaller.ReadName(trans, reader);
+ marshaller.ReadMetaClassID(reader);
+ // never used ???
+ SetStateUnread();
+ BitFalse(Const4.CheckedChanges);
+ BitFalse(Const4.StaticFieldsStored);
+ ok = true;
+ return i_nameBytes;
+ }
+ finally
+ {
+ if (!ok)
+ {
+ SetStateDead();
+ }
+ }
+ }
+
+ public virtual void ReadVirtualAttributes(Transaction trans, ObjectReference @ref
+ , bool lastCommitted)
+ {
+ int id = @ref.GetID();
+ ObjectContainerBase container = trans.Container();
+ ByteArrayBuffer buffer = container.ReadBufferById(trans, id, lastCommitted);
+ ObjectHeader oh = new ObjectHeader(this, buffer);
+ ObjectReferenceContext context = new ObjectReferenceContext(trans, buffer, oh, @ref
+ );
+ Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).ReadVirtualAttributes
+ (context);
+ }
+
+ public virtual GenericReflector Reflector()
+ {
+ return _container.Reflector();
+ }
+
+ public virtual void Rename(string newName)
+ {
+ if (_container.IsClient)
+ {
+ Exceptions4.ThrowRuntimeException(58);
+ }
+ int tempState = _state;
+ SetStateOK();
+ SetName(newName);
+ i_nameBytes = AsBytes(i_name);
+ SetStateDirty();
+ Write(_container.SystemTransaction());
+ IReflectClass oldReflector = _classReflector;
+ ClassReflector(Container().Reflector().ForName(newName));
+ Container().ClassCollection().RefreshClassCache(this, oldReflector);
+ Refresh();
+ _state = tempState;
+ }
+
+ //TODO: duplicates ClassMetadataRepository#asBytes
+ private byte[] AsBytes(string str)
+ {
+ return Container().StringIO().Write(str);
+ }
+
+ internal void CreateConfigAndConstructor(Hashtable4 a_byteHashTable, IReflectClass
+ claxx)
+ {
+ SetName(ResolveName(claxx));
+ SetConfig(ConfigImpl().ConfigClass(GetName()));
+ if (claxx == null)
+ {
+ ResolveClassReflector(GetName());
+ }
+ else
+ {
+ ClassReflector(claxx);
+ }
+ // createConstructor(true);
+ if (i_nameBytes != null)
+ {
+ a_byteHashTable.Remove(i_nameBytes);
+ i_nameBytes = null;
+ }
+ }
+
+ internal virtual string ResolveName(IReflectClass claxx)
+ {
+ if (claxx != null)
+ {
+ return claxx.GetName();
+ }
+ if (i_nameBytes != null)
+ {
+ string name = _container.StringIO().Read(i_nameBytes);
+ return ConfigImpl().ResolveAliasStoredName(name);
+ }
+ throw new InvalidOperationException();
+ }
+
+ internal virtual bool ReadThis()
+ {
+ bool stateUnread = StateUnread();
+ if (stateUnread)
+ {
+ SetStateOK();
+ SetStateClean();
+ }
+ if (stateUnread || StateDead())
+ {
+ ForceRead();
+ return true;
+ }
+ return false;
+ }
+
+ internal void ForceRead()
+ {
+ if (i_reader == null || BitIsTrue(Const4.Reading))
+ {
+ return;
+ }
+ BitTrue(Const4.Reading);
+ try
+ {
+ MarshallerFamily.ForConverterVersion(_container.ConverterVersion())._class.Read(_container
+ , this, i_reader);
+ i_nameBytes = null;
+ i_reader = null;
+ }
+ finally
+ {
+ BitFalse(Const4.Reading);
+ }
+ }
+
+ public override void ReadThis(Transaction a_trans, ByteArrayBuffer a_reader)
+ {
+ throw Exceptions4.VirtualException();
+ }
+
+ public virtual void Refresh()
+ {
+ if (!StateUnread())
+ {
+ ResolveClassReflector(i_name);
+ BitFalse(Const4.CheckedChanges);
+ CheckChanges();
+ TraverseDeclaredFields(new _IProcedure4_1582());
+ }
+ }
+
+ private sealed class _IProcedure4_1582 : IProcedure4
+ {
+ public _IProcedure4_1582()
+ {
+ }
+
+ public void Apply(object arg)
+ {
+ ((FieldMetadata)arg).Refresh();
+ }
+ }
+
+ internal virtual void RemoveFromIndex(Transaction ta, int id)
+ {
+ if (HasClassIndex())
+ {
+ _index.Remove(ta, id);
+ }
+ if (_ancestor != null)
+ {
+ _ancestor.RemoveFromIndex(ta, id);
+ }
+ }
+
+ internal virtual bool RenameField(string oldName, string newName)
+ {
+ BooleanByRef renamed = new BooleanByRef(false);
+ for (int i = 0; i < _aspects.Length; i++)
+ {
+ if (_aspects[i].GetName().Equals(newName))
+ {
+ _container.LogMsg(9, "class:" + GetName() + " field:" + newName);
+ return false;
+ }
+ }
+ TraverseDeclaredFields(new _IProcedure4_1607(oldName, newName, renamed));
+ return renamed.value;
+ }
+
+ private sealed class _IProcedure4_1607 : IProcedure4
+ {
+ public _IProcedure4_1607(string oldName, string newName, BooleanByRef renamed)
+ {
+ this.oldName = oldName;
+ this.newName = newName;
+ this.renamed = renamed;
+ }
+
+ public void Apply(object arg)
+ {
+ FieldMetadata field = (FieldMetadata)arg;
+ if (field.GetName().Equals(oldName))
+ {
+ field.SetName(newName);
+ renamed.value = true;
+ }
+ }
+
+ private readonly string oldName;
+
+ private readonly string newName;
+
+ private readonly BooleanByRef renamed;
+ }
+
+ internal virtual void SetConfig(Config4Class config)
+ {
+ if (config == null)
+ {
+ return;
+ }
+ // The configuration can be set by a ObjectClass#readAs setting
+ // from YapClassCollection, right after reading the meta information
+ // for the first time. In that case we never change the setting
+ if (_config == null)
+ {
+ _config = config;
+ }
+ }
+
+ internal virtual void SetName(string a_name)
+ {
+ i_name = a_name;
+ }
+
+ internal void SetStateDead()
+ {
+ BitTrue(Const4.Dead);
+ BitFalse(Const4.Continue);
+ }
+
+ private void SetStateUnread()
+ {
+ BitFalse(Const4.Dead);
+ BitTrue(Const4.Continue);
+ }
+
+ internal void SetStateOK()
+ {
+ BitFalse(Const4.Dead);
+ BitFalse(Const4.Continue);
+ }
+
+ internal virtual bool StateDead()
+ {
+ return BitIsTrue(Const4.Dead);
+ }
+
+ internal bool StateOK()
+ {
+ return BitIsFalse(Const4.Continue) && BitIsFalse(Const4.Dead) && BitIsFalse(Const4
+ .Reading);
+ }
+
+ internal virtual bool StateUnread()
+ {
+ return BitIsTrue(Const4.Continue) && BitIsFalse(Const4.Dead) && BitIsFalse(Const4
+ .Reading);
+ }
+
+ internal virtual bool StoreField(IReflectField field)
+ {
+ if (field.IsStatic())
+ {
+ return false;
+ }
+ if (IsTransient(field))
+ {
+ if (!ShouldStoreTransientFields())
+ {
+ return false;
+ }
+ }
+ return Platform4.CanSetAccessible() || field.IsPublic();
+ }
+
+ internal virtual bool ShouldStoreTransientFields()
+ {
+ Config4Class config = ConfigOrAncestorConfig();
+ if (config == null)
+ {
+ return false;
+ }
+ return config.StoreTransientFields();
+ }
+
+ private bool IsTransient(IReflectField field)
+ {
+ return field.IsTransient() || Platform4.IsTransient(field.GetFieldType());
+ }
+
+ public virtual IStoredField StoredField(string fieldName, object fieldType)
+ {
+ lock (Lock())
+ {
+ Db4objects.Db4o.Internal.ClassMetadata fieldTypeFilter = fieldType == null ? null
+ : _container.ClassMetadataForReflectClass(ReflectorUtils.ReflectClassFor(Reflector
+ (), fieldType));
+ ByRef foundField = new ByRef();
+ TraverseAllAspects(new _TraverseFieldCommand_1701(foundField, fieldName, fieldTypeFilter
+ ));
+ // TODO: implement field creation
+ return (IStoredField)foundField.value;
+ }
+ }
+
+ private sealed class _TraverseFieldCommand_1701 : TraverseFieldCommand
+ {
+ public _TraverseFieldCommand_1701(ByRef foundField, string fieldName, Db4objects.Db4o.Internal.ClassMetadata
+ fieldTypeFilter)
+ {
+ this.foundField = foundField;
+ this.fieldName = fieldName;
+ this.fieldTypeFilter = fieldTypeFilter;
+ }
+
+ protected override void Process(FieldMetadata field)
+ {
+ if (foundField.value != null)
+ {
+ return;
+ }
+ if (field.GetName().Equals(fieldName))
+ {
+ if (fieldTypeFilter == null || fieldTypeFilter == field.FieldType())
+ {
+ foundField.value = field;
+ }
+ }
+ }
+
+ private readonly ByRef foundField;
+
+ private readonly string fieldName;
+
+ private readonly Db4objects.Db4o.Internal.ClassMetadata fieldTypeFilter;
+ }
+
+ internal virtual void StoreStaticFieldValues(Transaction trans, bool force)
+ {
+ if (BitIsTrue(Const4.StaticFieldsStored) && !force)
+ {
+ return;
+ }
+ BitTrue(Const4.StaticFieldsStored);
+ if (!ShouldStoreStaticFields(trans))
+ {
+ return;
+ }
+ ObjectContainerBase stream = trans.Container();
+ stream.ShowInternalClasses(true);
+ try
+ {
+ StaticClass sc = QueryStaticClass(trans);
+ if (sc == null)
+ {
+ CreateStaticClass(trans);
+ }
+ else
+ {
+ UpdateStaticClass(trans, sc);
+ }
+ }
+ finally
+ {
+ stream.ShowInternalClasses(false);
+ }
+ }
+
+ private bool ShouldStoreStaticFields(Transaction trans)
+ {
+ return !IsReadOnlyContainer() && (StaticFieldValuesArePersisted() || Platform4.StoreStaticFieldValues
+ (trans.Reflector(), ClassReflector()));
+ }
+
+ private bool IsReadOnlyContainer()
+ {
+ return Container().Config().IsReadOnly();
+ }
+
+ private void UpdateStaticClass(Transaction trans, StaticClass sc)
+ {
+ ObjectContainerBase stream = trans.Container();
+ stream.Activate(trans, sc, new FixedActivationDepth(4));
+ StaticField[] existingFields = sc.fields;
+ IEnumerator staticFields = Iterators.Map(StaticReflectFields(), new _IFunction4_1761
+ (this, existingFields, trans));
+ sc.fields = ToStaticFieldArray(staticFields);
+ if (!stream.IsClient)
+ {
+ SetStaticClass(trans, sc);
+ }
+ }
+
+ private sealed class _IFunction4_1761 : IFunction4
+ {
+ public _IFunction4_1761(ClassMetadata _enclosing, StaticField[] existingFields, Transaction
+ trans)
+ {
+ this._enclosing = _enclosing;
+ this.existingFields = existingFields;
+ this.trans = trans;
+ }
+
+ public object Apply(object arg)
+ {
+ IReflectField reflectField = (IReflectField)arg;
+ StaticField existingField = this._enclosing.FieldByName(existingFields, reflectField
+ .GetName());
+ if (existingField != null)
+ {
+ this._enclosing.UpdateExistingStaticField(trans, existingField, reflectField);
+ return existingField;
+ }
+ return this._enclosing.ToStaticField(reflectField);
+ }
+
+ private readonly ClassMetadata _enclosing;
+
+ private readonly StaticField[] existingFields;
+
+ private readonly Transaction trans;
+ }
+
+ private void CreateStaticClass(Transaction trans)
+ {
+ if (trans.Container().IsClient)
+ {
+ return;
+ }
+ StaticClass sc = new StaticClass(GetName(), ToStaticFieldArray(StaticReflectFieldsToStaticFields
+ ()));
+ SetStaticClass(trans, sc);
+ }
+
+ private IEnumerator StaticReflectFieldsToStaticFields()
+ {
+ return Iterators.Map(StaticReflectFields(), new _IFunction4_1789(this));
+ }
+
+ private sealed class _IFunction4_1789 : IFunction4
+ {
+ public _IFunction4_1789(ClassMetadata _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public object Apply(object arg)
+ {
+ return this._enclosing.ToStaticField((IReflectField)arg);
+ }
+
+ private readonly ClassMetadata _enclosing;
+ }
+
+ protected virtual StaticField ToStaticField(IReflectField reflectField)
+ {
+ return new StaticField(reflectField.GetName(), StaticReflectFieldValue(reflectField
+ ));
+ }
+
+ private object StaticReflectFieldValue(IReflectField reflectField)
+ {
+ return _fieldAccessor.Get(reflectField, null);
+ }
+
+ private void SetStaticClass(Transaction trans, StaticClass sc)
+ {
+ // TODO: we should probably use a specific update depth here, 4?
+ trans.Container().StoreInternal(trans, sc, true);
+ }
+
+ private StaticField[] ToStaticFieldArray(IEnumerator iterator4)
+ {
+ return ToStaticFieldArray(new Collection4(iterator4));
+ }
+
+ private StaticField[] ToStaticFieldArray(Collection4 fields)
+ {
+ return (StaticField[])fields.ToArray(new StaticField[fields.Size()]);
+ }
+
+ private IEnumerator StaticReflectFields()
+ {
+ return Iterators.Filter(ReflectFields(), new _IPredicate4_1818());
+ }
+
+ private sealed class _IPredicate4_1818 : IPredicate4
+ {
+ public _IPredicate4_1818()
+ {
+ }
+
+ public bool Match(object candidate)
+ {
+ return ((IReflectField)candidate).IsStatic() && !((IReflectField)candidate).IsTransient
+ ();
+ }
+ }
+
+ private IReflectField[] ReflectFields()
+ {
+ return ClassReflector().GetDeclaredFields();
+ }
+
+ protected virtual void UpdateExistingStaticField(Transaction trans, StaticField existingField
+ , IReflectField reflectField)
+ {
+ ObjectContainerBase stream = trans.Container();
+ object newValue = StaticReflectFieldValue(reflectField);
+ if (existingField.value != null && newValue != null && existingField.value.GetType
+ () == newValue.GetType())
+ {
+ int id = stream.GetID(trans, existingField.value);
+ if (id > 0)
+ {
+ if (existingField.value != newValue)
+ {
+ // This is the clue:
+ // Bind the current static member to it's old database identity,
+ // so constants and enums will work with '=='
+ stream.Bind(trans, newValue, id);
+ // This may produce unwanted side effects if the static field object
+ // was modified in the current session. TODO:Add documentation case.
+ stream.Refresh(trans, newValue, int.MaxValue);
+ existingField.value = newValue;
+ }
+ return;
+ }
+ }
+ if (newValue == null)
+ {
+ try
+ {
+ _fieldAccessor.Set(reflectField, null, existingField.value);
+ }
+ catch (Exception)
+ {
+ }
+ // fail silently
+ // TODO: why?
+ return;
+ }
+ existingField.value = newValue;
+ }
+
+ private bool StaticFieldValuesArePersisted()
+ {
+ return (_config != null && _config.StaticFieldValuesArePersisted());
+ }
+
+ protected virtual StaticField FieldByName(StaticField[] fields, string fieldName)
+ {
+ for (int i = 0; i < fields.Length; i++)
+ {
+ StaticField field = fields[i];
+ if (fieldName.Equals(field.name))
+ {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ private StaticClass QueryStaticClass(Transaction trans)
+ {
+ IQuery q = trans.Container().Query(trans);
+ q.Constrain(Const4.ClassStaticclass);
+ q.Descend("name").Constrain(GetName());
+ IObjectSet os = q.Execute();
+ return os.Count > 0 ? (StaticClass)os.Next() : null;
+ }
+
+ public override string ToString()
+ {
+ if (i_name != null)
+ {
+ return i_name;
+ }
+ if (i_nameBytes == null)
+ {
+ return "*CLASS NAME UNKNOWN*";
+ }
+ LatinStringIO stringIO = _container == null ? Const4.stringIO : _container.StringIO
+ ();
+ return stringIO.Read(i_nameBytes);
+ }
+
+ public override bool WriteObjectBegin()
+ {
+ if (!StateOK())
+ {
+ return false;
+ }
+ return base.WriteObjectBegin();
+ }
+
+ public sealed override void WriteThis(Transaction trans, ByteArrayBuffer writer)
+ {
+ MarshallerFamily.Current()._class.Write(trans, this, writer);
+ }
+
+ public virtual IPreparedComparison PrepareComparison(IContext context, object source
+ )
+ {
+ return Handlers4.PrepareComparisonFor(_typeHandler, context, source);
+ }
+
+ public static void DefragObject(DefragmentContextImpl context)
+ {
+ ObjectHeader header = ObjectHeader.Defrag(context);
+ DefragmentContextImpl childContext = new DefragmentContextImpl(context, header);
+ header.ClassMetadata().Defragment(childContext);
+ }
+
+ public virtual void Defragment(IDefragmentContext context)
+ {
+ CorrectHandlerVersion(context).Defragment(context);
+ }
+
+ public virtual void DefragClass(DefragmentContextImpl context, int classIndexID)
+ {
+ MarshallerFamily mf = MarshallerFamily.ForConverterVersion(Container().ConverterVersion
+ ());
+ mf._class.Defrag(this, _container.StringIO(), context, classIndexID);
+ }
+
+ public static Db4objects.Db4o.Internal.ClassMetadata ReadClass(ObjectContainerBase
+ stream, ByteArrayBuffer reader)
+ {
+ ObjectHeader oh = new ObjectHeader(stream, reader);
+ return oh.ClassMetadata();
+ }
+
+ public virtual bool IsAssignableFrom(Db4objects.Db4o.Internal.ClassMetadata other
+ )
+ {
+ return ClassReflector().IsAssignableFrom(other.ClassReflector());
+ }
+
+ public virtual void SetAncestor(Db4objects.Db4o.Internal.ClassMetadata ancestor)
+ {
+ if (ancestor == this)
+ {
+ throw new InvalidOperationException();
+ }
+ _ancestor = ancestor;
+ }
+
+ public virtual object WrapWithTransactionContext(Transaction transaction, object
+ value)
+ {
+ if (value is int)
+ {
+ return value;
+ }
+ return new TransactionContext(transaction, value);
+ }
+
+ public virtual ITypeHandler4 TypeHandler()
+ {
+ return _typeHandler;
+ }
+
+ public virtual ITypeHandler4 DelegateTypeHandler(IContext context)
+ {
+ if (context is IHandlerVersionContext)
+ {
+ return CorrectHandlerVersion((IHandlerVersionContext)context);
+ }
+ return _typeHandler;
+ }
+
+ protected virtual ITypeHandler4 CorrectHandlerVersion(IHandlerVersionContext context
+ )
+ {
+ ITypeHandler4 typeHandler = HandlerRegistry.CorrectHandlerVersion(context, _typeHandler
+ );
+ if (typeHandler != _typeHandler)
+ {
+ if (typeHandler is StandardReferenceTypeHandler)
+ {
+ ((StandardReferenceTypeHandler)typeHandler).ClassMetadata(this);
+ }
+ }
+ return typeHandler;
+ }
+
+ public virtual void TraverseDeclaredFields(IProcedure4 procedure)
+ {
+ if (_aspects == null)
+ {
+ return;
+ }
+ for (int i = 0; i < _aspects.Length; i++)
+ {
+ if (_aspects[i] is FieldMetadata)
+ {
+ procedure.Apply(_aspects[i]);
+ }
+ }
+ }
+
+ public virtual void TraverseDeclaredAspects(IProcedure4 procedure)
+ {
+ if (_aspects == null)
+ {
+ return;
+ }
+ for (int i = 0; i < _aspects.Length; i++)
+ {
+ procedure.Apply(_aspects[i]);
+ }
+ }
+
+ public virtual bool AspectsAreNull()
+ {
+ return _aspects == null;
+ }
+
+ private sealed class AlwaysModified : IModificationAware
+ {
+ internal static readonly ClassMetadata.AlwaysModified Instance = new ClassMetadata.AlwaysModified
+ ();
+
+ public bool IsModified(object obj)
+ {
+ return true;
+ }
+ }
+
+ public virtual bool IsModified(object obj)
+ {
+ return _modificationChecker.IsModified(obj);
+ }
+
+ public virtual int InstanceCount()
+ {
+ return InstanceCount(_container.Transaction);
+ }
+
+ public virtual int InstanceCount(Transaction trans)
+ {
+ return _container.InstanceCount(this, trans);
+ }
+
+ public virtual bool IsStorable()
+ {
+ return !StateDead() && !IsTransient();
+ }
+
+ private object InstantiateWithCustomTypeHandlerIfEnabled(UnmarshallingContext context
+ )
+ {
+ if (!_customTypeHandlerAspect.IsEnabledOn(context))
+ {
+ return InstantiateForVersionWithoutCustomTypeHandler(context);
+ }
+ return InstantiateWithCustomTypeHandler(context);
+ }
+
+ private object InstantiateForVersionWithoutCustomTypeHandler(UnmarshallingContext
+ context)
+ {
+ IFunction4 oldVersionConstructor = CreateConstructor(null);
+ if (null == oldVersionConstructor)
+ {
+ throw new InvalidOperationException();
+ }
+ return oldVersionConstructor.Apply(context);
+ }
+
+ private object InstantiateWithCustomTypeHandler(UnmarshallingContext context)
+ {
+ ContextState contextState = context.SaveState();
+ try
+ {
+ bool fieldHasValue = SeekToField(context, _customTypeHandlerAspect);
+ if (!fieldHasValue)
+ {
+ context.RestoreState(contextState);
+ return InstantiateForVersionWithoutCustomTypeHandler(context);
+ }
+ IInstantiatingTypeHandler customTypeHandler = (IInstantiatingTypeHandler)_customTypeHandlerAspect
+ ._typeHandler;
+ return context.SlotFormat().DoWithSlotIndirection(context, new _IClosure4_2056(customTypeHandler
+ , context));
+ }
+ finally
+ {
+ context.RestoreState(contextState);
+ }
+ }
+
+ private sealed class _IClosure4_2056 : IClosure4
+ {
+ public _IClosure4_2056(IInstantiatingTypeHandler customTypeHandler, UnmarshallingContext
+ context)
+ {
+ this.customTypeHandler = customTypeHandler;
+ this.context = context;
+ }
+
+ public object Run()
+ {
+ return customTypeHandler.Instantiate(context);
+ }
+
+ private readonly IInstantiatingTypeHandler customTypeHandler;
+
+ private readonly UnmarshallingContext context;
+ }
+
+ public virtual bool IsStruct()
+ {
+ return Platform4.IsStruct(ClassReflector());
+ }
+
+ public virtual void DropClassIndex()
+ {
+ if (Container().IsClient)
+ {
+ throw new InvalidOperationException();
+ }
+ _index = CreateIndexStrategy();
+ _index.Initialize(Container());
+ Container().SetDirtyInSystemTransaction(this);
+ }
+
+ public virtual void TraverseAllAspects(ITraverseAspectCommand command)
+ {
+ AspectTraversalStrategy().TraverseAllAspects(command);
+ }
+
+ private IAspectTraversalStrategy AspectTraversalStrategy()
+ {
+ if (_aspectTraversalStrategy == null)
+ {
+ _aspectTraversalStrategy = DetectAspectTraversalStrategy();
+ }
+ return _aspectTraversalStrategy;
+ }
+
+ protected virtual IAspectTraversalStrategy DetectAspectTraversalStrategy()
+ {
+ IList ancestors = CompareAncestorHierarchy();
+ for (IEnumerator diffIter = ancestors.GetEnumerator(); diffIter.MoveNext(); )
+ {
+ HierarchyAnalyzer.Diff diff = ((HierarchyAnalyzer.Diff)diffIter.Current);
+ if (diff.IsRemoved())
+ {
+ return CreateRemovedAspectTraversalStrategy(ancestors);
+ }
+ }
+ return new StandardAspectTraversalStrategy(this);
+ }
+
+ private IAspectTraversalStrategy CreateRemovedAspectTraversalStrategy(IList ancestors
+ )
+ {
+ return new ModifiedAspectTraversalStrategy(this, ancestors);
+ }
+
+ private IList CompareAncestorHierarchy()
+ {
+ return new HierarchyAnalyzer(this, ClassReflector()).Analyze();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,30 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal
+{
+ /// TODO: remove this class or make it private to ClassMetadataRepository
+ public class ClassMetadataIterator : MappingIterator
+ {
+ private readonly ClassMetadataRepository i_collection;
+
+ internal ClassMetadataIterator(ClassMetadataRepository a_collection, IEnumerator
+ iterator) : base(iterator)
+ {
+ i_collection = a_collection;
+ }
+
+ public virtual ClassMetadata CurrentClass()
+ {
+ return (ClassMetadata)Current;
+ }
+
+ protected override object Map(object current)
+ {
+ return i_collection.ReadClassMetadata((ClassMetadata)current, null);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,745 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Metadata;
+using Db4objects.Db4o.Reflect;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public sealed class ClassMetadataRepository : PersistentBase
+ {
+ private Collection4 _classes;
+
+ private Hashtable4 _creating;
+
+ private readonly Transaction _systemTransaction;
+
+ private Hashtable4 _classMetadataByBytes;
+
+ private Hashtable4 _classMetadataByClass;
+
+ private Hashtable4 _classMetadataByName;
+
+ private Hashtable4 _classMetadataByID;
+
+ private int _classMetadataCreationDepth;
+
+ private IQueue4 _initClassMetadataOnUp;
+
+ private readonly PendingClassInits _classInits;
+
+ public ClassMetadataRepository(Transaction systemTransaction)
+ {
+ _systemTransaction = systemTransaction;
+ _initClassMetadataOnUp = new NonblockingQueue();
+ _classInits = new PendingClassInits(_systemTransaction);
+ }
+
+ public void AddClassMetadata(ClassMetadata clazz)
+ {
+ Container().SetDirtyInSystemTransaction(this);
+ _classes.Add(clazz);
+ if (clazz.StateUnread())
+ {
+ _classMetadataByBytes.Put(clazz.i_nameBytes, clazz);
+ }
+ else
+ {
+ _classMetadataByClass.Put(clazz.ClassReflector(), clazz);
+ }
+ RegisterClassMetadataById(clazz);
+ }
+
+ private void RegisterClassMetadataById(ClassMetadata clazz)
+ {
+ if (clazz.GetID() == 0)
+ {
+ clazz.Write(_systemTransaction);
+ }
+ _classMetadataByID.Put(clazz.GetID(), clazz);
+ }
+
+ private byte[] AsBytes(string str)
+ {
+ return Container().StringIO().Write(str);
+ }
+
+ public void AttachQueryNode(string fieldName, IVisitor4 visitor)
+ {
+ ClassMetadataIterator i = Iterator();
+ while (i.MoveNext())
+ {
+ ClassMetadata classMetadata = i.CurrentClass();
+ if (!classMetadata.IsInternal())
+ {
+ classMetadata.TraverseAllAspects(new _TraverseFieldCommand_65(fieldName, visitor,
+ classMetadata));
+ }
+ }
+ }
+
+ private sealed class _TraverseFieldCommand_65 : TraverseFieldCommand
+ {
+ public _TraverseFieldCommand_65(string fieldName, IVisitor4 visitor, ClassMetadata
+ classMetadata)
+ {
+ this.fieldName = fieldName;
+ this.visitor = visitor;
+ this.classMetadata = classMetadata;
+ }
+
+ protected override void Process(FieldMetadata field)
+ {
+ if (field.CanAddToQuery(fieldName))
+ {
+ visitor.Visit(new object[] { classMetadata, field });
+ }
+ }
+
+ private readonly string fieldName;
+
+ private readonly IVisitor4 visitor;
+
+ private readonly ClassMetadata classMetadata;
+ }
+
+ public void IterateTopLevelClasses(IVisitor4 visitor)
+ {
+ ClassMetadataIterator i = Iterator();
+ while (i.MoveNext())
+ {
+ ClassMetadata classMetadata = i.CurrentClass();
+ if (!classMetadata.IsInternal())
+ {
+ if (classMetadata.GetAncestor() == null)
+ {
+ visitor.Visit(classMetadata);
+ }
+ }
+ }
+ }
+
+ internal void CheckChanges()
+ {
+ IEnumerator i = _classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ((ClassMetadata)i.Current).CheckChanges();
+ }
+ }
+
+ internal bool CreateClassMetadata(ClassMetadata clazz, IReflectClass reflectClazz
+ )
+ {
+ bool result = false;
+ _classMetadataCreationDepth++;
+ try
+ {
+ IReflectClass parentReflectClazz = reflectClazz.GetSuperclass();
+ ClassMetadata parentClazz = null;
+ if (parentReflectClazz != null && !parentReflectClazz.Equals(Container()._handlers
+ .IclassObject))
+ {
+ parentClazz = ProduceClassMetadata(parentReflectClazz);
+ }
+ result = Container().CreateClassMetadata(clazz, reflectClazz, parentClazz);
+ }
+ finally
+ {
+ _classMetadataCreationDepth--;
+ }
+ InitClassMetadataOnUp();
+ return result;
+ }
+
+ private void EnsureAllClassesRead()
+ {
+ bool allClassesRead = false;
+ while (!allClassesRead)
+ {
+ Collection4 unreadClasses = new Collection4();
+ int numClasses = _classes.Size();
+ IEnumerator classIter = _classes.GetEnumerator();
+ while (classIter.MoveNext())
+ {
+ ClassMetadata clazz = (ClassMetadata)classIter.Current;
+ if (clazz.StateUnread())
+ {
+ unreadClasses.Add(clazz);
+ }
+ }
+ IEnumerator unreadIter = unreadClasses.GetEnumerator();
+ while (unreadIter.MoveNext())
+ {
+ ClassMetadata clazz = (ClassMetadata)unreadIter.Current;
+ clazz = ReadClassMetadata(clazz, null);
+ if (clazz.ClassReflector() == null)
+ {
+ clazz.ForceRead();
+ }
+ }
+ allClassesRead = (_classes.Size() == numClasses);
+ }
+ ApplyReadAs();
+ }
+
+ internal bool FieldExists(string field)
+ {
+ ClassMetadataIterator i = Iterator();
+ while (i.MoveNext())
+ {
+ if (i.CurrentClass().FieldMetadataForName(field) != null)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Collection4 ForInterface(IReflectClass claxx)
+ {
+ Collection4 col = new Collection4();
+ ClassMetadataIterator i = Iterator();
+ while (i.MoveNext())
+ {
+ ClassMetadata clazz = i.CurrentClass();
+ IReflectClass candidate = clazz.ClassReflector();
+ if (!candidate.IsInterface())
+ {
+ if (claxx.IsAssignableFrom(candidate))
+ {
+ col.Add(clazz);
+ IEnumerator j = new Collection4(col).GetEnumerator();
+ while (j.MoveNext())
+ {
+ ClassMetadata existing = (ClassMetadata)j.Current;
+ if (existing != clazz)
+ {
+ ClassMetadata higher = clazz.GetHigherHierarchy(existing);
+ if (higher != null)
+ {
+ if (higher == clazz)
+ {
+ col.Remove(existing);
+ }
+ else
+ {
+ col.Remove(clazz);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return col;
+ }
+
+ public override byte GetIdentifier()
+ {
+ return Const4.Yapclasscollection;
+ }
+
+ internal ClassMetadata GetActiveClassMetadata(IReflectClass reflectClazz)
+ {
+ return (ClassMetadata)_classMetadataByClass.Get(reflectClazz);
+ }
+
+ internal ClassMetadata ClassMetadataForReflectClass(IReflectClass reflectClazz)
+ {
+ ClassMetadata cached = (ClassMetadata)_classMetadataByClass.Get(reflectClazz);
+ if (cached != null)
+ {
+ return cached;
+ }
+ return ReadClassMetadata(reflectClazz);
+ }
+
+ private ClassMetadata ReadClassMetadata(IReflectClass reflectClazz)
+ {
+ ClassMetadata clazz = (ClassMetadata)_classMetadataByBytes.Remove(GetNameBytes(reflectClazz
+ .GetName()));
+ if (clazz == null)
+ {
+ return null;
+ }
+ return ReadClassMetadata(clazz, reflectClazz);
+ }
+
+ internal ClassMetadata ProduceClassMetadata(IReflectClass reflectClazz)
+ {
+ ClassMetadata classMetadata = ClassMetadataForReflectClass(reflectClazz);
+ if (classMetadata != null)
+ {
+ return classMetadata;
+ }
+ ClassMetadata classBeingCreated = (ClassMetadata)_creating.Get(reflectClazz);
+ if (classBeingCreated != null)
+ {
+ return classBeingCreated;
+ }
+ ClassMetadata newClassMetadata = new ClassMetadata(Container(), reflectClazz);
+ _creating.Put(reflectClazz, newClassMetadata);
+ try
+ {
+ if (!CreateClassMetadata(newClassMetadata, reflectClazz))
+ {
+ return null;
+ }
+ // ObjectContainerBase#createClassMetadata may add the ClassMetadata already,
+ // so we have to check again
+ if (!IsRegistered(reflectClazz))
+ {
+ AddClassMetadata(newClassMetadata);
+ _classInits.Process(newClassMetadata);
+ }
+ else
+ {
+ RegisterClassMetadataById(newClassMetadata);
+ if (newClassMetadata.AspectsAreNull())
+ {
+ _classInits.Process(newClassMetadata);
+ }
+ }
+ Container().SetDirtyInSystemTransaction(this);
+ }
+ finally
+ {
+ _creating.Remove(reflectClazz);
+ }
+ return newClassMetadata;
+ }
+
+ private bool IsRegistered(IReflectClass reflectClazz)
+ {
+ return _classMetadataByClass.Get(reflectClazz) != null;
+ }
+
+ internal ClassMetadata ClassMetadataForId(int id)
+ {
+ ClassMetadata classMetadata = (ClassMetadata)_classMetadataByID.Get(id);
+ if (null == classMetadata)
+ {
+ return null;
+ }
+ return ReadClassMetadata(classMetadata, null);
+ }
+
+ public int ClassMetadataIdForName(string name)
+ {
+ ClassMetadata classMetadata = (ClassMetadata)_classMetadataByBytes.Get(GetNameBytes
+ (name));
+ if (classMetadata == null)
+ {
+ classMetadata = FindInitializedClassByName(name);
+ }
+ if (classMetadata != null)
+ {
+ return classMetadata.GetID();
+ }
+ return 0;
+ }
+
+ public ClassMetadata GetClassMetadata(string name)
+ {
+ ClassMetadata classMetadata = (ClassMetadata)_classMetadataByBytes.Remove(GetNameBytes
+ (name));
+ if (classMetadata == null)
+ {
+ classMetadata = FindInitializedClassByName(name);
+ }
+ if (classMetadata != null)
+ {
+ classMetadata = ReadClassMetadata(classMetadata, null);
+ }
+ return classMetadata;
+ }
+
+ private ClassMetadata FindInitializedClassByName(string name)
+ {
+ ClassMetadata classMetadata = (ClassMetadata)_classMetadataByName.Get(name);
+ if (classMetadata != null)
+ {
+ return classMetadata;
+ }
+ ClassMetadataIterator i = Iterator();
+ while (i.MoveNext())
+ {
+ classMetadata = (ClassMetadata)i.Current;
+ if (name.Equals(classMetadata.GetName()))
+ {
+ _classMetadataByName.Put(name, classMetadata);
+ return classMetadata;
+ }
+ }
+ return null;
+ }
+
+ public int GetClassMetadataID(string name)
+ {
+ ClassMetadata clazz = (ClassMetadata)_classMetadataByBytes.Get(GetNameBytes(name)
+ );
+ if (clazz != null)
+ {
+ return clazz.GetID();
+ }
+ return 0;
+ }
+
+ internal byte[] GetNameBytes(string name)
+ {
+ return AsBytes(ResolveAliasRuntimeName(name));
+ }
+
+ private string ResolveAliasRuntimeName(string name)
+ {
+ return Container().ConfigImpl.ResolveAliasRuntimeName(name);
+ }
+
+ public void InitOnUp(Transaction systemTrans)
+ {
+ _classMetadataCreationDepth++;
+ systemTrans.Container().ShowInternalClasses(true);
+ try
+ {
+ IEnumerator i = _classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ((ClassMetadata)i.Current).InitOnUp(systemTrans);
+ }
+ }
+ finally
+ {
+ systemTrans.Container().ShowInternalClasses(false);
+ _classMetadataCreationDepth--;
+ }
+ InitClassMetadataOnUp();
+ }
+
+ internal void InitTables(int size)
+ {
+ _classes = new Collection4();
+ _classMetadataByBytes = new Hashtable4(size);
+ if (size < 16)
+ {
+ size = 16;
+ }
+ _classMetadataByClass = new Hashtable4(size);
+ _classMetadataByName = new Hashtable4(size);
+ _classMetadataByID = new Hashtable4(size);
+ _creating = new Hashtable4(1);
+ }
+
+ private void InitClassMetadataOnUp()
+ {
+ if (_classMetadataCreationDepth != 0)
+ {
+ return;
+ }
+ ClassMetadata clazz = (ClassMetadata)_initClassMetadataOnUp.Next();
+ while (clazz != null)
+ {
+ clazz.InitOnUp(_systemTransaction);
+ clazz = (ClassMetadata)_initClassMetadataOnUp.Next();
+ }
+ }
+
+ public ClassMetadataIterator Iterator()
+ {
+ return new ClassMetadataIterator(this, new ArrayIterator4(_classes.ToArray()));
+ }
+
+ private class ClassIDIterator : MappingIterator
+ {
+ public ClassIDIterator(Collection4 classes) : base(classes.GetEnumerator())
+ {
+ }
+
+ protected override object Map(object current)
+ {
+ return ((ClassMetadata)current).GetID();
+ }
+ }
+
+ public IEnumerator Ids()
+ {
+ return new ClassMetadataRepository.ClassIDIterator(_classes);
+ }
+
+ public override int OwnLength()
+ {
+ return Const4.ObjectLength + Const4.IntLength + (_classes.Size() * Const4.IdLength
+ );
+ }
+
+ internal void Purge()
+ {
+ IEnumerator i = _classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ((ClassMetadata)i.Current).Purge();
+ }
+ }
+
+ public sealed override void ReadThis(Transaction trans, ByteArrayBuffer buffer)
+ {
+ int classCount = buffer.ReadInt();
+ InitTables(classCount);
+ ObjectContainerBase container = Container();
+ int[] ids = ReadMetadataIds(buffer, classCount);
+ ByteArrayBuffer[] metadataSlots = container.ReadSlotBuffers(trans, ids);
+ for (int i = 0; i < classCount; ++i)
+ {
+ ClassMetadata classMetadata = new ClassMetadata(container, null);
+ classMetadata.SetID(ids[i]);
+ _classes.Add(classMetadata);
+ _classMetadataByID.Put(ids[i], classMetadata);
+ byte[] name = classMetadata.ReadName1(trans, metadataSlots[i]);
+ if (name != null)
+ {
+ _classMetadataByBytes.Put(name, classMetadata);
+ }
+ }
+ ApplyReadAs();
+ }
+
+ private int[] ReadMetadataIds(ByteArrayBuffer buffer, int classCount)
+ {
+ int[] ids = new int[classCount];
+ for (int i = 0; i < classCount; ++i)
+ {
+ ids[i] = buffer.ReadInt();
+ }
+ return ids;
+ }
+
+ internal Hashtable4 ClassByBytes()
+ {
+ return _classMetadataByBytes;
+ }
+
+ private void ApplyReadAs()
+ {
+ Hashtable4 readAs = Container().ConfigImpl.ReadAs();
+ IEnumerator i = readAs.Iterator();
+ while (i.MoveNext())
+ {
+ IEntry4 entry = (IEntry4)i.Current;
+ string dbName = (string)entry.Key();
+ string useName = (string)entry.Value();
+ byte[] dbbytes = GetNameBytes(dbName);
+ byte[] useBytes = GetNameBytes(useName);
+ if (ClassByBytes().Get(useBytes) == null)
+ {
+ ClassMetadata clazz = (ClassMetadata)ClassByBytes().Get(dbbytes);
+ if (clazz != null)
+ {
+ clazz.i_nameBytes = useBytes;
+ clazz.SetConfig(ConfigClass(dbName));
+ ClassByBytes().Remove(dbbytes);
+ ClassByBytes().Put(useBytes, clazz);
+ }
+ }
+ }
+ }
+
+ private Config4Class ConfigClass(string name)
+ {
+ return Container().ConfigImpl.ConfigClass(name);
+ }
+
+ public ClassMetadata ReadClassMetadata(ClassMetadata classMetadata, IReflectClass
+ clazz)
+ {
+ if (classMetadata == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (!classMetadata.StateUnread())
+ {
+ return classMetadata;
+ }
+ _classMetadataCreationDepth++;
+ try
+ {
+ classMetadata.CreateConfigAndConstructor(_classMetadataByBytes, clazz);
+ IReflectClass claxx = classMetadata.ClassReflector();
+ if (claxx != null)
+ {
+ _classMetadataByClass.Put(claxx, classMetadata);
+ classMetadata.ReadThis();
+ classMetadata.CheckChanges();
+ _initClassMetadataOnUp.Add(classMetadata);
+ }
+ }
+ finally
+ {
+ _classMetadataCreationDepth--;
+ }
+ InitClassMetadataOnUp();
+ return classMetadata;
+ }
+
+ public void CheckAllClassChanges()
+ {
+ IEnumerator i = _classMetadataByID.Keys();
+ while (i.MoveNext())
+ {
+ int classMetadataID = ((int)i.Current);
+ ClassMetadataForId(classMetadataID);
+ }
+ }
+
+ public void RefreshClasses()
+ {
+ ClassMetadataRepository rereader = new ClassMetadataRepository(_systemTransaction
+ );
+ rereader._id = _id;
+ rereader.Read(Container().SystemTransaction());
+ IEnumerator i = rereader._classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ClassMetadata clazz = (ClassMetadata)i.Current;
+ RefreshClass(clazz);
+ }
+ i = _classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ClassMetadata clazz = (ClassMetadata)i.Current;
+ clazz.Refresh();
+ }
+ }
+
+ private void RefreshClass(ClassMetadata clazz)
+ {
+ if (_classMetadataByID.Get(clazz.GetID()) == null)
+ {
+ _classes.Add(clazz);
+ _classMetadataByID.Put(clazz.GetID(), clazz);
+ RefreshClassCache(clazz, null);
+ }
+ }
+
+ public void RefreshClassCache(ClassMetadata clazz, IReflectClass oldReflector)
+ {
+ if (clazz.StateUnread())
+ {
+ _classMetadataByBytes.Put(clazz.ReadName(_systemTransaction), clazz);
+ }
+ else
+ {
+ if (oldReflector != null)
+ {
+ _classMetadataByClass.Remove(oldReflector);
+ }
+ _classMetadataByClass.Put(clazz.ClassReflector(), clazz);
+ }
+ }
+
+ internal void ReReadClassMetadata(ClassMetadata clazz)
+ {
+ if (clazz != null)
+ {
+ ReReadClassMetadata(clazz._ancestor);
+ clazz.ReadName(_systemTransaction);
+ clazz.ForceRead();
+ clazz.SetStateClean();
+ clazz.BitFalse(Const4.CheckedChanges);
+ clazz.BitFalse(Const4.Reading);
+ clazz.BitFalse(Const4.Continue);
+ clazz.BitFalse(Const4.Dead);
+ clazz.CheckChanges();
+ }
+ }
+
+ public IStoredClass[] StoredClasses()
+ {
+ EnsureAllClassesRead();
+ IStoredClass[] sclasses = new IStoredClass[_classes.Size()];
+ _classes.ToArray(sclasses);
+ return sclasses;
+ }
+
+ public void WriteAllClasses()
+ {
+ Collection4 deadClasses = new Collection4();
+ IStoredClass[] storedClasses = StoredClasses();
+ for (int i = 0; i < storedClasses.Length; i++)
+ {
+ ClassMetadata clazz = (ClassMetadata)storedClasses[i];
+ clazz.SetStateDirty();
+ if (clazz.StateDead())
+ {
+ deadClasses.Add(clazz);
+ clazz.SetStateOK();
+ }
+ }
+ for (int i = 0; i < storedClasses.Length; i++)
+ {
+ ClassMetadata clazz = (ClassMetadata)storedClasses[i];
+ clazz.Write(_systemTransaction);
+ }
+ IEnumerator it = deadClasses.GetEnumerator();
+ while (it.MoveNext())
+ {
+ ((ClassMetadata)it.Current).SetStateDead();
+ }
+ }
+
+ public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
+ {
+ buffer.WriteInt(_classes.Size());
+ IEnumerator i = _classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ buffer.WriteIDOf(trans, i.Current);
+ }
+ }
+
+ public override string ToString()
+ {
+ string str = "Active:\n";
+ IEnumerator i = _classes.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ClassMetadata clazz = (ClassMetadata)i.Current;
+ str += clazz.GetID() + " " + clazz + "\n";
+ }
+ return str;
+ }
+
+ internal ObjectContainerBase Container()
+ {
+ return _systemTransaction.Container();
+ }
+
+ public override void SetID(int id)
+ {
+ if (Container().IsClient)
+ {
+ base.SetID(id);
+ return;
+ }
+ if (_id == 0)
+ {
+ SystemData().ClassCollectionID(id);
+ }
+ base.SetID(id);
+ }
+
+ private SystemData SystemData()
+ {
+ return LocalSystemTransaction().LocalContainer().SystemData();
+ }
+
+ private LocalTransaction LocalSystemTransaction()
+ {
+ return ((LocalTransaction)_systemTransaction);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,100 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Handlers;
+
+namespace Db4objects.Db4o.Internal.Collections
+{
+ ///
+ public class BigSetBTreeManager
+ {
+ private sealed class _TransactionLocal_14 : TransactionLocal
+ {
+ public _TransactionLocal_14()
+ {
+ }
+
+ public override object InitialValueFor(Transaction transaction)
+ {
+ return new Hashtable();
+ }
+ }
+
+ private static readonly TransactionLocal _bTreesInTransaction = new _TransactionLocal_14
+ ();
+
+ private readonly Transaction _transaction;
+
+ internal BigSetBTreeManager(Transaction transaction)
+ {
+ _transaction = transaction;
+ }
+
+ internal virtual BTree ProduceBTree(int id)
+ {
+ AssertValidBTreeId(id);
+ BTree bTree = ExistingBTreeInTransactionWith(id);
+ if (null == bTree)
+ {
+ bTree = NewBTreeWithId(id);
+ RegisterBTreeInTransaction(bTree);
+ }
+ return bTree;
+ }
+
+ internal virtual BTree NewBTree()
+ {
+ BTree bTree = NewBTreeWithId(0);
+ bTree.Write(SystemTransaction());
+ RegisterBTreeInTransaction(bTree);
+ return bTree;
+ }
+
+ internal virtual void EnsureIsManaged(BTree tree)
+ {
+ RegisterBTreeInTransaction(tree);
+ }
+
+ private BTree NewBTreeWithId(int id)
+ {
+ return NewBTreeWithId(id, SystemTransaction());
+ }
+
+ private Transaction SystemTransaction()
+ {
+ return _transaction.SystemTransaction();
+ }
+
+ private static BTree NewBTreeWithId(int id, Transaction systemTransaction)
+ {
+ return new BTree(systemTransaction, id, new IntHandler());
+ }
+
+ private static void AssertValidBTreeId(int id)
+ {
+ if (id <= 0)
+ {
+ throw new ArgumentException();
+ }
+ }
+
+ private void RegisterBTreeInTransaction(BTree tree)
+ {
+ AssertValidBTreeId(tree.GetID());
+ BTreesIn(_transaction)[tree.GetID()] = tree;
+ }
+
+ private BTree ExistingBTreeInTransactionWith(int id)
+ {
+ return ((BTree)BTreesIn(_transaction)[id]);
+ }
+
+ private static IDictionary BTreesIn(Transaction transaction)
+ {
+ return ((IDictionary)transaction.Get(_bTreesInTransaction).value);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,238 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Collections;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal.Collections
+{
+ ///
+ public partial class BigSet : Db4objects.Db4o.Collections.ISet, IBigSetPersistence
+ {
+ private Db4objects.Db4o.Internal.Btree.BTree _bTree;
+
+ private Db4objects.Db4o.Internal.Transaction _transaction;
+
+ public BigSet(LocalObjectContainer db)
+ {
+ if (db == null)
+ {
+ return;
+ }
+ _transaction = db.Transaction;
+ _bTree = BTreeManager().NewBTree();
+ }
+
+ private ObjectContainerBase Container()
+ {
+ return Transaction().Container();
+ }
+
+ public virtual bool Add(E obj)
+ {
+ lock (Lock())
+ {
+ int id = GetID(obj);
+ if (id == 0)
+ {
+ Add(Store(obj));
+ return true;
+ }
+ if (Contains(id))
+ {
+ return false;
+ }
+ Add(id);
+ return true;
+ }
+ }
+
+ private int Store(E obj)
+ {
+ return Container().Store(_transaction, obj, Container().UpdateDepthProvider().Unspecified
+ (NullModifiedObjectQuery.Instance));
+ }
+
+ private void Add(int id)
+ {
+ BTreeForUpdate().Add(_transaction, id);
+ }
+
+ private int GetID(object obj)
+ {
+ return (int)Container().GetID(obj);
+ }
+
+ public virtual bool AddAll(IEnumerable iterable)
+ {
+ bool result = false;
+ foreach (E element in iterable)
+ {
+ if (Add(element))
+ {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ public virtual void Clear()
+ {
+ lock (Lock())
+ {
+ BTreeForUpdate().Clear(Transaction());
+ }
+ }
+
+ public virtual bool Contains(object obj)
+ {
+ int id = GetID(obj);
+ if (id == 0)
+ {
+ return false;
+ }
+ return Contains(id);
+ }
+
+ private bool Contains(int id)
+ {
+ lock (Lock())
+ {
+ IBTreeRange range = BTree().SearchRange(Transaction(), id);
+ return !range.IsEmpty();
+ }
+ }
+
+ public virtual bool IsEmpty
+ {
+ get
+ {
+ return Count == 0;
+ }
+ }
+
+ private IEnumerator BTreeIterator()
+ {
+ return new SynchronizedIterator4(BTree().Iterator(Transaction()), Lock());
+ }
+
+ public virtual bool Remove(object obj)
+ {
+ lock (Lock())
+ {
+ if (!Contains(obj))
+ {
+ return false;
+ }
+ int id = GetID(obj);
+ BTreeForUpdate().Remove(Transaction(), id);
+ return true;
+ }
+ }
+
+ public virtual int Count
+ {
+ get
+ {
+ lock (Lock())
+ {
+ return BTree().Size(Transaction());
+ }
+ }
+ }
+
+ public virtual object[] ToArray()
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual T[] ToArray(T[] a)
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual void Write(IWriteContext context)
+ {
+ int id = BTree().GetID();
+ if (id == 0)
+ {
+ BTree().Write(SystemTransaction());
+ }
+ context.WriteInt(BTree().GetID());
+ }
+
+ public virtual void Read(IReadContext context)
+ {
+ int id = context.ReadInt();
+ if (_bTree != null)
+ {
+ AssertCurrentBTreeId(id);
+ return;
+ }
+ _transaction = context.Transaction();
+ _bTree = BTreeManager().ProduceBTree(id);
+ }
+
+ private BigSetBTreeManager BTreeManager()
+ {
+ return new BigSetBTreeManager(_transaction);
+ }
+
+ private void AssertCurrentBTreeId(int id)
+ {
+ if (id != _bTree.GetID())
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ private Db4objects.Db4o.Internal.Transaction Transaction()
+ {
+ return _transaction;
+ }
+
+ private Db4objects.Db4o.Internal.Transaction SystemTransaction()
+ {
+ return Container().SystemTransaction();
+ }
+
+ public virtual void Invalidate()
+ {
+ _bTree = null;
+ }
+
+ private Db4objects.Db4o.Internal.Btree.BTree BTree()
+ {
+ if (_bTree == null)
+ {
+ throw new InvalidOperationException();
+ }
+ return _bTree;
+ }
+
+ private Db4objects.Db4o.Internal.Btree.BTree BTreeForUpdate()
+ {
+ Db4objects.Db4o.Internal.Btree.BTree bTree = BTree();
+ BTreeManager().EnsureIsManaged(bTree);
+ return bTree;
+ }
+
+ private object Element(int id)
+ {
+ object obj = Container().GetByID(Transaction(), id);
+ Container().Activate(obj);
+ return obj;
+ }
+
+ private object Lock()
+ {
+ return Container().Lock();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,102 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Defragment;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Collections;
+using Db4objects.Db4o.Internal.Delete;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Marshall;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal.Collections
+{
+ ///
+ public class BigSetTypeHandler : IReferenceTypeHandler, ICascadingTypeHandler
+ {
+ public virtual void Defragment(IDefragmentContext context)
+ {
+ int pos = context.Offset();
+ int id = context.ReadInt();
+ BTree bTree = NewBTree(context, id);
+ DefragmentServicesImpl services = (DefragmentServicesImpl)context.Services();
+ IDMappingCollector collector = new IDMappingCollector();
+ services.RegisterBTreeIDs(bTree, collector);
+ collector.Flush(services);
+ context.Seek(pos);
+ context.CopyID();
+ bTree.DefragBTree(services);
+ }
+
+ ///
+ public virtual void Delete(IDeleteContext context)
+ {
+ InvalidBigSet(context);
+ int id = context.ReadInt();
+ FreeBTree(context, id);
+ }
+
+ private void InvalidBigSet(IDeleteContext context)
+ {
+ IBigSetPersistence bigSet = (IBigSetPersistence)context.Transaction().ObjectForIdFromCache
+ (context.ObjectId());
+ if (bigSet != null)
+ {
+ bigSet.Invalidate();
+ }
+ }
+
+ private void FreeBTree(IDeleteContext context, int id)
+ {
+ BTree bTree = NewBTree(context, id);
+ bTree.Free(SystemTransaction(context));
+ bTree = null;
+ }
+
+ private static LocalTransaction SystemTransaction(IContext context)
+ {
+ return (LocalTransaction)context.Transaction().SystemTransaction();
+ }
+
+ private BTree NewBTree(IContext context, int id)
+ {
+ return new BTree(SystemTransaction(context), id, new IDHandler());
+ }
+
+ public virtual void Write(IWriteContext context, object obj)
+ {
+ IBigSetPersistence bigSet = (IBigSetPersistence)obj;
+ bigSet.Write(context);
+ }
+
+ public virtual IPreparedComparison PrepareComparison(IContext context, object obj
+ )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public virtual void Activate(IReferenceActivationContext context)
+ {
+ IBigSetPersistence bigSet = (IBigSetPersistence)context.PersistentObject();
+ bigSet.Read(context);
+ }
+
+ public virtual void CascadeActivation(IActivationContext context)
+ {
+ }
+
+ // TODO Auto-generated method stub
+ public virtual void CollectIDs(QueryingReadContext context)
+ {
+ }
+
+ // TODO Auto-generated method stub
+ public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,15 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal.Collections
+{
+ public interface IBigSetPersistence
+ {
+ void Write(IWriteContext context);
+
+ void Read(IReadContext context);
+
+ void Invalidate();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,94 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Delete;
+using Db4objects.Db4o.Internal.Handlers;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class CommitTimestampFieldMetadata : VirtualFieldMetadata
+ {
+ internal CommitTimestampFieldMetadata() : base(Handlers4.LongId, new LongHandler(
+ ))
+ {
+ SetName(VirtualField.CommitTimestamp);
+ }
+
+ ///
+ public override void AddFieldIndex(ObjectIdContextImpl context)
+ {
+ }
+
+ public override void AddIndexEntry(Transaction trans, int parentID, object indexEntry
+ )
+ {
+ }
+
+ public override void RemoveIndexEntry(Transaction trans, int parentID, object indexEntry
+ )
+ {
+ }
+
+ public override void Delete(DeleteContextImpl context, bool isUpdate)
+ {
+ }
+
+ internal override void Instantiate1(ObjectReferenceContext context)
+ {
+ }
+
+ internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer
+ buffer, bool isMigrating, bool isNew)
+ {
+ }
+
+ public override int LinkLength()
+ {
+ return 0;
+ }
+
+ public override void DefragAspect(IDefragmentContext context)
+ {
+ }
+
+ internal override void MarshallIgnore(IWriteBuffer buffer)
+ {
+ }
+
+ public override void Activate(UnmarshallingContext context)
+ {
+ }
+
+ // do nothing.
+ public override BTree GetIndex(Transaction trans)
+ {
+ return ((LocalTransaction)trans.SystemTransaction()).CommitTimestampSupport().TimestampToId
+ ();
+ }
+
+ public override bool HasIndex()
+ {
+ return true;
+ }
+
+ protected override IFieldIndexKey CreateFieldIndexKey(int parentID, object indexEntry
+ )
+ {
+ return new CommitTimestampSupport.TimestampEntry(parentID, ((long)indexEntry));
+ }
+
+ internal int counter = 0;
+
+ public override object Read(IObjectIdContext context)
+ {
+ int objectId = context.ObjectId();
+ long version = context.Transaction().SystemTransaction().VersionForId(objectId);
+ return version;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,270 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Events;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Handlers;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal
+{
+ public class CommitTimestampSupport
+ {
+ private BTree _idToTimestamp;
+
+ private BTree _timestampToId;
+
+ private readonly LocalObjectContainer _container;
+
+ public CommitTimestampSupport(LocalObjectContainer container)
+ {
+ _container = container;
+ }
+
+ public virtual void EnsureInitialized()
+ {
+ IdToTimestamp();
+ }
+
+ public virtual BTree IdToTimestamp()
+ {
+ if (_idToTimestamp != null)
+ {
+ return _idToTimestamp;
+ }
+ if (!_container.Config().GenerateCommitTimestamps().DefiniteYes())
+ {
+ return null;
+ }
+ Initialize();
+ return _idToTimestamp;
+ }
+
+ public virtual BTree TimestampToId()
+ {
+ if (_timestampToId != null)
+ {
+ return _timestampToId;
+ }
+ if (!_container.Config().GenerateCommitTimestamps().DefiniteYes())
+ {
+ return null;
+ }
+ Initialize();
+ return _timestampToId;
+ }
+
+ private void Initialize()
+ {
+ int idToTimestampIndexId = _container.SystemData().IdToTimestampIndexId();
+ int timestampToIdIndexId = _container.SystemData().TimestampToIdIndexId();
+ _idToTimestamp = new BTree(_container.SystemTransaction(), idToTimestampIndexId,
+ new CommitTimestampSupport.TimestampEntryById());
+ _timestampToId = new BTree(_container.SystemTransaction(), timestampToIdIndexId,
+ new CommitTimestampSupport.IdEntryByTimestamp());
+ if (idToTimestampIndexId != _idToTimestamp.GetID())
+ {
+ StoreBtreesIds();
+ }
+ EventRegistryFactory.ForObjectContainer(_container).Committing += new System.EventHandler
+ (new _IEventListener4_69(this).OnEvent);
+ }
+
+ private sealed class _IEventListener4_69
+ {
+ public _IEventListener4_69(CommitTimestampSupport _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args)
+ {
+ LocalTransaction trans = (LocalTransaction)((CommitEventArgs)args).Transaction();
+ long transactionTimestamp = trans.Timestamp();
+ long commitTimestamp = (transactionTimestamp > 0) ? transactionTimestamp : this._enclosing
+ ._container.GenerateTimeStampId();
+ Transaction sysTrans = trans.SystemTransaction();
+ this.AddTimestamp(sysTrans, ((CommitEventArgs)args).Added.GetEnumerator(), commitTimestamp
+ );
+ this.AddTimestamp(sysTrans, ((CommitEventArgs)args).Updated.GetEnumerator(), commitTimestamp
+ );
+ this.AddTimestamp(sysTrans, ((CommitEventArgs)args).Deleted.GetEnumerator(), 0);
+ }
+
+ private void AddTimestamp(Transaction trans, IEnumerator it, long commitTimestamp
+ )
+ {
+ while (it.MoveNext())
+ {
+ IObjectInfo objInfo = (IObjectInfo)it.Current;
+ CommitTimestampSupport.TimestampEntry te = new CommitTimestampSupport.TimestampEntry
+ ((int)objInfo.GetInternalID(), commitTimestamp);
+ CommitTimestampSupport.TimestampEntry oldEntry = (CommitTimestampSupport.TimestampEntry
+ )this._enclosing._idToTimestamp.Remove(trans, te);
+ if (oldEntry != null)
+ {
+ this._enclosing._timestampToId.Remove(trans, oldEntry);
+ }
+ if (commitTimestamp != 0)
+ {
+ this._enclosing._idToTimestamp.Add(trans, te);
+ this._enclosing._timestampToId.Add(trans, te);
+ }
+ }
+ }
+
+ private readonly CommitTimestampSupport _enclosing;
+ }
+
+ private void StoreBtreesIds()
+ {
+ _container.SystemData().IdToTimestampIndexId(_idToTimestamp.GetID());
+ _container.SystemData().TimestampToIdIndexId(_timestampToId.GetID());
+ _container.GetFileHeader().WriteVariablePart(_container);
+ }
+
+ public class TimestampEntry : IFieldIndexKey
+ {
+ public readonly int objectId;
+
+ public readonly long commitTimestamp;
+
+ public override string ToString()
+ {
+ return "TimestampEntry [objectId=" + objectId + ", commitTimestamp=" + commitTimestamp
+ + "]";
+ }
+
+ public TimestampEntry(int objectId, long commitTimestamp)
+ {
+ this.objectId = objectId;
+ this.commitTimestamp = commitTimestamp;
+ }
+
+ public virtual int ParentID()
+ {
+ return objectId;
+ }
+
+ public virtual long GetCommitTimestamp()
+ {
+ return commitTimestamp;
+ }
+
+ public virtual object Value()
+ {
+ return commitTimestamp;
+ }
+ }
+
+ private class TimestampEntryById : IIndexable4
+ {
+ public virtual IPreparedComparison PrepareComparison(IContext context, object first
+ )
+ {
+ return new _IPreparedComparison_139(first);
+ }
+
+ private sealed class _IPreparedComparison_139 : IPreparedComparison
+ {
+ public _IPreparedComparison_139(object first)
+ {
+ this.first = first;
+ }
+
+ public int CompareTo(object second)
+ {
+ return IntHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).objectId
+ , ((CommitTimestampSupport.TimestampEntry)second).objectId);
+ }
+
+ private readonly object first;
+ }
+
+ public virtual int LinkLength()
+ {
+ return Const4.IntLength + Const4.LongLength;
+ }
+
+ public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer reader)
+ {
+ return new CommitTimestampSupport.TimestampEntry(reader.ReadInt(), reader.ReadLong
+ ());
+ }
+
+ public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
+ obj)
+ {
+ writer.WriteInt(((CommitTimestampSupport.TimestampEntry)obj).ParentID());
+ writer.WriteLong(((CommitTimestampSupport.TimestampEntry)obj).GetCommitTimestamp(
+ ));
+ }
+
+ public virtual void DefragIndexEntry(DefragmentContextImpl context)
+ {
+ // we are storing ids in the btree, so the order will change when the ids change
+ // to properly defrag the btree we need to readd all the entries
+ throw new NotSupportedException();
+ }
+ }
+
+ private sealed class IdEntryByTimestamp : CommitTimestampSupport.TimestampEntryById
+ {
+ public override IPreparedComparison PrepareComparison(IContext context, object first
+ )
+ {
+ return new _IPreparedComparison_168(first);
+ }
+
+ private sealed class _IPreparedComparison_168 : IPreparedComparison
+ {
+ public _IPreparedComparison_168(object first)
+ {
+ this.first = first;
+ }
+
+ public int CompareTo(object second)
+ {
+ int result = LongHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).commitTimestamp
+ , ((CommitTimestampSupport.TimestampEntry)second).commitTimestamp);
+ if (result != 0)
+ {
+ return result;
+ }
+ return IntHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).objectId
+ , ((CommitTimestampSupport.TimestampEntry)second).objectId);
+ }
+
+ private readonly object first;
+ }
+ }
+
+ public virtual long VersionForId(int id)
+ {
+ if (IdToTimestamp() == null || id == 0)
+ {
+ return 0;
+ }
+ CommitTimestampSupport.TimestampEntry te = (CommitTimestampSupport.TimestampEntry
+ )IdToTimestamp().Search(_container.SystemTransaction(), new CommitTimestampSupport.TimestampEntry
+ (id, 0));
+ if (te == null)
+ {
+ return 0;
+ }
+ return te.GetCommitTimestamp();
+ }
+
+ public virtual void Put(Transaction trans, int objectId, long version)
+ {
+ CommitTimestampSupport.TimestampEntry te = new CommitTimestampSupport.TimestampEntry
+ (objectId, version);
+ IdToTimestamp().Add(trans, te);
+ TimestampToId().Add(trans, te);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ ///
+ public class CacheConfigurationImpl : ICacheConfiguration
+ {
+ private readonly Config4Impl _config;
+
+ public CacheConfigurationImpl(Config4Impl config)
+ {
+ _config = config;
+ }
+
+ [System.ObsoleteAttribute(@"since 7.14 BTrees have their own LRU cache now.")]
+ public virtual int SlotCacheSize
+ {
+ set
+ {
+ int size = value;
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,281 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.IO;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Config.Encoding;
+using Db4objects.Db4o.Diagnostic;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Reflect;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ public class CommonConfigurationImpl : ICommonConfiguration
+ {
+ private readonly Config4Impl _config;
+
+ public CommonConfigurationImpl(Config4Impl config)
+ {
+ _config = config;
+ }
+
+ public virtual int ActivationDepth
+ {
+ get
+ {
+ return _config.ActivationDepth();
+ }
+ set
+ {
+ int depth = value;
+ _config.ActivationDepth(depth);
+ }
+ }
+
+ public virtual void Add(IConfigurationItem configurationItem)
+ {
+ _config.Add(configurationItem);
+ }
+
+ public virtual void AddAlias(IAlias alias)
+ {
+ _config.AddAlias(alias);
+ }
+
+ public virtual void RemoveAlias(IAlias alias)
+ {
+ _config.RemoveAlias(alias);
+ }
+
+ public virtual bool AllowVersionUpdates
+ {
+ set
+ {
+ bool flag = value;
+ _config.AllowVersionUpdates(flag);
+ }
+ }
+
+ public virtual bool AutomaticShutDown
+ {
+ set
+ {
+ bool flag = value;
+ _config.AutomaticShutDown(flag);
+ }
+ }
+
+ public virtual int BTreeNodeSize
+ {
+ set
+ {
+ int size = value;
+ _config.BTreeNodeSize(size);
+ }
+ }
+
+ public virtual bool Callbacks
+ {
+ set
+ {
+ bool flag = value;
+ _config.Callbacks(flag);
+ }
+ }
+
+ public virtual void CallbackMode(CallBackMode mode)
+ {
+ _config.CallbackMode(mode);
+ }
+
+ public virtual bool CallConstructors
+ {
+ set
+ {
+ bool flag = value;
+ _config.CallConstructors(flag);
+ }
+ }
+
+ public virtual bool DetectSchemaChanges
+ {
+ set
+ {
+ bool flag = value;
+ _config.DetectSchemaChanges(flag);
+ }
+ }
+
+ public virtual IDiagnosticConfiguration Diagnostic
+ {
+ get
+ {
+ return _config.Diagnostic();
+ }
+ }
+
+ public virtual bool ExceptionsOnNotStorable
+ {
+ set
+ {
+ bool flag = value;
+ _config.ExceptionsOnNotStorable(flag);
+ }
+ }
+
+ public virtual bool InternStrings
+ {
+ set
+ {
+ bool flag = value;
+ _config.InternStrings(flag);
+ }
+ }
+
+ public virtual void MarkTransient(string attributeName)
+ {
+ _config.MarkTransient(attributeName);
+ }
+
+ public virtual int MessageLevel
+ {
+ set
+ {
+ int level = value;
+ _config.MessageLevel(level);
+ }
+ }
+
+ public virtual IObjectClass ObjectClass(object clazz)
+ {
+ return _config.ObjectClass(clazz);
+ }
+
+ public virtual bool OptimizeNativeQueries
+ {
+ get
+ {
+ return _config.OptimizeNativeQueries();
+ }
+ set
+ {
+ bool optimizeNQ = value;
+ _config.OptimizeNativeQueries(optimizeNQ);
+ }
+ }
+
+ public virtual IQueryConfiguration Queries
+ {
+ get
+ {
+ return _config.Queries();
+ }
+ }
+
+ public virtual void ReflectWith(IReflector reflector)
+ {
+ _config.ReflectWith(reflector);
+ }
+
+ public virtual TextWriter OutStream
+ {
+ set
+ {
+ TextWriter outStream = value;
+ _config.SetOut(outStream);
+ }
+ }
+
+ public virtual IStringEncoding StringEncoding
+ {
+ set
+ {
+ IStringEncoding encoding = value;
+ _config.StringEncoding(encoding);
+ }
+ }
+
+ public virtual bool TestConstructors
+ {
+ set
+ {
+ bool flag = value;
+ _config.TestConstructors(flag);
+ }
+ }
+
+ public virtual int UpdateDepth
+ {
+ set
+ {
+ int depth = value;
+ _config.UpdateDepth(depth);
+ }
+ }
+
+ public virtual bool WeakReferences
+ {
+ set
+ {
+ bool flag = value;
+ _config.WeakReferences(flag);
+ }
+ }
+
+ public virtual int WeakReferenceCollectionInterval
+ {
+ set
+ {
+ int milliseconds = value;
+ _config.WeakReferenceCollectionInterval(milliseconds);
+ }
+ }
+
+ public virtual void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4
+ typeHandler)
+ {
+ _config.RegisterTypeHandler(predicate, typeHandler);
+ }
+
+ public virtual IEnvironmentConfiguration Environment
+ {
+ get
+ {
+ return new _IEnvironmentConfiguration_139(this);
+ }
+ }
+
+ private sealed class _IEnvironmentConfiguration_139 : IEnvironmentConfiguration
+ {
+ public _IEnvironmentConfiguration_139(CommonConfigurationImpl _enclosing)
+ {
+ this._enclosing = _enclosing;
+ }
+
+ public void Add(object service)
+ {
+ this._enclosing._config.EnvironmentContributions().Add(service);
+ }
+
+ private readonly CommonConfigurationImpl _enclosing;
+ }
+
+ public virtual void NameProvider(INameProvider provider)
+ {
+ _config.NameProvider(provider);
+ }
+
+ public virtual int MaxStackDepth
+ {
+ get
+ {
+ return _config.MaxStackDepth();
+ }
+ set
+ {
+ int maxStackDepth = value;
+ _config.MaxStackDepth(maxStackDepth);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,38 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Config;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ public class Db4oLegacyConfigurationBridge
+ {
+ public static IEmbeddedConfiguration AsEmbeddedConfiguration(IConfiguration legacy
+ )
+ {
+ return new EmbeddedConfigurationImpl(legacy);
+ }
+
+ public static ICommonConfiguration AsCommonConfiguration(IConfiguration config)
+ {
+ return new CommonConfigurationImpl((Config4Impl)config);
+ }
+
+ public static Config4Impl AsLegacy(object config)
+ {
+ return ((ILegacyConfigurationProvider)config).Legacy();
+ }
+
+ public static IFileConfiguration AsFileConfiguration(IConfiguration config)
+ {
+ return new FileConfigurationImpl((Config4Impl)config);
+ }
+
+ public static IIdSystemConfiguration AsIdSystemConfiguration(IConfiguration config
+ )
+ {
+ return new IdSystemConfigurationImpl((Config4Impl)config);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,88 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System.Collections;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Config;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ public class EmbeddedConfigurationImpl : IEmbeddedConfiguration, ILegacyConfigurationProvider
+ {
+ private readonly Config4Impl _legacy;
+
+ private IList _configItems;
+
+ public EmbeddedConfigurationImpl(IConfiguration legacy)
+ {
+ _legacy = (Config4Impl)legacy;
+ }
+
+ public virtual ICacheConfiguration Cache
+ {
+ get
+ {
+ return new CacheConfigurationImpl(_legacy);
+ }
+ }
+
+ public virtual IFileConfiguration File
+ {
+ get
+ {
+ return new FileConfigurationImpl(_legacy);
+ }
+ }
+
+ public virtual ICommonConfiguration Common
+ {
+ get
+ {
+ return Db4oLegacyConfigurationBridge.AsCommonConfiguration(Legacy());
+ }
+ }
+
+ public virtual Config4Impl Legacy()
+ {
+ return _legacy;
+ }
+
+ public virtual void AddConfigurationItem(IEmbeddedConfigurationItem configItem)
+ {
+ if (_configItems != null && _configItems.Contains(configItem))
+ {
+ return;
+ }
+ configItem.Prepare(this);
+ if (_configItems == null)
+ {
+ _configItems = new ArrayList();
+ }
+ _configItems.Add(configItem);
+ }
+
+ public virtual void ApplyConfigurationItems(IEmbeddedObjectContainer container)
+ {
+ if (_configItems == null)
+ {
+ return;
+ }
+ for (IEnumerator configItemIter = _configItems.GetEnumerator(); configItemIter.MoveNext
+ (); )
+ {
+ IEmbeddedConfigurationItem configItem = ((IEmbeddedConfigurationItem)configItemIter
+ .Current);
+ configItem.Apply(container);
+ }
+ }
+
+ public virtual IIdSystemConfiguration IdSystem
+ {
+ get
+ {
+ return new IdSystemConfigurationImpl(_legacy);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,147 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.IO;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ internal class FileConfigurationImpl : IFileConfiguration
+ {
+ private readonly Config4Impl _config;
+
+ public FileConfigurationImpl(Config4Impl config)
+ {
+ _config = config;
+ }
+
+ public virtual int BlockSize
+ {
+ set
+ {
+ int bytes = value;
+ _config.BlockSize(bytes);
+ }
+ }
+
+ public virtual int DatabaseGrowthSize
+ {
+ set
+ {
+ int bytes = value;
+ _config.DatabaseGrowthSize(bytes);
+ }
+ }
+
+ public virtual void DisableCommitRecovery()
+ {
+ _config.DisableCommitRecovery();
+ }
+
+ public virtual IFreespaceConfiguration Freespace
+ {
+ get
+ {
+ return _config.Freespace();
+ }
+ }
+
+ public virtual ConfigScope GenerateUUIDs
+ {
+ set
+ {
+ ConfigScope setting = value;
+ _config.GenerateUUIDs(setting);
+ }
+ }
+
+ public virtual ConfigScope GenerateVersionNumbers
+ {
+ set
+ {
+ ConfigScope setting = value;
+ _config.GenerateVersionNumbers(setting);
+ }
+ }
+
+ public virtual bool GenerateCommitTimestamps
+ {
+ set
+ {
+ bool setting = value;
+ _config.GenerateCommitTimestamps(setting);
+ }
+ }
+
+ ///
+ public virtual IStorage Storage
+ {
+ get
+ {
+ return _config.Storage;
+ }
+ set
+ {
+ IStorage factory = value;
+ _config.Storage = factory;
+ }
+ }
+
+ public virtual bool LockDatabaseFile
+ {
+ set
+ {
+ bool flag = value;
+ _config.LockDatabaseFile(flag);
+ }
+ }
+
+ ///
+ ///
+ public virtual long ReserveStorageSpace
+ {
+ set
+ {
+ long byteCount = value;
+ _config.ReserveStorageSpace(byteCount);
+ }
+ }
+
+ ///
+ public virtual string BlobPath
+ {
+ set
+ {
+ string path = value;
+ _config.SetBlobPath(path);
+ }
+ }
+
+ public virtual bool ReadOnly
+ {
+ set
+ {
+ bool flag = value;
+ _config.ReadOnly(flag);
+ }
+ }
+
+ public virtual bool RecoveryMode
+ {
+ set
+ {
+ bool flag = value;
+ _config.RecoveryMode(flag);
+ }
+ }
+
+ public virtual bool AsynchronousSync
+ {
+ set
+ {
+ bool flag = value;
+ _config.AsynchronousSync(flag);
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,43 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ ///
+ public class IdSystemConfigurationImpl : IIdSystemConfiguration
+ {
+ private readonly Config4Impl _config;
+
+ public IdSystemConfigurationImpl(Config4Impl config)
+ {
+ _config = config;
+ }
+
+ public virtual void UsePointerBasedSystem()
+ {
+ _config.UsePointerBasedIdSystem();
+ }
+
+ public virtual void UseStackedBTreeSystem()
+ {
+ _config.UseStackedBTreeIdSystem();
+ }
+
+ public virtual void UseInMemorySystem()
+ {
+ _config.UseInMemoryIdSystem();
+ }
+
+ public virtual void UseCustomSystem(IIdSystemFactory factory)
+ {
+ _config.UseCustomIdSystem(factory);
+ }
+
+ public virtual void UseSingleBTreeSystem()
+ {
+ _config.UseSingleBTreeIdSystem();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal.Config
+{
+ public interface ILegacyConfigurationProvider
+ {
+ Config4Impl Legacy();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,117 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public abstract class Config4Abstract
+ {
+ protected KeySpecHashtable4 _config;
+
+ private static readonly KeySpec CascadeOnActivateKey = new KeySpec(TernaryBool.Unspecified
+ );
+
+ private static readonly KeySpec CascadeOnDeleteKey = new KeySpec(TernaryBool.Unspecified
+ );
+
+ private static readonly KeySpec CascadeOnUpdateKey = new KeySpec(TernaryBool.Unspecified
+ );
+
+ private static readonly KeySpec NameKey = new KeySpec(null);
+
+ public Config4Abstract() : this(new KeySpecHashtable4(10))
+ {
+ }
+
+ protected Config4Abstract(KeySpecHashtable4 config)
+ {
+ _config = (KeySpecHashtable4)config.DeepClone(this);
+ }
+
+ public virtual void CascadeOnActivate(bool flag)
+ {
+ PutThreeValued(CascadeOnActivateKey, flag);
+ }
+
+ public virtual void CascadeOnDelete(bool flag)
+ {
+ PutThreeValued(CascadeOnDeleteKey, flag);
+ }
+
+ public virtual void CascadeOnUpdate(bool flag)
+ {
+ PutThreeValued(CascadeOnUpdateKey, flag);
+ }
+
+ protected virtual void PutThreeValued(KeySpec spec, bool flag)
+ {
+ _config.Put(spec, TernaryBool.ForBoolean(flag));
+ }
+
+ protected virtual void PutThreeValuedInt(KeySpec spec, bool flag)
+ {
+ _config.Put(spec, flag ? 1 : -1);
+ }
+
+ public virtual TernaryBool CascadeOnActivate()
+ {
+ return Cascade(CascadeOnActivateKey);
+ }
+
+ public virtual TernaryBool CascadeOnDelete()
+ {
+ return Cascade(CascadeOnDeleteKey);
+ }
+
+ public virtual TernaryBool CascadeOnUpdate()
+ {
+ return Cascade(CascadeOnUpdateKey);
+ }
+
+ private TernaryBool Cascade(KeySpec spec)
+ {
+ return _config.GetAsTernaryBool(spec);
+ }
+
+ internal abstract string ClassName();
+
+ /// Will raise an exception if argument class doesn't match this class - violates equals() contract in favor of failing fast.
+ ///
+ /// Will raise an exception if argument class doesn't match this class - violates equals() contract in favor of failing fast.
+ ///
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (null == obj)
+ {
+ return false;
+ }
+ if (GetType() != obj.GetType())
+ {
+ Exceptions4.ShouldNeverHappen();
+ }
+ return GetName().Equals(((Db4objects.Db4o.Internal.Config4Abstract)obj).GetName()
+ );
+ }
+
+ public override int GetHashCode()
+ {
+ return GetName().GetHashCode();
+ }
+
+ public virtual string GetName()
+ {
+ return _config.GetAsString(NameKey);
+ }
+
+ protected virtual void SetName(string name)
+ {
+ _config.Put(NameKey, name);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,344 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Reflect;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class Config4Class : Config4Abstract, IObjectClass, IDeepClone
+ {
+ private readonly Config4Impl _configImpl;
+
+ private static readonly KeySpec CallConstructorKey = new KeySpec(TernaryBool.Unspecified
+ );
+
+ private static readonly KeySpec ClassIndexedKey = new KeySpec(true);
+
+ private static readonly KeySpec ExceptionalFieldsKey = new KeySpec(null);
+
+ private static readonly KeySpec GenerateUuidsKey = new KeySpec(TernaryBool.Unspecified
+ );
+
+ ///
+ /// We are running into cyclic dependancies on reading the PBootRecord
+ /// object, if we maintain MetaClass information there
+ ///
+ private static readonly KeySpec MaintainMetaclassKey = new KeySpec(true);
+
+ private static readonly KeySpec MaximumActivationDepthKey = new KeySpec(0);
+
+ private static readonly KeySpec MinimumActivationDepthKey = new KeySpec(0);
+
+ private static readonly KeySpec PersistStaticFieldValuesKey = new KeySpec(false);
+
+ private static readonly KeySpec QueryAttributeProviderKey = new KeySpec(null);
+
+ private static readonly KeySpec StoreTransientFieldsKey = new KeySpec(false);
+
+ private static readonly KeySpec TranslatorKey = new KeySpec(null);
+
+ private static readonly KeySpec TranslatorNameKey = new KeySpec((string)null);
+
+ private static readonly KeySpec UpdateDepthKey = new KeySpec(Const4.Unspecified);
+
+ private static readonly KeySpec WriteAsKey = new KeySpec((string)null);
+
+ protected Config4Class(Config4Impl configuration, KeySpecHashtable4 config) : base
+ (config)
+ {
+ _configImpl = configuration;
+ }
+
+ internal Config4Class(Config4Impl a_configuration, string a_name)
+ {
+ _configImpl = a_configuration;
+ SetName(a_name);
+ }
+
+ public virtual int AdjustActivationDepth(int depth)
+ {
+ TernaryBool cascadeOnActivate = CascadeOnActivate();
+ if (cascadeOnActivate.DefiniteYes() && depth < 2)
+ {
+ depth = 2;
+ }
+ if (cascadeOnActivate.DefiniteNo() && depth > 1)
+ {
+ depth = 1;
+ }
+ if (Config().ClassActivationDepthConfigurable())
+ {
+ int minimumActivationDepth = MinimumActivationDepth();
+ if (minimumActivationDepth != 0 && depth < minimumActivationDepth)
+ {
+ depth = minimumActivationDepth;
+ }
+ int maximumActivationDepth = MaximumActivationDepth();
+ if (maximumActivationDepth != 0 && depth > maximumActivationDepth)
+ {
+ depth = maximumActivationDepth;
+ }
+ }
+ return depth;
+ }
+
+ public virtual void CallConstructor(bool flag)
+ {
+ PutThreeValued(CallConstructorKey, flag);
+ }
+
+ internal override string ClassName()
+ {
+ return GetName();
+ }
+
+ internal virtual IReflectClass ClassReflector()
+ {
+ return Config().Reflector().ForName(GetName());
+ }
+
+ [System.ObsoleteAttribute]
+ public virtual void Compare(IObjectAttribute comparator)
+ {
+ _config.Put(QueryAttributeProviderKey, comparator);
+ }
+
+ internal virtual Config4Field ConfigField(string fieldName)
+ {
+ Hashtable4 exceptionalFields = ExceptionalFieldsOrNull();
+ if (exceptionalFields == null)
+ {
+ return null;
+ }
+ Config4Field config4Field = (Config4Field)exceptionalFields.Get(fieldName);
+ if (config4Field == null)
+ {
+ return null;
+ }
+ config4Field.Used(true);
+ return config4Field;
+ }
+
+ public virtual object DeepClone(object param)
+ {
+ Config4Impl parentConfig = ((Config4Impl.ConfigDeepCloneContext)param)._cloned;
+ return new Db4objects.Db4o.Internal.Config4Class(parentConfig, _config);
+ }
+
+ public virtual void EnableReplication(bool setting)
+ {
+ throw new NotSupportedException("See documentation");
+ }
+
+ public virtual void GenerateUUIDs(bool setting)
+ {
+ _config.Put(GenerateUuidsKey, TernaryBool.ForBoolean(setting));
+ }
+
+ public virtual void GenerateVersionNumbers(bool setting)
+ {
+ throw new NotSupportedException("See documentation");
+ }
+
+ public virtual IObjectTranslator GetTranslator()
+ {
+ IObjectTranslator translator = (IObjectTranslator)_config.Get(TranslatorKey);
+ if (translator != null)
+ {
+ return translator;
+ }
+ string translatorName = _config.GetAsString(TranslatorNameKey);
+ if (translatorName == null)
+ {
+ return null;
+ }
+ try
+ {
+ translator = NewTranslatorFromReflector(translatorName);
+ }
+ catch (Exception)
+ {
+ try
+ {
+ translator = NewTranslatorFromPlatform(translatorName);
+ }
+ catch (Exception e)
+ {
+ throw new Db4oException(e);
+ }
+ }
+ Translate(translator);
+ return translator;
+ }
+
+ ///
+ ///
+ private IObjectTranslator NewTranslatorFromPlatform(string translatorName)
+ {
+ return (IObjectTranslator)System.Activator.CreateInstance(ReflectPlatform.ForName
+ (translatorName));
+ }
+
+ private IObjectTranslator NewTranslatorFromReflector(string translatorName)
+ {
+ return (IObjectTranslator)Config().Reflector().ForName(translatorName).NewInstance
+ ();
+ }
+
+ public virtual void Indexed(bool flag)
+ {
+ _config.Put(ClassIndexedKey, flag);
+ }
+
+ public virtual bool Indexed()
+ {
+ return _config.GetAsBoolean(ClassIndexedKey);
+ }
+
+ public virtual void MaximumActivationDepth(int depth)
+ {
+ _config.Put(MaximumActivationDepthKey, depth);
+ }
+
+ internal virtual int MaximumActivationDepth()
+ {
+ return _config.GetAsInt(MaximumActivationDepthKey);
+ }
+
+ public virtual void MinimumActivationDepth(int depth)
+ {
+ _config.Put(MinimumActivationDepthKey, depth);
+ }
+
+ public virtual int MinimumActivationDepth()
+ {
+ return _config.GetAsInt(MinimumActivationDepthKey);
+ }
+
+ public virtual TernaryBool CallConstructor()
+ {
+ if (_config.Get(TranslatorKey) != null)
+ {
+ return TernaryBool.Yes;
+ }
+ return _config.GetAsTernaryBool(CallConstructorKey);
+ }
+
+ internal virtual Hashtable4 ExceptionalFieldsOrNull()
+ {
+ return (Hashtable4)_config.Get(ExceptionalFieldsKey);
+ }
+
+ private Hashtable4 ExceptionalFields()
+ {
+ Hashtable4 exceptionalFieldsCollection = ExceptionalFieldsOrNull();
+ if (exceptionalFieldsCollection == null)
+ {
+ exceptionalFieldsCollection = new Hashtable4(16);
+ _config.Put(ExceptionalFieldsKey, exceptionalFieldsCollection);
+ }
+ return exceptionalFieldsCollection;
+ }
+
+ public virtual IObjectField ObjectField(string fieldName)
+ {
+ Hashtable4 exceptionalFieldsCollection = ExceptionalFields();
+ Config4Field c4f = (Config4Field)exceptionalFieldsCollection.Get(fieldName);
+ if (c4f == null)
+ {
+ c4f = new Config4Field(this, fieldName);
+ exceptionalFieldsCollection.Put(fieldName, c4f);
+ }
+ return c4f;
+ }
+
+ public virtual void PersistStaticFieldValues()
+ {
+ _config.Put(PersistStaticFieldValuesKey, true);
+ }
+
+ public virtual void Rename(string newName)
+ {
+ Config().Rename(Renames.ForClass(GetName(), newName));
+ SetName(newName);
+ }
+
+ public virtual void StoreTransientFields(bool flag)
+ {
+ _config.Put(StoreTransientFieldsKey, flag);
+ }
+
+ public virtual void Translate(IObjectTranslator translator)
+ {
+ if (translator == null)
+ {
+ _config.Put(TranslatorNameKey, null);
+ }
+ _config.Put(TranslatorKey, translator);
+ }
+
+ internal virtual void TranslateOnDemand(string a_translatorName)
+ {
+ _config.Put(TranslatorNameKey, a_translatorName);
+ }
+
+ public virtual void UpdateDepth(int depth)
+ {
+ if (depth < 0)
+ {
+ throw new ArgumentException("update depth must not be negative");
+ }
+ _config.Put(UpdateDepthKey, depth);
+ }
+
+ internal virtual Config4Impl Config()
+ {
+ return _configImpl;
+ }
+
+ internal virtual TernaryBool GenerateUUIDs()
+ {
+ return (TernaryBool)_config.Get(GenerateUuidsKey);
+ }
+
+ internal virtual TernaryBool GenerateVersionNumbers()
+ {
+ return TernaryBool.No;
+ }
+
+ internal virtual void MaintainMetaClass(bool flag)
+ {
+ _config.Put(MaintainMetaclassKey, flag);
+ }
+
+ internal virtual bool StaticFieldValuesArePersisted()
+ {
+ return _config.GetAsBoolean(PersistStaticFieldValuesKey);
+ }
+
+ public virtual IObjectAttribute QueryAttributeProvider()
+ {
+ return (IObjectAttribute)_config.Get(QueryAttributeProviderKey);
+ }
+
+ public virtual bool StoreTransientFields()
+ {
+ return _config.GetAsBoolean(StoreTransientFieldsKey);
+ }
+
+ internal virtual int UpdateDepth()
+ {
+ return _config.GetAsInt(UpdateDepthKey);
+ }
+
+ internal virtual string WriteAs()
+ {
+ return _config.GetAsString(WriteAsKey);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,100 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal
+{
+ public class Config4Field : Config4Abstract, IObjectField, IDeepClone
+ {
+ private readonly Config4Class _configClass;
+
+ private bool _used;
+
+ private static readonly KeySpec IndexedKey = new KeySpec(TernaryBool.Unspecified);
+
+ protected Config4Field(Config4Class a_class, KeySpecHashtable4 config) : base(config
+ )
+ {
+ _configClass = a_class;
+ }
+
+ internal Config4Field(Config4Class a_class, string a_name)
+ {
+ _configClass = a_class;
+ SetName(a_name);
+ }
+
+ private Config4Class ClassConfig()
+ {
+ return _configClass;
+ }
+
+ internal override string ClassName()
+ {
+ return ClassConfig().GetName();
+ }
+
+ public virtual object DeepClone(object param)
+ {
+ return new Db4objects.Db4o.Internal.Config4Field((Config4Class)param, _config);
+ }
+
+ public virtual void Rename(string newName)
+ {
+ ClassConfig().Config().Rename(Renames.ForField(ClassName(), GetName(), newName));
+ SetName(newName);
+ }
+
+ public virtual void Indexed(bool flag)
+ {
+ PutThreeValued(IndexedKey, flag);
+ }
+
+ public virtual void InitOnUp(Transaction systemTrans, FieldMetadata fieldMetadata
+ )
+ {
+ ObjectContainerBase anyStream = systemTrans.Container();
+ if (!anyStream.MaintainsIndices())
+ {
+ return;
+ }
+ if (!fieldMetadata.SupportsIndex())
+ {
+ Indexed(false);
+ }
+ TernaryBool indexedFlag = _config.GetAsTernaryBool(IndexedKey);
+ if (indexedFlag.DefiniteNo())
+ {
+ fieldMetadata.DropIndex((LocalTransaction)systemTrans);
+ return;
+ }
+ if (UseExistingIndex(systemTrans, fieldMetadata))
+ {
+ return;
+ }
+ if (!indexedFlag.DefiniteYes())
+ {
+ return;
+ }
+ fieldMetadata.CreateIndex();
+ }
+
+ private bool UseExistingIndex(Transaction systemTrans, FieldMetadata fieldMetadata
+ )
+ {
+ return fieldMetadata.GetIndex(systemTrans) != null;
+ }
+
+ public virtual void Used(bool flag)
+ {
+ _used = flag;
+ }
+
+ public virtual bool Used()
+ {
+ return _used;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,1450 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using System.IO;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Config.Encoding;
+using Db4objects.Db4o.Diagnostic;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.IO;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Activation;
+using Db4objects.Db4o.Internal.Config;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Internal.Freespace;
+using Db4objects.Db4o.Internal.Handlers;
+using Db4objects.Db4o.Internal.Ids;
+using Db4objects.Db4o.Internal.References;
+using Db4objects.Db4o.Messaging;
+using Db4objects.Db4o.Reflect;
+using Db4objects.Db4o.Reflect.Core;
+using Db4objects.Db4o.Reflect.Generic;
+using Db4objects.Db4o.Typehandlers;
+using Sharpen;
+
+namespace Db4objects.Db4o.Internal
+{
+ /// Configuration template for creating new db4o files
+ ///
+ public sealed partial class Config4Impl : IConfiguration, IDeepClone, IMessageSender
+ , IFreespaceConfiguration, IQueryConfiguration, IClientServerConfiguration
+ {
+ private KeySpecHashtable4 _config = new KeySpecHashtable4(50);
+
+ private static readonly KeySpec ActivationDepthKey = new KeySpec(5);
+
+ private static readonly KeySpec ActivationDepthProviderKey = new KeySpec(LegacyActivationDepthProvider
+ .Instance);
+
+ private static readonly KeySpec UpdateDepthProviderKey = new KeySpec(new LegacyUpdateDepthProvider
+ ());
+
+ private static readonly KeySpec AllowVersionUpdatesKey = new KeySpec(false);
+
+ private static readonly KeySpec AsynchronousSyncKey = new KeySpec(false);
+
+ private static readonly KeySpec AutomaticShutdownKey = new KeySpec(true);
+
+ private static readonly KeySpec BlocksizeKey = new KeySpec((byte)1);
+
+ private static readonly KeySpec BlobPathKey = new KeySpec(null);
+
+ private static readonly KeySpec BtreeNodeSizeKey = new KeySpec(201);
+
+ private static readonly KeySpec CallbacksKey = new KeySpec(CallBackMode.All);
+
+ private static readonly KeySpec CallConstructorsKey = new KeySpec(TernaryBool.Unspecified
+ );
+
+ private static readonly KeySpec ConfigurationItemsKey = new KeySpec(null);
+
+ private static readonly KeySpec ConfiguredReflectorKey = new KeySpec(null);
+
+ private static readonly KeySpec ClassActivationDepthConfigurableKey = new KeySpec
+ (true);
+
+ private static readonly KeySpec ClassloaderKey = new KeySpec(null);
+
+ private sealed class _IDeferred_75 : KeySpec.IDeferred
+ {
+ public _IDeferred_75()
+ {
+ }
+
+ // TODO: consider setting default to 8, it's more efficient with freespace.
+ public object Evaluate()
+ {
+ return Config4Impl.DefaultClientServerFactory();
+ }
+ }
+
+ private static readonly KeySpec ClientServerFactoryKey = new KeySpec(new _IDeferred_75
+ ());
+
+ private static readonly KeySpec DatabaseGrowthSizeKey = new KeySpec(0);
+
+ private static readonly KeySpec DetectSchemaChangesKey = new KeySpec(true);
+
+ private sealed class _IDeferred_85 : KeySpec.IDeferred
+ {
+ public _IDeferred_85()
+ {
+ }
+
+ public object Evaluate()
+ {
+ return new Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor();
+ }
+ }
+
+ private static readonly KeySpec DiagnosticKey = new KeySpec(new _IDeferred_85());
+
+ private static readonly KeySpec DisableCommitRecoveryKey = new KeySpec(false);
+
+ private static readonly KeySpec DiscardFreespaceKey = new KeySpec(0);
+
+ private static readonly IStringEncoding DefaultStringEncoding = StringEncodings.Unicode
+ ();
+
+ private static readonly KeySpec StringEncodingKey = new KeySpec(DefaultStringEncoding
+ );
+
+ private static readonly KeySpec EncodingKey = new KeySpec(BuiltInStringEncoding.EncodingByteForEncoding
+ (DefaultStringEncoding));
+
+ private static readonly KeySpec EncryptKey = new KeySpec(false);
+
+ private sealed class _IDeferred_103 : KeySpec.IDeferred
+ {
+ public _IDeferred_103()
+ {
+ }
+
+ public object Evaluate()
+ {
+ return new ArrayList();
+ }
+ }
+
+ private static readonly KeySpec EnvironmentContributionsKey = new KeySpec(new _IDeferred_103
+ ());
+
+ private static readonly KeySpec ExceptionalClassesKey = new KeySpec(null);
+
+ private static readonly KeySpec ExceptionsOnNotStorableKey = new KeySpec(true);
+
+ private static readonly KeySpec FileBasedTransactionLogKey = new KeySpec(false);
+
+ private static readonly KeySpec FreespaceFillerKey = new KeySpec(null);
+
+ private static readonly KeySpec FreespaceSystemKey = new KeySpec(AbstractFreespaceManager
+ .FmDefault);
+
+ private static readonly KeySpec GenerateUuidsKey = new KeySpec(ConfigScope.Individually
+ );
+
+ private static readonly KeySpec GenerateCommitTimestampsKey = new KeySpec(TernaryBool
+ .Unspecified);
+
+ private static readonly KeySpec IdSystemKey = new KeySpec(StandardIdSystemFactory
+ .Default);
+
+ private static readonly KeySpec IdSystemCustomFactoryKey = new KeySpec(null);
+
+ private static readonly KeySpec QueryEvaluationModeKey = new KeySpec(QueryEvaluationMode
+ .Immediate);
+
+ private static readonly KeySpec LockFileKey = new KeySpec(true);
+
+ private static readonly KeySpec MessageRecipientKey = new KeySpec(null);
+
+ private static readonly KeySpec OptimizeNqKey = new KeySpec(true);
+
+ private static readonly KeySpec OutstreamKey = new KeySpec(null);
+
+ private static readonly KeySpec PasswordKey = new KeySpec((string)null);
+
+ private static readonly KeySpec ClientQueryResultIteratorFactoryKey = new KeySpec
+ (null);
+
+ private static readonly KeySpec PrefetchIdCountKey = new KeySpec(10);
+
+ private static readonly KeySpec PrefetchObjectCountKey = new KeySpec(10);
+
+ private static readonly KeySpec PrefetchDepthKey = new KeySpec(0);
+
+ public const int PrefetchSlotCacheSizeFactor = 10;
+
+ private const int MaximumPrefetchSlotCacheSize = 10000;
+
+ private static readonly KeySpec PrefetchSlotCacheSizeKey = new KeySpec(0);
+
+ private sealed class _IDeferred_155 : KeySpec.IDeferred
+ {
+ public _IDeferred_155()
+ {
+ }
+
+ // for playing with different strategies of prefetching
+ // object
+ public object Evaluate()
+ {
+ return new Hashtable4(16);
+ }
+ }
+
+ private static readonly KeySpec ReadAsKey = new KeySpec(new _IDeferred_155());
+
+ private static readonly KeySpec RecoveryModeKey = new KeySpec(false);
+
+ private static readonly KeySpec ReflectorKey = new KeySpec(null);
+
+ private static readonly KeySpec RenameKey = new KeySpec(null);
+
+ private static readonly KeySpec ReservedStorageSpaceKey = new KeySpec(0);
+
+ private static readonly KeySpec SingleThreadedClientKey = new KeySpec(false);
+
+ private static readonly KeySpec TestConstructorsKey = new KeySpec(true);
+
+ private static readonly KeySpec TimeoutClientSocketKey = new KeySpec(Const4.ClientSocketTimeout
+ );
+
+ private static readonly KeySpec TimeoutServerSocketKey = new KeySpec(Const4.ServerSocketTimeout
+ );
+
+ private static readonly KeySpec UpdateDepthKey = new KeySpec(1);
+
+ private static readonly KeySpec WeakReferenceCollectionIntervalKey = new KeySpec(
+ 1000);
+
+ private static readonly KeySpec WeakReferencesKey = new KeySpec(true);
+
+ private static readonly KeySpec StorageFactoryKey = new KeySpec(new CachingStorage
+ (new FileStorage()));
+
+ private static readonly KeySpec AliasesKey = new KeySpec(null);
+
+ private static readonly KeySpec BatchMessagesKey = new KeySpec(true);
+
+ private static readonly KeySpec MaxBatchQueueSizeKey = new KeySpec(int.MaxValue);
+
+ private static readonly KeySpec TaintedKey = new KeySpec(false);
+
+ private sealed class _IReferenceSystemFactory_193 : IReferenceSystemFactory
+ {
+ public _IReferenceSystemFactory_193()
+ {
+ }
+
+ public IReferenceSystem NewReferenceSystem(IInternalObjectContainer container)
+ {
+ return new TransactionalReferenceSystem();
+ }
+ }
+
+ private static readonly KeySpec ReferenceSystemFactoryKey = new KeySpec(new _IReferenceSystemFactory_193
+ ());
+
+ private sealed class _INameProvider_199 : INameProvider
+ {
+ public _INameProvider_199()
+ {
+ }
+
+ public string Name(IObjectContainer db)
+ {
+ return null;
+ }
+ }
+
+ private static readonly KeySpec NameProviderKey = new KeySpec(new _INameProvider_199
+ ());
+
+ private static readonly KeySpec MaxStackDepthKey = new KeySpec("Dalvik".Equals(Runtime
+ .GetProperty("java.vm.name")) ? 2 : Const4.DefaultMaxStackDepth);
+
+ private ObjectContainerBase _container;
+
+ private bool _internStrings;
+
+ private int _messageLevel;
+
+ private bool _readOnly;
+
+ private Collection4 _registeredTypeHandlers;
+
+ private System.EventHandler _prefetchSettingsChanged;
+
+ private bool _prefetchSlotCacheSizeModifiedExternally;
+
+ // TODO find a better place to do this, and use AndroidConfiguration instead.
+ // is null in the global configuration until deepClone is called
+ // The following are very frequently being asked for, so they show up in the profiler.
+ // Let's keep them out of the Hashtable.
+ public int ActivationDepth()
+ {
+ return _config.GetAsInt(ActivationDepthKey);
+ }
+
+ // FIXME: circular cs dependancy. Improve.
+ public void ActivationDepth(int depth)
+ {
+ _config.Put(ActivationDepthKey, depth);
+ }
+
+ public void Add(IConfigurationItem item)
+ {
+ item.Prepare(this);
+ SafeConfigurationItems().Put(item, item);
+ }
+
+ ///
+ /// Returns an iterator for all
+ /// Db4objects.Db4o.Config.IConfigurationItem
+ ///
+ /// instances
+ /// added.
+ ///
+ /// Add(Db4objects.Db4o.Config.IConfigurationItem)
+ ///
+ /// the iterator
+ public IEnumerator ConfigurationItemsIterator()
+ {
+ Hashtable4 items = ConfigurationItems();
+ if (items == null)
+ {
+ return Iterators.EmptyIterator;
+ }
+ return items.Keys();
+ }
+
+ private Hashtable4 SafeConfigurationItems()
+ {
+ Hashtable4 items = ConfigurationItems();
+ if (items == null)
+ {
+ items = new Hashtable4(16);
+ _config.Put(ConfigurationItemsKey, items);
+ }
+ return items;
+ }
+
+ public void AllowVersionUpdates(bool flag)
+ {
+ _config.Put(AllowVersionUpdatesKey, flag);
+ }
+
+ private Hashtable4 ConfigurationItems()
+ {
+ return (Hashtable4)_config.Get(ConfigurationItemsKey);
+ }
+
+ public void ApplyConfigurationItems(IInternalObjectContainer container)
+ {
+ Hashtable4 items = ConfigurationItems();
+ if (items == null)
+ {
+ return;
+ }
+ IEnumerator i = items.Iterator();
+ while (i.MoveNext())
+ {
+ IEntry4 entry = (IEntry4)i.Current;
+ IConfigurationItem item = (IConfigurationItem)entry.Value();
+ item.Apply(container);
+ }
+ }
+
+ public void AutomaticShutDown(bool flag)
+ {
+ _config.Put(AutomaticShutdownKey, flag);
+ }
+
+ public void BlockSize(int bytes)
+ {
+ if (bytes < 1 || bytes > 127)
+ {
+ throw new ArgumentException();
+ }
+ GlobalSettingOnly();
+ _config.Put(BlocksizeKey, (byte)bytes);
+ }
+
+ public void BTreeNodeSize(int size)
+ {
+ _config.Put(BtreeNodeSizeKey, size);
+ }
+
+ public void BTreeCacheHeight(int height)
+ {
+ }
+
+ public void Callbacks(bool turnOn)
+ {
+ CallbackMode(turnOn ? CallBackMode.All : CallBackMode.None);
+ }
+
+ public void CallbackMode(CallBackMode mode)
+ {
+ _config.Put(CallbacksKey, mode);
+ }
+
+ public void CallConstructors(bool flag)
+ {
+ _config.Put(CallConstructorsKey, TernaryBool.ForBoolean(flag));
+ }
+
+ public void ClassActivationDepthConfigurable(bool turnOn)
+ {
+ _config.Put(ClassActivationDepthConfigurableKey, turnOn);
+ }
+
+ public Config4Class ConfigClass(string className)
+ {
+ Config4Class config = (Config4Class)ExceptionalClasses().Get(className);
+ return config;
+ }
+
+ private bool IsIgnoredClass(string className)
+ {
+ Type[] ignore = IgnoredClasses();
+ for (int i = 0; i < ignore.Length; i++)
+ {
+ if (ignore[i].FullName.Equals(className))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Type[] IgnoredClasses()
+ {
+ return new Type[] { typeof(StaticClass), typeof(StaticField) };
+ }
+
+ public object DeepClone(object param)
+ {
+ Config4Impl ret = new Config4Impl();
+ Config4Impl.ConfigDeepCloneContext context = new Config4Impl.ConfigDeepCloneContext
+ (this, ret);
+ ret._config = (KeySpecHashtable4)_config.DeepClone(context);
+ ret._internStrings = _internStrings;
+ ret._messageLevel = _messageLevel;
+ ret._readOnly = _readOnly;
+ if (_registeredTypeHandlers != null)
+ {
+ ret._registeredTypeHandlers = (Collection4)_registeredTypeHandlers.DeepClone(context
+ );
+ }
+ return ret;
+ }
+
+ public void Container(ObjectContainerBase container)
+ {
+ _container = container;
+ }
+
+ public void DatabaseGrowthSize(int bytes)
+ {
+ _config.Put(DatabaseGrowthSizeKey, bytes);
+ }
+
+ public int DatabaseGrowthSize()
+ {
+ return _config.GetAsInt(DatabaseGrowthSizeKey);
+ }
+
+ public void DetectSchemaChanges(bool flag)
+ {
+ _config.Put(DetectSchemaChangesKey, flag);
+ }
+
+ public void DisableCommitRecovery()
+ {
+ _config.Put(DisableCommitRecoveryKey, true);
+ }
+
+ public void DiscardSmallerThan(int byteCount)
+ {
+ if (byteCount < 0)
+ {
+ throw new ArgumentException();
+ }
+ _config.Put(DiscardFreespaceKey, byteCount);
+ }
+
+ [System.ObsoleteAttribute]
+ public void Encrypt(bool flag)
+ {
+ GlobalSettingOnly();
+ _config.Put(EncryptKey, flag);
+ }
+
+ internal void OldEncryptionOff()
+ {
+ _config.Put(EncryptKey, false);
+ }
+
+ ///
+ internal void EnsureDirExists(string path)
+ {
+ Sharpen.IO.File file = new Sharpen.IO.File(path);
+ if (!file.Exists())
+ {
+ file.Mkdirs();
+ }
+ if (file.Exists() && file.IsDirectory())
+ {
+ }
+ else
+ {
+ throw new IOException(Db4objects.Db4o.Internal.Messages.Get(37, path));
+ }
+ }
+
+ internal TextWriter ErrStream()
+ {
+ TextWriter outStream = OutStreamOrNull();
+ return outStream == null ? Sharpen.Runtime.Err : outStream;
+ }
+
+ public void ExceptionsOnNotStorable(bool flag)
+ {
+ _config.Put(ExceptionsOnNotStorableKey, flag);
+ }
+
+ public IFreespaceConfiguration Freespace()
+ {
+ return this;
+ }
+
+ public void FreespaceFiller(IFreespaceFiller freespaceFiller)
+ {
+ _config.Put(FreespaceFillerKey, freespaceFiller);
+ }
+
+ public IFreespaceFiller FreespaceFiller()
+ {
+ return (IFreespaceFiller)_config.Get(FreespaceFillerKey);
+ }
+
+ public void GenerateUUIDs(ConfigScope scope)
+ {
+ _config.Put(GenerateUuidsKey, scope);
+ }
+
+ public void GenerateVersionNumbers(ConfigScope scope)
+ {
+ if (scope == ConfigScope.Individually)
+ {
+ throw new NotSupportedException();
+ }
+ GenerateCommitTimestamps(scope == ConfigScope.Globally);
+ }
+
+ public void GenerateCommitTimestamps(bool flag)
+ {
+ _config.Put(GenerateCommitTimestampsKey, TernaryBool.ForBoolean(flag));
+ }
+
+ public IMessageSender GetMessageSender()
+ {
+ return this;
+ }
+
+ private void GlobalSettingOnly()
+ {
+ if (_container != null)
+ {
+ throw new GlobalOnlyConfigException();
+ }
+ }
+
+ public void InternStrings(bool doIntern)
+ {
+ _internStrings = doIntern;
+ }
+
+ public void Io(IoAdapter adapter)
+ {
+ GlobalSettingOnly();
+ Storage = new IoAdapterStorage(adapter);
+ }
+
+ public void LockDatabaseFile(bool flag)
+ {
+ _config.Put(LockFileKey, flag);
+ }
+
+ public void MarkTransient(string marker)
+ {
+ Platform4.MarkTransient(marker);
+ }
+
+ public void MessageLevel(int level)
+ {
+ _messageLevel = level;
+ if (OutStream() == null)
+ {
+ SetOut(Sharpen.Runtime.Out);
+ }
+ }
+
+ public void OptimizeNativeQueries(bool optimizeNQ)
+ {
+ _config.Put(OptimizeNqKey, optimizeNQ);
+ }
+
+ public bool OptimizeNativeQueries()
+ {
+ return _config.GetAsBoolean(OptimizeNqKey);
+ }
+
+ public IObjectClass ObjectClass(object clazz)
+ {
+ string className = null;
+ if (clazz is string)
+ {
+ className = (string)clazz;
+ }
+ else
+ {
+ IReflectClass claxx = ReflectorFor(clazz);
+ if (claxx == null)
+ {
+ return null;
+ }
+ className = claxx.GetName();
+ }
+ if (ReflectPlatform.FullyQualifiedName(typeof(object)).Equals(className))
+ {
+ throw new ArgumentException("Configuration of the Object class is not supported."
+ );
+ }
+ Hashtable4 xClasses = ExceptionalClasses();
+ Config4Class c4c = (Config4Class)xClasses.Get(className);
+ if (c4c == null)
+ {
+ c4c = new Config4Class(this, className);
+ xClasses.Put(className, c4c);
+ }
+ return c4c;
+ }
+
+ private TextWriter OutStreamOrNull()
+ {
+ return (TextWriter)_config.Get(OutstreamKey);
+ }
+
+ public TextWriter OutStream()
+ {
+ TextWriter outStream = OutStreamOrNull();
+ return outStream == null ? Sharpen.Runtime.Out : outStream;
+ }
+
+ [System.ObsoleteAttribute]
+ public void Password(string pw)
+ {
+ GlobalSettingOnly();
+ _config.Put(PasswordKey, pw);
+ }
+
+ public void ReadOnly(bool flag)
+ {
+ _readOnly = flag;
+ }
+
+ public GenericReflector Reflector()
+ {
+ GenericReflector reflector = (GenericReflector)_config.Get(ReflectorKey);
+ if (reflector == null)
+ {
+ IReflector configuredReflector = (IReflector)_config.Get(ConfiguredReflectorKey);
+ if (configuredReflector == null)
+ {
+ configuredReflector = Platform4.CreateReflector(ClassLoader());
+ _config.Put(ConfiguredReflectorKey, configuredReflector);
+ }
+ reflector = new GenericReflector(configuredReflector);
+ _config.Put(ReflectorKey, reflector);
+ }
+ // TODO: transaction assignment has been moved to YapStreamBase#initialize1().
+ // implement better, more generic solution as described in COR-288
+ // if(! reflector.hasTransaction() && i_stream != null){
+ // reflector.setTransaction(i_stream.getSystemTransaction());
+ // }
+ return reflector;
+ }
+
+ public void ReflectWith(IReflector reflect)
+ {
+ if (_container != null)
+ {
+ Exceptions4.ThrowRuntimeException(46);
+ }
+ // see readable message for code in Messages.java
+ if (reflect == null)
+ {
+ throw new ArgumentNullException();
+ }
+ _config.Put(ConfiguredReflectorKey, reflect);
+ _config.Put(ReflectorKey, null);
+ }
+
+ public void RefreshClasses()
+ {
+ throw new NotImplementedException();
+ }
+
+ internal void Rename(Db4objects.Db4o.Rename a_rename)
+ {
+ Collection4 renameCollection = Rename();
+ if (renameCollection == null)
+ {
+ renameCollection = new Collection4();
+ _config.Put(RenameKey, renameCollection);
+ }
+ renameCollection.Add(a_rename);
+ }
+
+ ///
+ public void ReserveStorageSpace(long byteCount)
+ {
+ int reservedStorageSpace = (int)byteCount;
+ if (reservedStorageSpace < 0)
+ {
+ reservedStorageSpace = 0;
+ }
+ _config.Put(ReservedStorageSpaceKey, reservedStorageSpace);
+ if (_container != null)
+ {
+ _container.Reserve(reservedStorageSpace);
+ }
+ }
+
+ /// The ConfigImpl also is our messageSender
+ public void Send(object obj)
+ {
+ if (_container != null)
+ {
+ _container.Send(obj);
+ }
+ }
+
+ ///
+ public void SetBlobPath(string path)
+ {
+ EnsureDirExists(path);
+ _config.Put(BlobPathKey, path);
+ }
+
+ public void SetMessageRecipient(IMessageRecipient messageRecipient)
+ {
+ _config.Put(MessageRecipientKey, messageRecipient);
+ }
+
+ [System.ObsoleteAttribute]
+ public void SetOut(TextWriter outStream)
+ {
+ _config.Put(OutstreamKey, outStream);
+ if (_container != null)
+ {
+ _container.LogMsg(19, Db4oFactory.Version());
+ }
+ else
+ {
+ Db4objects.Db4o.Internal.Messages.LogMsg(this, 19, Db4oFactory.Version());
+ }
+ }
+
+ public void SingleThreadedClient(bool flag)
+ {
+ _config.Put(SingleThreadedClientKey, flag);
+ }
+
+ public IStringEncoding StringEncoding()
+ {
+ return (IStringEncoding)_config.Get(StringEncodingKey);
+ }
+
+ public void StringEncoding(IStringEncoding encoding)
+ {
+ _config.Put(StringEncodingKey, encoding);
+ _config.Put(EncodingKey, BuiltInStringEncoding.EncodingByteForEncoding(encoding));
+ }
+
+ public void TestConstructors(bool flag)
+ {
+ _config.Put(TestConstructorsKey, flag);
+ }
+
+ public void TimeoutClientSocket(int milliseconds)
+ {
+ _config.Put(TimeoutClientSocketKey, milliseconds);
+ }
+
+ public void TimeoutServerSocket(int milliseconds)
+ {
+ _config.Put(TimeoutServerSocketKey, milliseconds);
+ }
+
+ public void UpdateDepth(int depth)
+ {
+ if (depth < 0)
+ {
+ throw new ArgumentException("update depth must not be negative");
+ }
+ Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor dp = DiagnosticProcessor(
+ );
+ if (dp.Enabled())
+ {
+ dp.CheckUpdateDepth(depth);
+ }
+ _config.Put(UpdateDepthKey, depth);
+ }
+
+ public void UseBTreeSystem()
+ {
+ _config.Put(FreespaceSystemKey, AbstractFreespaceManager.FmBtree);
+ }
+
+ public void UseRamSystem()
+ {
+ _config.Put(FreespaceSystemKey, AbstractFreespaceManager.FmRam);
+ }
+
+ [System.ObsoleteAttribute]
+ public void UseIndexSystem()
+ {
+ throw new NotSupportedException();
+ }
+
+ public void WeakReferenceCollectionInterval(int milliseconds)
+ {
+ _config.Put(WeakReferenceCollectionIntervalKey, milliseconds);
+ }
+
+ public void WeakReferences(bool flag)
+ {
+ _config.Put(WeakReferencesKey, flag);
+ }
+
+ private Collection4 Aliases()
+ {
+ Collection4 aliasesCollection = (Collection4)_config.Get(AliasesKey);
+ if (null == aliasesCollection)
+ {
+ aliasesCollection = new Collection4();
+ _config.Put(AliasesKey, aliasesCollection);
+ }
+ return aliasesCollection;
+ }
+
+ public void AddAlias(IAlias alias)
+ {
+ if (null == alias)
+ {
+ throw new ArgumentNullException("alias");
+ }
+ Aliases().Add(alias);
+ }
+
+ public void RemoveAlias(IAlias alias)
+ {
+ if (null == alias)
+ {
+ throw new ArgumentNullException("alias");
+ }
+ Aliases().Remove(alias);
+ }
+
+ public string ResolveAliasRuntimeName(string runtimeType)
+ {
+ Collection4 configuredAliases = Aliases();
+ if (null == configuredAliases)
+ {
+ return runtimeType;
+ }
+ IEnumerator i = configuredAliases.GetEnumerator();
+ while (i.MoveNext())
+ {
+ string resolved = ((IAlias)i.Current).ResolveRuntimeName(runtimeType);
+ if (null != resolved)
+ {
+ return resolved;
+ }
+ }
+ return runtimeType;
+ }
+
+ public string ResolveAliasStoredName(string storedType)
+ {
+ Collection4 configuredAliases = Aliases();
+ if (null == configuredAliases)
+ {
+ return storedType;
+ }
+ IEnumerator i = configuredAliases.GetEnumerator();
+ while (i.MoveNext())
+ {
+ string resolved = ((IAlias)i.Current).ResolveStoredName(storedType);
+ if (null != resolved)
+ {
+ return resolved;
+ }
+ }
+ return storedType;
+ }
+
+ internal IReflectClass ReflectorFor(object clazz)
+ {
+ return ReflectorUtils.ReflectClassFor(Reflector(), clazz);
+ }
+
+ public bool AllowVersionUpdates()
+ {
+ return _config.GetAsBoolean(AllowVersionUpdatesKey);
+ }
+
+ public bool AutomaticShutDown()
+ {
+ return _config.GetAsBoolean(AutomaticShutdownKey);
+ }
+
+ public byte BlockSize()
+ {
+ return _config.GetAsByte(BlocksizeKey);
+ }
+
+ public int BTreeNodeSize()
+ {
+ return _config.GetAsInt(BtreeNodeSizeKey);
+ }
+
+ public string BlobPath()
+ {
+ return _config.GetAsString(BlobPathKey);
+ }
+
+ public CallBackMode CallbackMode()
+ {
+ return (CallBackMode)_config.Get(CallbacksKey);
+ }
+
+ public TernaryBool CallConstructors()
+ {
+ return _config.GetAsTernaryBool(CallConstructorsKey);
+ }
+
+ internal bool ClassActivationDepthConfigurable()
+ {
+ return _config.GetAsBoolean(ClassActivationDepthConfigurableKey);
+ }
+
+ internal object ClassLoader()
+ {
+ return _config.Get(ClassloaderKey);
+ }
+
+ public bool DetectSchemaChanges()
+ {
+ return _config.GetAsBoolean(DetectSchemaChangesKey);
+ }
+
+ public bool CommitRecoveryDisabled()
+ {
+ return _config.GetAsBoolean(DisableCommitRecoveryKey);
+ }
+
+ public IDiagnosticConfiguration Diagnostic()
+ {
+ return (IDiagnosticConfiguration)_config.Get(DiagnosticKey);
+ }
+
+ public Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor DiagnosticProcessor
+ ()
+ {
+ return (Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor)_config.Get(DiagnosticKey
+ );
+ }
+
+ public int DiscardFreeSpace()
+ {
+ return _config.GetAsInt(DiscardFreespaceKey);
+ }
+
+ internal byte Encoding()
+ {
+ return _config.GetAsByte(EncodingKey);
+ }
+
+ internal bool Encrypt()
+ {
+ return _config.GetAsBoolean(EncryptKey);
+ }
+
+ public Hashtable4 ExceptionalClasses()
+ {
+ Hashtable4 exceptionalClasses = (Hashtable4)_config.Get(ExceptionalClassesKey);
+ if (exceptionalClasses == null)
+ {
+ exceptionalClasses = new Hashtable4(16);
+ _config.Put(ExceptionalClassesKey, exceptionalClasses);
+ }
+ return exceptionalClasses;
+ }
+
+ public bool ExceptionsOnNotStorable()
+ {
+ return _config.GetAsBoolean(ExceptionsOnNotStorableKey);
+ }
+
+ internal byte FreespaceSystem()
+ {
+ return _config.GetAsByte(FreespaceSystemKey);
+ }
+
+ public ConfigScope GenerateUUIDs()
+ {
+ return (ConfigScope)_config.Get(GenerateUuidsKey);
+ }
+
+ public TernaryBool GenerateCommitTimestamps()
+ {
+ return (TernaryBool)_config.Get(GenerateCommitTimestampsKey);
+ }
+
+ public bool InternStrings()
+ {
+ return _internStrings;
+ }
+
+ public bool LockFile()
+ {
+ return _config.GetAsBoolean(LockFileKey);
+ }
+
+ public int MessageLevel()
+ {
+ return _messageLevel;
+ }
+
+ public IMessageRecipient MessageRecipient()
+ {
+ return (IMessageRecipient)_config.Get(MessageRecipientKey);
+ }
+
+ internal bool OptimizeNQ()
+ {
+ return _config.GetAsBoolean(OptimizeNqKey);
+ }
+
+ internal string Password()
+ {
+ return _config.GetAsString(PasswordKey);
+ }
+
+ public void PrefetchIDCount(int prefetchIDCount)
+ {
+ _config.Put(PrefetchIdCountKey, prefetchIDCount);
+ }
+
+ public int PrefetchIDCount()
+ {
+ return _config.GetAsInt(PrefetchIdCountKey);
+ }
+
+ public void PrefetchObjectCount(int prefetchObjectCount)
+ {
+ _config.Put(PrefetchObjectCountKey, prefetchObjectCount);
+ EnsurePrefetchSlotCacheSize();
+ }
+
+ public int PrefetchObjectCount()
+ {
+ return _config.GetAsInt(PrefetchObjectCountKey);
+ }
+
+ public Hashtable4 ReadAs()
+ {
+ return (Hashtable4)_config.Get(ReadAsKey);
+ }
+
+ public bool IsReadOnly()
+ {
+ return _readOnly;
+ }
+
+ public void RecoveryMode(bool flag)
+ {
+ _config.Put(RecoveryModeKey, flag);
+ }
+
+ public bool RecoveryMode()
+ {
+ return _config.GetAsBoolean(RecoveryModeKey);
+ }
+
+ internal Collection4 Rename()
+ {
+ return (Collection4)_config.Get(RenameKey);
+ }
+
+ public int ReservedStorageSpace()
+ {
+ return _config.GetAsInt(ReservedStorageSpaceKey);
+ }
+
+ public bool SingleThreadedClient()
+ {
+ return _config.GetAsBoolean(SingleThreadedClientKey);
+ }
+
+ public bool TestConstructors()
+ {
+ return _config.GetAsBoolean(TestConstructorsKey);
+ }
+
+ public int TimeoutClientSocket()
+ {
+ return _config.GetAsInt(TimeoutClientSocketKey);
+ }
+
+ public int TimeoutServerSocket()
+ {
+ return _config.GetAsInt(TimeoutServerSocketKey);
+ }
+
+ public int UpdateDepth()
+ {
+ return _config.GetAsInt(UpdateDepthKey);
+ }
+
+ public int WeakReferenceCollectionInterval()
+ {
+ return _config.GetAsInt(WeakReferenceCollectionIntervalKey);
+ }
+
+ public bool WeakReferences()
+ {
+ return _config.GetAsBoolean(WeakReferencesKey);
+ }
+
+ public IoAdapter Io()
+ {
+ throw new NotImplementedException();
+ }
+
+ public IStorage Storage
+ {
+ get
+ {
+ return (IStorage)_config.Get(StorageFactoryKey);
+ }
+ set
+ {
+ IStorage factory = value;
+ _config.Put(StorageFactoryKey, factory);
+ }
+ }
+
+ public IQueryConfiguration Queries()
+ {
+ return this;
+ }
+
+ public void EvaluationMode(QueryEvaluationMode mode)
+ {
+ _config.Put(QueryEvaluationModeKey, mode);
+ }
+
+ public QueryEvaluationMode EvaluationMode()
+ {
+ return (QueryEvaluationMode)_config.Get(QueryEvaluationModeKey);
+ }
+
+ public void QueryResultIteratorFactory(IQueryResultIteratorFactory factory)
+ {
+ _config.Put(ClientQueryResultIteratorFactoryKey, factory);
+ }
+
+ public IQueryResultIteratorFactory QueryResultIteratorFactory()
+ {
+ return (IQueryResultIteratorFactory)_config.Get(ClientQueryResultIteratorFactoryKey
+ );
+ }
+
+ public IClientServerConfiguration ClientServer()
+ {
+ return this;
+ }
+
+ public void BatchMessages(bool flag)
+ {
+ _config.Put(BatchMessagesKey, flag);
+ }
+
+ public bool BatchMessages()
+ {
+ return _config.GetAsBoolean(BatchMessagesKey);
+ }
+
+ public void MaxBatchQueueSize(int maxSize)
+ {
+ _config.Put(MaxBatchQueueSizeKey, maxSize);
+ }
+
+ public int MaxBatchQueueSize()
+ {
+ return _config.GetAsInt(MaxBatchQueueSizeKey);
+ }
+
+ public void ActivationDepthProvider(IActivationDepthProvider provider)
+ {
+ _config.Put(ActivationDepthProviderKey, provider);
+ }
+
+ public void UpdateDepthProvider(IUpdateDepthProvider provider)
+ {
+ _config.Put(UpdateDepthProviderKey, provider);
+ }
+
+ public IActivationDepthProvider ActivationDepthProvider()
+ {
+ return (IActivationDepthProvider)_config.Get(ActivationDepthProviderKey);
+ }
+
+ public IUpdateDepthProvider UpdateDepthProvider()
+ {
+ return (IUpdateDepthProvider)_config.Get(UpdateDepthProviderKey);
+ }
+
+ public void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4 typeHandler
+ )
+ {
+ if (_registeredTypeHandlers == null)
+ {
+ _registeredTypeHandlers = new Collection4();
+ }
+ _registeredTypeHandlers.Add(new TypeHandlerPredicatePair(predicate, typeHandler));
+ }
+
+ public ITypeHandler4 TypeHandlerForClass(IReflectClass classReflector, byte handlerVersion
+ )
+ {
+ if (_registeredTypeHandlers == null)
+ {
+ return null;
+ }
+ IEnumerator i = _registeredTypeHandlers.GetEnumerator();
+ while (i.MoveNext())
+ {
+ TypeHandlerPredicatePair pair = (TypeHandlerPredicatePair)i.Current;
+ if (pair._predicate.Match(classReflector))
+ {
+ return pair._typeHandler;
+ }
+ }
+ return null;
+ }
+
+ public class ConfigDeepCloneContext
+ {
+ public readonly Config4Impl _orig;
+
+ public readonly Config4Impl _cloned;
+
+ public ConfigDeepCloneContext(Config4Impl orig, Config4Impl cloned)
+ {
+ _orig = orig;
+ _cloned = cloned;
+ }
+ }
+
+ public void Factory(ILegacyClientServerFactory factory)
+ {
+ _config.Put(ClientServerFactoryKey, factory);
+ }
+
+ public ILegacyClientServerFactory ClientServerFactory()
+ {
+ return (ILegacyClientServerFactory)_config.Get(ClientServerFactoryKey);
+ }
+
+ public ICacheConfiguration Cache()
+ {
+ return new CacheConfigurationImpl(this);
+ }
+
+ public bool FileBasedTransactionLog()
+ {
+ return _config.GetAsBoolean(FileBasedTransactionLogKey);
+ }
+
+ public void FileBasedTransactionLog(bool flag)
+ {
+ _config.Put(FileBasedTransactionLogKey, flag);
+ }
+
+ private bool IsTainted()
+ {
+ return _config.GetAsBoolean(TaintedKey);
+ }
+
+ public void Taint()
+ {
+ _config.Put(TaintedKey, true);
+ }
+
+ public static void AssertIsNotTainted(IConfiguration config)
+ {
+ if (((Config4Impl)config).IsTainted())
+ {
+ throw new ArgumentException("Configuration already used.");
+ }
+ }
+
+ public void PrefetchDepth(int prefetchDepth)
+ {
+ _config.Put(PrefetchDepthKey, prefetchDepth);
+ EnsurePrefetchSlotCacheSize();
+ }
+
+ private void EnsurePrefetchSlotCacheSize()
+ {
+ if (!_prefetchSlotCacheSizeModifiedExternally)
+ {
+ PrefetchSlotCacheSize(CalculatedPrefetchSlotcacheSize());
+ _prefetchSlotCacheSizeModifiedExternally = false;
+ }
+ }
+
+ public int PrefetchDepth()
+ {
+ return _config.GetAsInt(PrefetchDepthKey);
+ }
+
+ public IList EnvironmentContributions()
+ {
+ return (IList)_config.Get(EnvironmentContributionsKey);
+ }
+
+ public void PrefetchSlotCacheSize(int slotCacheSize)
+ {
+ _prefetchSlotCacheSizeModifiedExternally = true;
+ _config.Put(PrefetchSlotCacheSizeKey, slotCacheSize);
+ if (null != _prefetchSettingsChanged) _prefetchSettingsChanged(null, EventArgs.Empty
+ );
+ }
+
+ public int PrefetchSlotCacheSize()
+ {
+ return _config.GetAsInt(PrefetchSlotCacheSizeKey);
+ }
+
+ private int CalculatedPrefetchSlotcacheSize()
+ {
+ long calculated = (long)PrefetchDepth() * PrefetchObjectCount() * PrefetchSlotCacheSizeFactor;
+ if (calculated > MaximumPrefetchSlotCacheSize)
+ {
+ calculated = MaximumPrefetchSlotCacheSize;
+ }
+ return (int)calculated;
+ }
+
+ public event System.EventHandler PrefetchSettingsChanged
+ {
+ add
+ {
+ _prefetchSettingsChanged = (System.EventHandler)System.Delegate.Combine
+ (_prefetchSettingsChanged, value);
+ }
+ remove
+ {
+ _prefetchSettingsChanged = (System.EventHandler)System.Delegate.Remove
+ (_prefetchSettingsChanged, value);
+ }
+ }
+
+ public void ReferenceSystemFactory(IReferenceSystemFactory referenceSystemFactory
+ )
+ {
+ _config.Put(ReferenceSystemFactoryKey, referenceSystemFactory);
+ }
+
+ public IReferenceSystemFactory ReferenceSystemFactory()
+ {
+ return (IReferenceSystemFactory)_config.Get(ReferenceSystemFactoryKey);
+ }
+
+ public void NameProvider(INameProvider provider)
+ {
+ _config.Put(NameProviderKey, provider);
+ }
+
+ public INameProvider NameProvider()
+ {
+ return (INameProvider)_config.Get(NameProviderKey);
+ }
+
+ public void UsePointerBasedIdSystem()
+ {
+ _config.Put(IdSystemKey, StandardIdSystemFactory.PointerBased);
+ }
+
+ public void UseStackedBTreeIdSystem()
+ {
+ _config.Put(IdSystemKey, StandardIdSystemFactory.StackedBtree);
+ }
+
+ public void UseSingleBTreeIdSystem()
+ {
+ _config.Put(IdSystemKey, StandardIdSystemFactory.SingleBtree);
+ }
+
+ public byte IdSystemType()
+ {
+ return _config.GetAsByte(IdSystemKey);
+ }
+
+ public void UseInMemoryIdSystem()
+ {
+ _config.Put(IdSystemKey, StandardIdSystemFactory.InMemory);
+ }
+
+ public void UseCustomIdSystem(IIdSystemFactory factory)
+ {
+ _config.Put(IdSystemKey, StandardIdSystemFactory.Custom);
+ _config.Put(IdSystemCustomFactoryKey, factory);
+ }
+
+ public IIdSystemFactory CustomIdSystemFactory()
+ {
+ return (IIdSystemFactory)_config.Get(IdSystemCustomFactoryKey);
+ }
+
+ public void AsynchronousSync(bool flag)
+ {
+ _config.Put(AsynchronousSyncKey, flag);
+ }
+
+ public bool AsynchronousSync()
+ {
+ return _config.GetAsBoolean(AsynchronousSyncKey);
+ }
+
+ public int MaxStackDepth()
+ {
+ return _config.GetAsInt(MaxStackDepthKey);
+ }
+
+ public void MaxStackDepth(int maxStackDepth)
+ {
+ _config.Put(MaxStackDepthKey, maxStackDepth);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,227 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Config;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Types;
+
+namespace Db4objects.Db4o.Internal
+{
+ /// TODO: Split into separate enums with defined range and values.
+ public sealed partial class Const4
+ {
+ public const byte Yapfileversion = 4;
+
+ public const byte Yapbegin = (byte)'{';
+
+ public const byte Yapfile = (byte)'Y';
+
+ public const byte Yapid = (byte)'#';
+
+ public const byte Yappointer = (byte)'>';
+
+ public const byte Yapclasscollection = (byte)'A';
+
+ public const byte Yapclass = (byte)'C';
+
+ public const byte Yapfield = (byte)'F';
+
+ public const byte Yapobject = (byte)'O';
+
+ public const byte Yaparray = (byte)'N';
+
+ public const byte Yaparrayn = (byte)'Z';
+
+ public const byte Yapindex = (byte)'X';
+
+ public const byte Yapstring = (byte)'S';
+
+ public const byte Yaplong = (byte)'l';
+
+ public const byte Yapinteger = (byte)'i';
+
+ public const byte Yapboolean = (byte)'=';
+
+ public const byte Yapdouble = (byte)'d';
+
+ public const byte Yapbyte = (byte)'b';
+
+ public const byte Yapshort = (byte)'s';
+
+ public const byte Yapchar = (byte)'c';
+
+ public const byte Yapfloat = (byte)'f';
+
+ public const byte Yapend = (byte)'}';
+
+ public const byte Yapnull = (byte)'0';
+
+ public const byte Btree = (byte)'T';
+
+ public const byte BtreeNode = (byte)'B';
+
+ public const byte Header = (byte)'H';
+
+ public const byte IntegerArray = (byte)'I';
+
+ public const byte BtreeList = (byte)'L';
+
+ public const int IdentifierLength = (Deploy.debug && Deploy.identifiers) ? 1 : 0;
+
+ public const int BracketsBytes = (Deploy.debug && Deploy.brackets) ? 1 : 0;
+
+ public const int BracketsLength = BracketsBytes * 2;
+
+ public const int LeadingLength = IdentifierLength + BracketsBytes;
+
+ public const int AddedLength = IdentifierLength + BracketsLength;
+
+ public const int ShortBytes = 2;
+
+ public const int IntegerBytes = (Deploy.debug && Deploy.debugLong) ? 11 : 4;
+
+ public const int LongBytes = (Deploy.debug && Deploy.debugLong) ? 20 : 8;
+
+ public const int CharBytes = 2;
+
+ public const int Unspecified = int.MinValue + 100;
+
+ public const int IntLength = IntegerBytes + AddedLength;
+
+ public const int IdLength = IntLength;
+
+ public const int LongLength = LongBytes + AddedLength;
+
+ public const int IndirectionLength = IntLength + IdLength;
+
+ public const int WriteLoop = (IntegerBytes - 1) * 8;
+
+ public const int ObjectLength = AddedLength;
+
+ public const int PointerLength = (IntLength * 2) + AddedLength;
+
+ public const int MessageLength = IntLength * 2 + 1;
+
+ public const byte SystemTrans = (byte)'s';
+
+ public const byte UserTrans = (byte)'u';
+
+ public const byte Xbyte = (byte)'X';
+
+ public const int IgnoreId = -99999;
+
+ public const int Primitive = -2000000000;
+
+ public const int TypeArray = 3;
+
+ public const int TypeNarray = 4;
+
+ public const int None = 0;
+
+ public const int State = 1;
+
+ public const int Activation = 2;
+
+ public const int Transient = -1;
+
+ public const int AddMembersToIdTreeOnly = 0;
+
+ public const int AddToIdTree = 1;
+
+ public const int LockTimeInterval = 1000;
+
+ public const int ServerSocketTimeout = Debug4.longTimeOuts ? 1000000 : 600000;
+
+ public const int ClientSocketTimeout = ServerSocketTimeout;
+
+ public const int MaximumBlockSize = 70000000;
+
+ public const int MaximumArrayEntries = 7000000;
+
+ public const int MaximumArrayEntriesPrimitive = MaximumArrayEntries * 100;
+
+ public static readonly Type ClassCompare = typeof(ICompare);
+
+ public static readonly Type ClassDb4otype = typeof(IDb4oType);
+
+ public static readonly Type ClassDb4otypeimpl = typeof(IDb4oTypeImpl);
+
+ public static readonly Type ClassInternal = typeof(IInternal4);
+
+ public static readonly Type ClassUnversioned = typeof(IUnversioned);
+
+ public static readonly Type ClassObject = new object().GetType();
+
+ public static readonly Type ClassObjectcontainer = typeof(IObjectContainer);
+
+ public static readonly Type ClassStaticfield = new StaticField().GetType();
+
+ public static readonly Type ClassStaticclass = new StaticClass().GetType();
+
+ public static readonly Type ClassTransientclass = typeof(ITransientClass);
+
+ public static readonly string EmbeddedClientUser = "embedded client";
+
+ public const int Clean = 0;
+
+ public const int Active = 1;
+
+ public const int Processing = 2;
+
+ public const int CachedDirty = 3;
+
+ public const int Continue = 4;
+
+ public const int StaticFieldsStored = 5;
+
+ public const int CheckedChanges = 6;
+
+ public const int Dead = 7;
+
+ public const int Reading = 8;
+
+ public const int Activating = 9;
+
+ public const int Old = -1;
+
+ public const int New = 1;
+
+ public static readonly UnicodeStringIO stringIO = new UnicodeStringIO();
+
+ public static readonly Type[] EssentialClasses = new Type[] { ClassStaticfield, ClassStaticclass
+ };
+
+ public static readonly string VirtualFieldPrefix = "v4o";
+
+ public const int InvalidObjectId = 1;
+
+ public const int DefaultMaxStackDepth = 20;
+ // make sure we don't fall over the -1 cliff
+ // TODO: Is this the right place for the knowledge, that an indirection
+ // within a slot is an address and a length?
+ // debug constants
+ // TODO: This one is a terrible low-frequency blunder in YapArray.writeClass!!!
+ // If YapClass-ID == 99999 (not very likely) then we will get IGNORE_ID. Change
+ // to -Integer.MAX_VALUE or protect 99999 in YapFile.getPointerSlot()
+ // This is a hard coded 2 Gig-Limit for YapClass-IDs.
+ // TODO: get rid of magic numbers like this one
+ // array type information
+ // message levels
+ // Use if > NONE: normal messages
+ // if > STATE: state messages
+ // if > ACTIVATION: activation messages
+ // Timings
+ // 10 minutes until clients are disconnected, (5 minutes until they get pinged)
+ // TODO: Consider to make configurable
+ // 70 MB
+ // 7 Million
+ // 70 MB for byte arrays
+ // bits in PersistentBase.i_state
+ // and reuse in other classes
+ // system classes that need to get loaded first
+ // StaticClass should load Staticfield
+ // TODO: remove unnecessary
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,20 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Convert;
+
+namespace Db4objects.Db4o.Internal.Convert
+{
+ ///
+ public abstract class Conversion
+ {
+ ///
+ public virtual void Convert(ConversionStage.ClassCollectionAvailableStage stage)
+ {
+ }
+
+ ///
+ public virtual void Convert(ConversionStage.SystemUpStage stage)
+ {
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,17 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Convert;
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public class ClassAspects_7_4 : Conversion
+ {
+ public const int Version = 7;
+
+ public override void Convert(ConversionStage.SystemUpStage stage)
+ {
+ stage.File().ClassCollection().WriteAllClasses();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,38 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Btree;
+using Db4objects.Db4o.Internal.Convert;
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public class ClassIndexesToBTrees_5_5 : Conversion
+ {
+ public const int Version = 5;
+
+ public virtual void Convert(LocalObjectContainer container, int classIndexId, BTree
+ bTree)
+ {
+ Transaction trans = container.SystemTransaction();
+ ByteArrayBuffer reader = container.ReadBufferById(trans, classIndexId);
+ if (reader == null)
+ {
+ return;
+ }
+ int entries = reader.ReadInt();
+ for (int i = 0; i < entries; i++)
+ {
+ bTree.Add(trans, reader.ReadInt());
+ }
+ }
+
+ public override void Convert(ConversionStage.SystemUpStage stage)
+ {
+ // calling #storedClasses forces reading all classes
+ // That's good enough to load them all and to call the
+ // above convert method.
+ stage.File().StoredClasses();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Convert;
+using Db4objects.Db4o.Internal.Convert.Conversions;
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public class CommonConversions
+ {
+ public static void Register(Converter converter)
+ {
+ converter.Register(ClassIndexesToBTrees_5_5.Version, new ClassIndexesToBTrees_5_5
+ ());
+ converter.Register(FieldIndexesToBTrees_5_7.Version, new FieldIndexesToBTrees_5_7
+ ());
+ converter.Register(ClassAspects_7_4.Version, new ClassAspects_7_4());
+ converter.Register(ReindexNetDateTime_7_8.Version, new ReindexNetDateTime_7_8());
+ converter.Register(DropEnumClassIndexes_7_10.Version, new DropEnumClassIndexes_7_10
+ ());
+ converter.Register(DropGuidClassIndexes_7_12.Version, new DropGuidClassIndexes_7_12
+ ());
+ converter.Register(DropDateTimeOffsetClassIndexes_7_12.Version, new DropDateTimeOffsetClassIndexes_7_12
+ ());
+ converter.Register(VersionNumberToCommitTimestamp_8_0.Version, new VersionNumberToCommitTimestamp_8_0
+ ());
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public partial class DropDateTimeOffsetClassIndexes_7_12
+ {
+ public const int Version = 11;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ /// *
+ public partial class DropEnumClassIndexes_7_10
+ {
+ public const int Version = 9;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public partial class DropGuidClassIndexes_7_12
+ {
+ public const int Version = 10;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,40 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Convert;
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public class FieldIndexesToBTrees_5_7 : Conversion
+ {
+ public const int Version = 6;
+
+ public override void Convert(ConversionStage.SystemUpStage stage)
+ {
+ stage.File().ClassCollection().WriteAllClasses();
+ RebuildUUIDIndex(stage.File());
+ FreeOldUUIDMetaIndex(stage.File());
+ }
+
+ private void RebuildUUIDIndex(LocalObjectContainer file)
+ {
+ UUIDFieldMetadata uuid = file.UUIDIndex();
+ ClassMetadataIterator i = file.ClassCollection().Iterator();
+ while (i.MoveNext())
+ {
+ ClassMetadata clazz = i.CurrentClass();
+ if (clazz.GenerateUUIDs())
+ {
+ uuid.RebuildIndexForClass(file, clazz);
+ }
+ }
+ }
+
+ ///
+ private void FreeOldUUIDMetaIndex(LocalObjectContainer file)
+ {
+ }
+ // updating removed here to allow removing MetaIndex class
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,10 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public partial class ReindexNetDateTime_7_8
+ {
+ public const int Version = 8;
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,90 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Convert;
+using Db4objects.Db4o.Internal.Handlers;
+using Db4objects.Db4o.Internal.Marshall;
+
+namespace Db4objects.Db4o.Internal.Convert.Conversions
+{
+ ///
+ public class VersionNumberToCommitTimestamp_8_0 : Conversion
+ {
+ public const int Version = 12;
+
+ private VersionFieldMetadata versionFieldMetadata;
+
+ public override void Convert(ConversionStage.SystemUpStage stage)
+ {
+ LocalObjectContainer container = stage.File();
+ if (!container.Config().GenerateCommitTimestamps().DefiniteYes())
+ {
+ return;
+ }
+ container.ClassCollection().WriteAllClasses();
+ BuildCommitTimestampIndex(container);
+ container.SystemTransaction().Commit();
+ }
+
+ private void BuildCommitTimestampIndex(LocalObjectContainer container)
+ {
+ versionFieldMetadata = container.Handlers.Indexes()._version;
+ ClassMetadataIterator i = container.ClassCollection().Iterator();
+ while (i.MoveNext())
+ {
+ ClassMetadata clazz = i.CurrentClass();
+ if (clazz.HasVersionField() && !clazz.IsStruct())
+ {
+ RebuildIndexForClass(container, clazz);
+ }
+ }
+ }
+
+ public virtual bool RebuildIndexForClass(LocalObjectContainer container, ClassMetadata
+ classMetadata)
+ {
+ long[] ids = classMetadata.GetIDs();
+ for (int i = 0; i < ids.Length; i++)
+ {
+ RebuildIndexForObject(container, (int)ids[i]);
+ }
+ return ids.Length > 0;
+ }
+
+ ///
+ protected virtual void RebuildIndexForObject(LocalObjectContainer container, int
+ objectId)
+ {
+ StatefulBuffer writer = container.ReadStatefulBufferById(container.SystemTransaction
+ (), objectId);
+ if (writer != null)
+ {
+ RebuildIndexForWriter(container, writer, objectId);
+ }
+ }
+
+ protected virtual void RebuildIndexForWriter(LocalObjectContainer container, StatefulBuffer
+ buffer, int objectId)
+ {
+ ObjectHeader objectHeader = new ObjectHeader(container, buffer);
+ ObjectIdContextImpl context = new ObjectIdContextImpl(container.SystemTransaction
+ (), buffer, objectHeader, objectId);
+ ClassMetadata classMetadata = context.ClassMetadata();
+ if (classMetadata.IsStruct())
+ {
+ // We don't keep version information for structs.
+ return;
+ }
+ if (classMetadata.SeekToField(container.SystemTransaction(), buffer, versionFieldMetadata
+ ) != HandlerVersion.Invalid)
+ {
+ long version = ((long)versionFieldMetadata.Read(context));
+ if (version != 0)
+ {
+ LocalTransaction t = (LocalTransaction)container.SystemTransaction();
+ t.CommitTimestampSupport().Put(container.SystemTransaction(), objectId, version);
+ }
+ }
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,54 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Convert;
+
+namespace Db4objects.Db4o.Internal.Convert
+{
+ ///
+ public abstract class ConversionStage
+ {
+ public sealed class ClassCollectionAvailableStage : ConversionStage
+ {
+ public ClassCollectionAvailableStage(LocalObjectContainer file) : base(file)
+ {
+ }
+
+ public override void Accept(Conversion conversion)
+ {
+ conversion.Convert(this);
+ }
+ }
+
+ public sealed class SystemUpStage : ConversionStage
+ {
+ public SystemUpStage(LocalObjectContainer file) : base(file)
+ {
+ }
+
+ public override void Accept(Conversion conversion)
+ {
+ conversion.Convert(this);
+ }
+ }
+
+ private LocalObjectContainer _file;
+
+ protected ConversionStage(LocalObjectContainer file)
+ {
+ _file = file;
+ }
+
+ public virtual LocalObjectContainer File()
+ {
+ return _file;
+ }
+
+ public virtual int ConverterVersion()
+ {
+ return _file.SystemData().ConverterVersion();
+ }
+
+ public abstract void Accept(Conversion conversion);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,87 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Internal.Convert;
+using Db4objects.Db4o.Internal.Convert.Conversions;
+
+namespace Db4objects.Db4o.Internal.Convert
+{
+ ///
+ public class Converter
+ {
+ public const int Version = VersionNumberToCommitTimestamp_8_0.Version;
+
+ public static bool Convert(ConversionStage stage)
+ {
+ if (!NeedsConversion(stage.ConverterVersion()))
+ {
+ return false;
+ }
+ return Instance().RunConversions(stage);
+ }
+
+ private static Db4objects.Db4o.Internal.Convert.Converter _instance;
+
+ private IDictionary _conversions;
+
+ private int _minimumVersion = int.MaxValue;
+
+ private Converter()
+ {
+ _conversions = new Hashtable();
+ // TODO: There probably will be Java and .NET conversions
+ // Create Platform4.registerConversions() method ann
+ // call from here when needed.
+ CommonConversions.Register(this);
+ }
+
+ public static Db4objects.Db4o.Internal.Convert.Converter Instance()
+ {
+ if (_instance == null)
+ {
+ _instance = new Db4objects.Db4o.Internal.Convert.Converter();
+ }
+ return _instance;
+ }
+
+ public virtual Conversion ConversionFor(int version)
+ {
+ return ((Conversion)_conversions[version]);
+ }
+
+ private static bool NeedsConversion(int converterVersion)
+ {
+ return converterVersion < Version;
+ }
+
+ public virtual void Register(int introducedVersion, Conversion conversion)
+ {
+ if (_conversions.Contains(introducedVersion))
+ {
+ throw new InvalidOperationException();
+ }
+ if (introducedVersion < _minimumVersion)
+ {
+ _minimumVersion = introducedVersion;
+ }
+ _conversions[introducedVersion] = conversion;
+ }
+
+ public virtual bool RunConversions(ConversionStage stage)
+ {
+ int startingVersion = Math.Max(stage.ConverterVersion() + 1, _minimumVersion);
+ for (int version = startingVersion; version <= Version; version++)
+ {
+ Conversion conversion = ConversionFor(version);
+ if (conversion == null)
+ {
+ throw new InvalidOperationException("Could not find a conversion for version " +
+ version);
+ }
+ stage.Accept(conversion);
+ }
+ return true;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,480 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o;
+using Db4objects.Db4o.Defragment;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Internal.Mapping;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Internal.Slots;
+using Db4objects.Db4o.Marshall;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public sealed class DefragmentContextImpl : IReadWriteBuffer, IDefragmentContext
+ {
+ private ByteArrayBuffer _source;
+
+ private ByteArrayBuffer _target;
+
+ private IDefragmentServices _services;
+
+ private readonly ObjectHeader _objectHeader;
+
+ private int _declaredAspectCount;
+
+ private int _currentParentSourceID;
+
+ public DefragmentContextImpl(ByteArrayBuffer source, Db4objects.Db4o.Internal.DefragmentContextImpl
+ context) : this(source, context._services, context._objectHeader)
+ {
+ }
+
+ public DefragmentContextImpl(ByteArrayBuffer source, IDefragmentServices services
+ ) : this(source, services, null)
+ {
+ }
+
+ public DefragmentContextImpl(ByteArrayBuffer source, IDefragmentServices services
+ , ObjectHeader header)
+ {
+ _source = source;
+ _services = services;
+ _target = new ByteArrayBuffer(Length());
+ _source.CopyTo(_target, 0, 0, Length());
+ _objectHeader = header;
+ }
+
+ public DefragmentContextImpl(Db4objects.Db4o.Internal.DefragmentContextImpl parentContext
+ , ObjectHeader header)
+ {
+ _source = parentContext._source;
+ _target = parentContext._target;
+ _services = parentContext._services;
+ _objectHeader = header;
+ }
+
+ public int Offset()
+ {
+ return _source.Offset();
+ }
+
+ public void Seek(int offset)
+ {
+ _source.Seek(offset);
+ _target.Seek(offset);
+ }
+
+ public void IncrementOffset(int numBytes)
+ {
+ _source.IncrementOffset(numBytes);
+ _target.IncrementOffset(numBytes);
+ }
+
+ public void IncrementIntSize()
+ {
+ IncrementOffset(Const4.IntLength);
+ }
+
+ public int CopySlotlessID()
+ {
+ return CopyUnindexedId(false);
+ }
+
+ public int CopyUnindexedID()
+ {
+ return CopyUnindexedId(true);
+ }
+
+ private int CopyUnindexedId(bool doRegister)
+ {
+ int orig = _source.ReadInt();
+ // TODO: There is no test case for the zero case
+ if (orig == 0)
+ {
+ _target.WriteInt(0);
+ return 0;
+ }
+ int mapped = -1;
+ try
+ {
+ mapped = _services.StrictMappedID(orig);
+ }
+ catch (MappingNotFoundException)
+ {
+ mapped = _services.TargetNewId();
+ _services.MapIDs(orig, mapped, false);
+ if (doRegister)
+ {
+ _services.RegisterUnindexed(orig);
+ }
+ }
+ _target.WriteInt(mapped);
+ return mapped;
+ }
+
+ public int CopyID()
+ {
+ // This code is slightly redundant.
+ // The profiler shows it's a hotspot.
+ // The following would be non-redudant.
+ // return copy(false, false);
+ int id = _source.ReadInt();
+ return WriteMappedID(id);
+ }
+
+ public int CopyID(bool flipNegative)
+ {
+ int id = _source.ReadInt();
+ return InternalCopyID(flipNegative, id);
+ }
+
+ public int CopyIDReturnOriginalID()
+ {
+ return CopyIDReturnOriginalID(false);
+ }
+
+ public int CopyIDReturnOriginalID(bool flipNegative)
+ {
+ int id = _source.ReadInt();
+ InternalCopyID(flipNegative, id);
+ bool flipped = flipNegative && (id < 0);
+ if (flipped)
+ {
+ return -id;
+ }
+ return id;
+ }
+
+ private int InternalCopyID(bool flipNegative, int id)
+ {
+ bool flipped = flipNegative && (id < 0);
+ if (flipped)
+ {
+ id = -id;
+ }
+ int mapped = _services.MappedID(id);
+ if (flipped)
+ {
+ mapped = -mapped;
+ }
+ _target.WriteInt(mapped);
+ return mapped;
+ }
+
+ public void ReadBegin(byte identifier)
+ {
+ _source.ReadBegin(identifier);
+ _target.ReadBegin(identifier);
+ }
+
+ public byte ReadByte()
+ {
+ byte value = _source.ReadByte();
+ _target.IncrementOffset(1);
+ return value;
+ }
+
+ public void ReadBytes(byte[] bytes)
+ {
+ _source.ReadBytes(bytes);
+ _target.IncrementOffset(bytes.Length);
+ }
+
+ public int ReadInt()
+ {
+ int value = _source.ReadInt();
+ _target.IncrementOffset(Const4.IntLength);
+ return value;
+ }
+
+ public void WriteInt(int value)
+ {
+ _source.IncrementOffset(Const4.IntLength);
+ _target.WriteInt(value);
+ }
+
+ public void Write(LocalObjectContainer file, int address)
+ {
+ file.WriteBytes(_target, address, 0);
+ }
+
+ public void IncrementStringOffset(LatinStringIO sio)
+ {
+ IncrementStringOffset(sio, _source);
+ IncrementStringOffset(sio, _target);
+ }
+
+ private void IncrementStringOffset(LatinStringIO sio, ByteArrayBuffer buffer)
+ {
+ sio.ReadLengthAndString(buffer);
+ }
+
+ public ByteArrayBuffer SourceBuffer()
+ {
+ return _source;
+ }
+
+ public ByteArrayBuffer TargetBuffer()
+ {
+ return _target;
+ }
+
+ public IIDMapping Mapping()
+ {
+ return _services;
+ }
+
+ public Db4objects.Db4o.Internal.Transaction SystemTrans()
+ {
+ return Transaction();
+ }
+
+ public IDefragmentServices Services()
+ {
+ return _services;
+ }
+
+ public static void ProcessCopy(IDefragmentServices context, int sourceID, ISlotCopyHandler
+ command)
+ {
+ ByteArrayBuffer sourceReader = context.SourceBufferByID(sourceID);
+ ProcessCopy(context, sourceID, command, sourceReader);
+ }
+
+ public static void ProcessCopy(IDefragmentServices services, int sourceID, ISlotCopyHandler
+ command, ByteArrayBuffer sourceReader)
+ {
+ int targetID = services.StrictMappedID(sourceID);
+ Slot targetSlot = services.AllocateTargetSlot(sourceReader.Length());
+ services.Mapping().MapId(targetID, targetSlot);
+ Db4objects.Db4o.Internal.DefragmentContextImpl context = new Db4objects.Db4o.Internal.DefragmentContextImpl
+ (sourceReader, services);
+ command.ProcessCopy(context);
+ services.TargetWriteBytes(context, targetSlot.Address());
+ }
+
+ public void WriteByte(byte value)
+ {
+ _source.IncrementOffset(1);
+ _target.WriteByte(value);
+ }
+
+ public long ReadLong()
+ {
+ long value = _source.ReadLong();
+ _target.IncrementOffset(Const4.LongLength);
+ return value;
+ }
+
+ public void WriteLong(long value)
+ {
+ _source.IncrementOffset(Const4.LongLength);
+ _target.WriteLong(value);
+ }
+
+ public BitMap4 ReadBitMap(int bitCount)
+ {
+ BitMap4 value = _source.ReadBitMap(bitCount);
+ _target.IncrementOffset(value.MarshalledLength());
+ return value;
+ }
+
+ public void ReadEnd()
+ {
+ _source.ReadEnd();
+ _target.ReadEnd();
+ }
+
+ public int WriteMappedID(int originalID)
+ {
+ int mapped = _services.MappedID(originalID);
+ _target.WriteInt(mapped);
+ return mapped;
+ }
+
+ public int Length()
+ {
+ return _source.Length();
+ }
+
+ public Db4objects.Db4o.Internal.Transaction Transaction()
+ {
+ return Services().SystemTrans();
+ }
+
+ public ObjectContainerBase Container()
+ {
+ return Transaction().Container();
+ }
+
+ public ITypeHandler4 TypeHandlerForId(int id)
+ {
+ return Container().TypeHandlerForClassMetadataID(id);
+ }
+
+ public int HandlerVersion()
+ {
+ return _objectHeader.HandlerVersion();
+ }
+
+ public bool IsLegacyHandlerVersion()
+ {
+ return HandlerVersion() == 0;
+ }
+
+ public int MappedID(int origID)
+ {
+ return Mapping().StrictMappedID(origID);
+ }
+
+ public IObjectContainer ObjectContainer()
+ {
+ return Container();
+ }
+
+ /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0.
+ ///
+ ///
+ /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0.
+ /// Doesn't need to work with modern IdSystems.
+ ///
+ public Slot AllocateTargetSlot(int length)
+ {
+ return _services.AllocateTargetSlot(length);
+ }
+
+ /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0.
+ ///
+ ///
+ /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0.
+ /// Doesn't need to work with modern IdSystems.
+ ///
+ public Slot AllocateMappedTargetSlot(int sourceAddress, int length)
+ {
+ Slot slot = AllocateTargetSlot(length);
+ _services.MapIDs(sourceAddress, slot.Address(), false);
+ return slot;
+ }
+
+ ///
+ public int CopySlotToNewMapped(int sourceAddress, int length)
+ {
+ Slot slot = AllocateMappedTargetSlot(sourceAddress, length);
+ ByteArrayBuffer sourceBuffer = SourceBufferByAddress(sourceAddress, length);
+ TargetWriteBytes(slot.Address(), sourceBuffer);
+ return slot.Address();
+ }
+
+ public void TargetWriteBytes(int address, ByteArrayBuffer buffer)
+ {
+ _services.TargetWriteBytes(buffer, address);
+ }
+
+ ///
+ public ByteArrayBuffer SourceBufferByAddress(int sourceAddress, int length)
+ {
+ ByteArrayBuffer sourceBuffer = _services.SourceBufferByAddress(sourceAddress, length
+ );
+ return sourceBuffer;
+ }
+
+ ///
+ public ByteArrayBuffer SourceBufferById(int sourceId)
+ {
+ ByteArrayBuffer sourceBuffer = _services.SourceBufferByID(sourceId);
+ return sourceBuffer;
+ }
+
+ public void WriteToTarget(int address)
+ {
+ _services.TargetWriteBytes(this, address);
+ }
+
+ public void WriteBytes(byte[] bytes)
+ {
+ _target.WriteBytes(bytes);
+ _source.IncrementOffset(bytes.Length);
+ }
+
+ public IReadBuffer Buffer()
+ {
+ return _source;
+ }
+
+ public void Defragment(ITypeHandler4 handler)
+ {
+ ITypeHandler4 typeHandler = HandlerRegistry.CorrectHandlerVersion(this, handler);
+ if (Handlers4.UseDedicatedSlot(this, typeHandler))
+ {
+ if (Handlers4.HasClassIndex(typeHandler))
+ {
+ CopyID();
+ }
+ else
+ {
+ CopyUnindexedID();
+ }
+ return;
+ }
+ typeHandler.Defragment(this);
+ }
+
+ public void BeginSlot()
+ {
+ }
+
+ // do nothing
+ public Db4objects.Db4o.Internal.ClassMetadata ClassMetadata()
+ {
+ return _objectHeader.ClassMetadata();
+ }
+
+ public bool IsNull(int fieldIndex)
+ {
+ return _objectHeader._headerAttributes.IsNull(fieldIndex);
+ }
+
+ public int DeclaredAspectCount()
+ {
+ return _declaredAspectCount;
+ }
+
+ public void DeclaredAspectCount(int count)
+ {
+ _declaredAspectCount = count;
+ }
+
+ public Db4objects.Db4o.Internal.Marshall.SlotFormat SlotFormat()
+ {
+ return Db4objects.Db4o.Internal.Marshall.SlotFormat.ForHandlerVersion(HandlerVersion
+ ());
+ }
+
+ public void CurrentParentSourceID(int id)
+ {
+ _currentParentSourceID = id;
+ }
+
+ public int ConsumeCurrentParentSourceID()
+ {
+ int id = _currentParentSourceID;
+ _currentParentSourceID = 0;
+ return id;
+ }
+
+ public void CopyAddress()
+ {
+ int sourceEntryAddress = _source.ReadInt();
+ int sourceId = ConsumeCurrentParentSourceID();
+ int sourceObjectAddress = _services.SourceAddressByID(sourceId);
+ int entryOffset = sourceEntryAddress - sourceObjectAddress;
+ int targetObjectAddress = _services.TargetAddressByID(_services.StrictMappedID(sourceId
+ ));
+ _target.WriteInt(targetObjectAddress + entryOffset);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,122 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Diagnostic;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Delete;
+using Db4objects.Db4o.Internal.Diagnostic;
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Internal.Slots;
+using Db4objects.Db4o.Reflect;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal.Delete
+{
+ ///
+ public class DeleteContextImpl : ObjectHeaderContext, IDeleteContext, IObjectIdContext
+ {
+ private readonly IReflectClass _fieldClass;
+
+ private readonly Config4Field _fieldConfig;
+
+ public DeleteContextImpl(Db4objects.Db4o.Internal.StatefulBuffer buffer, ObjectHeader
+ objectHeader, IReflectClass fieldClass, Config4Field fieldConfig) : base(buffer
+ .Transaction(), buffer, objectHeader)
+ {
+ _fieldClass = fieldClass;
+ _fieldConfig = fieldConfig;
+ }
+
+ public DeleteContextImpl(Db4objects.Db4o.Internal.Delete.DeleteContextImpl parentContext
+ , IReflectClass fieldClass, Config4Field fieldConfig) : this(parentContext.StatefulBuffer
+ (), parentContext._objectHeader, fieldClass, fieldConfig)
+ {
+ }
+
+ public virtual void CascadeDeleteDepth(int depth)
+ {
+ StatefulBuffer().SetCascadeDeletes(depth);
+ }
+
+ private Db4objects.Db4o.Internal.StatefulBuffer StatefulBuffer()
+ {
+ return ((Db4objects.Db4o.Internal.StatefulBuffer)Buffer());
+ }
+
+ public virtual int CascadeDeleteDepth()
+ {
+ return StatefulBuffer().CascadeDeletes();
+ }
+
+ public virtual bool CascadeDelete()
+ {
+ return CascadeDeleteDepth() > 0;
+ }
+
+ public virtual void DefragmentRecommended()
+ {
+ DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor();
+ if (dp.Enabled())
+ {
+ dp.DefragmentRecommended(DefragmentRecommendation.DefragmentRecommendationReason.
+ DeleteEmbeded);
+ }
+ }
+
+ public virtual Slot ReadSlot()
+ {
+ return new Slot(Buffer().ReadInt(), Buffer().ReadInt());
+ }
+
+ public virtual void Delete(ITypeHandler4 handler)
+ {
+ ITypeHandler4 correctHandlerVersion = HandlerRegistry.CorrectHandlerVersion(this,
+ handler);
+ int preservedCascadeDepth = CascadeDeleteDepth();
+ CascadeDeleteDepth(AdjustedDepth());
+ if (Handlers4.HandleAsObject(correctHandlerVersion))
+ {
+ DeleteObject();
+ }
+ else
+ {
+ correctHandlerVersion.Delete(this);
+ }
+ CascadeDeleteDepth(preservedCascadeDepth);
+ }
+
+ public virtual void DeleteObject()
+ {
+ int id = Buffer().ReadInt();
+ if (CascadeDelete())
+ {
+ Container().DeleteByID(Transaction(), id, CascadeDeleteDepth());
+ }
+ }
+
+ private int AdjustedDepth()
+ {
+ if (Platform4.IsStruct(_fieldClass))
+ {
+ return 1;
+ }
+ if (_fieldConfig == null)
+ {
+ return CascadeDeleteDepth();
+ }
+ if (_fieldConfig.CascadeOnDelete().DefiniteYes())
+ {
+ return 1;
+ }
+ if (_fieldConfig.CascadeOnDelete().DefiniteNo())
+ {
+ return 0;
+ }
+ return CascadeDeleteDepth();
+ }
+
+ public virtual int ObjectId()
+ {
+ return StatefulBuffer().GetID();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal.Marshall;
+using Db4objects.Db4o.Internal.Slots;
+using Db4objects.Db4o.Marshall;
+using Db4objects.Db4o.Typehandlers;
+
+namespace Db4objects.Db4o.Internal.Delete
+{
+ ///
+ public interface IDeleteContext : IContext, IReadBuffer, IHandlerVersionContext
+ {
+ bool CascadeDelete();
+
+ int CascadeDeleteDepth();
+
+ void Delete(ITypeHandler4 handler);
+
+ void DeleteObject();
+
+ bool IsLegacyHandlerVersion();
+
+ void DefragmentRecommended();
+
+ Slot ReadSlot();
+
+ int ObjectId();
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class DeleteInfo : TreeInt
+ {
+ internal int _cascade;
+
+ public ObjectReference _reference;
+
+ public DeleteInfo(int id, ObjectReference reference, int cascade) : base(id)
+ {
+ _reference = reference;
+ _cascade = cascade;
+ }
+
+ public override object ShallowClone()
+ {
+ Db4objects.Db4o.Internal.DeleteInfo deleteinfo = new Db4objects.Db4o.Internal.DeleteInfo
+ (0, _reference, _cascade);
+ return ShallowCloneInternal(deleteinfo);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,153 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using System.Collections;
+using Db4objects.Db4o.Diagnostic;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Query;
+
+namespace Db4objects.Db4o.Internal.Diagnostic
+{
+ /// FIXME: remove me from the core and make me a facade over Events
+ public class DiagnosticProcessor : IDiagnosticConfiguration, IDeepClone
+ {
+ private Collection4 _listeners;
+
+ public DiagnosticProcessor()
+ {
+ }
+
+ private DiagnosticProcessor(Collection4 listeners)
+ {
+ _listeners = listeners;
+ }
+
+ public virtual void AddListener(IDiagnosticListener listener)
+ {
+ if (_listeners == null)
+ {
+ _listeners = new Collection4();
+ }
+ _listeners.Add(listener);
+ }
+
+ public virtual void CheckClassHasFields(ClassMetadata classMetadata)
+ {
+ if (classMetadata.AspectsAreNull() || classMetadata.DeclaredAspectCount() == 0)
+ {
+ string name = classMetadata.GetName();
+ string[] ignoredPackages = new string[] { "java.util." };
+ for (int i = 0; i < ignoredPackages.Length; i++)
+ {
+ if (name.IndexOf(ignoredPackages[i]) == 0)
+ {
+ return;
+ }
+ }
+ if (IsDb4oClass(classMetadata))
+ {
+ return;
+ }
+ OnDiagnostic(new ClassHasNoFields(name));
+ }
+ }
+
+ public virtual void CheckUpdateDepth(int depth)
+ {
+ if (depth > 1)
+ {
+ OnDiagnostic(new UpdateDepthGreaterOne(depth));
+ }
+ }
+
+ public virtual object DeepClone(object context)
+ {
+ return new Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor(CloneListeners
+ ());
+ }
+
+ public virtual void DeletionFailed()
+ {
+ OnDiagnostic(new Db4objects.Db4o.Diagnostic.DeletionFailed());
+ }
+
+ public virtual void DefragmentRecommended(DefragmentRecommendation.DefragmentRecommendationReason
+ reason)
+ {
+ OnDiagnostic(new DefragmentRecommendation(reason));
+ }
+
+ private Collection4 CloneListeners()
+ {
+ return _listeners != null ? new Collection4(_listeners) : null;
+ }
+
+ public virtual bool Enabled()
+ {
+ return _listeners != null;
+ }
+
+ private bool IsDb4oClass(ClassMetadata classMetadata)
+ {
+ return classMetadata.IsInternal();
+ }
+
+ public virtual void LoadedFromClassIndex(ClassMetadata classMetadata)
+ {
+ if (IsDb4oClass(classMetadata))
+ {
+ return;
+ }
+ OnDiagnostic(new Db4objects.Db4o.Diagnostic.LoadedFromClassIndex(classMetadata.GetName
+ ()));
+ }
+
+ public virtual void DescendIntoTranslator(ClassMetadata parent, string fieldName)
+ {
+ OnDiagnostic(new Db4objects.Db4o.Diagnostic.DescendIntoTranslator(parent.GetName(
+ ), fieldName));
+ }
+
+ public virtual void NativeQueryUnoptimized(Predicate predicate, Exception exception
+ )
+ {
+ OnDiagnostic(new NativeQueryNotOptimized(predicate, exception));
+ }
+
+ public virtual void NativeQueryOptimizerNotLoaded(int reason, Exception e)
+ {
+ OnDiagnostic(new Db4objects.Db4o.Diagnostic.NativeQueryOptimizerNotLoaded(reason,
+ e));
+ }
+
+ public virtual void ObjectFieldDoesNotExist(string className, string fieldName)
+ {
+ OnDiagnostic(new Db4objects.Db4o.Diagnostic.ObjectFieldDoesNotExist(className, fieldName
+ ));
+ }
+
+ public virtual void ClassMissed(string className)
+ {
+ OnDiagnostic(new MissingClass(className));
+ }
+
+ public virtual void OnDiagnostic(IDiagnostic d)
+ {
+ if (_listeners == null)
+ {
+ return;
+ }
+ IEnumerator i = _listeners.GetEnumerator();
+ while (i.MoveNext())
+ {
+ ((IDiagnosticListener)i.Current).OnDiagnostic(d);
+ }
+ }
+
+ public virtual void RemoveAllListeners()
+ {
+ _listeners = null;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,36 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Slots;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public class DisabledBlockConverter : IBlockConverter
+ {
+ public virtual int BlockAlignedBytes(int bytes)
+ {
+ return bytes;
+ }
+
+ public virtual int BlocksToBytes(int blocks)
+ {
+ return blocks;
+ }
+
+ public virtual int BytesToBlocks(long bytes)
+ {
+ return (int)bytes;
+ }
+
+ public virtual Slot ToBlockedLength(Slot slot)
+ {
+ return slot;
+ }
+
+ public virtual Slot ToNonBlockedLength(Slot slot)
+ {
+ return slot;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,62 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Config.Encoding;
+using Db4objects.Db4o.Internal.Encoding;
+
+namespace Db4objects.Db4o.Internal.Encoding
+{
+ ///
+ public abstract class BuiltInStringEncoding : IStringEncoding
+ {
+ /// keep the position in the array.
+ ///
+ /// keep the position in the array.
+ /// Information is used to look up encodings.
+ ///
+ private static readonly BuiltInStringEncoding[] AllEncodings = new BuiltInStringEncoding
+ [] { null, new LatinStringEncoding(), new UnicodeStringEncoding(), new UTF8StringEncoding
+ () };
+
+ public static byte EncodingByteForEncoding(IStringEncoding encoding)
+ {
+ for (int i = 1; i < AllEncodings.Length; i++)
+ {
+ if (encoding.GetType() == AllEncodings[i].GetType())
+ {
+ return (byte)i;
+ }
+ }
+ return 0;
+ }
+
+ public static LatinStringIO StringIoForEncoding(byte encodingByte, IStringEncoding
+ encoding)
+ {
+ if (encodingByte < 0 || encodingByte > AllEncodings.Length)
+ {
+ throw new ArgumentException();
+ }
+ if (encodingByte == 0)
+ {
+ if (encoding is BuiltInStringEncoding)
+ {
+ Sharpen.Runtime.Out.WriteLine("Warning! Database was created with a custom string encoding but no custom string encoding is configured for this session."
+ );
+ }
+ return new DelegatingStringIO(encoding);
+ }
+ BuiltInStringEncoding builtInEncoding = AllEncodings[encodingByte];
+ return builtInEncoding.CreateStringIo(encoding);
+ }
+
+ protected virtual LatinStringIO CreateStringIo(IStringEncoding encoding)
+ {
+ return new DelegatingStringIO(encoding);
+ }
+
+ public abstract string Decode(byte[] arg1, int arg2, int arg3);
+
+ public abstract byte[] Encode(string arg1);
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,93 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config.Encoding;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal.Encoding
+{
+ ///
+ public class DelegatingStringIO : LatinStringIO
+ {
+ private readonly IStringEncoding _encoding;
+
+ public DelegatingStringIO(IStringEncoding encoding)
+ {
+ _encoding = encoding;
+ }
+
+ private string Decode(byte[] bytes, int start, int length)
+ {
+ return _encoding.Decode(bytes, start, length);
+ }
+
+ private byte[] Encode(string str)
+ {
+ return _encoding.Encode(str);
+ }
+
+ public override byte EncodingByte()
+ {
+ if (_encoding is BuiltInStringEncoding)
+ {
+ return BuiltInStringEncoding.EncodingByteForEncoding(_encoding);
+ }
+ return 0;
+ }
+
+ public override int Length(string str)
+ {
+ return Encode(str).Length + Const4.ObjectLength + Const4.IntLength;
+ }
+
+ public override string Read(IReadBuffer buffer, int length)
+ {
+ byte[] bytes = new byte[length];
+ buffer.ReadBytes(bytes);
+ return Decode(bytes, 0, bytes.Length);
+ }
+
+ public override string Read(byte[] bytes)
+ {
+ return Decode(bytes, 0, bytes.Length);
+ }
+
+ public override int ShortLength(string str)
+ {
+ return Encode(str).Length + Const4.IntLength;
+ }
+
+ public override void Write(IWriteBuffer buffer, string str)
+ {
+ buffer.WriteBytes(Encode(str));
+ }
+
+ public override byte[] Write(string str)
+ {
+ return Encode(str);
+ }
+
+ ///
+ /// Note the different implementation when compared to LatinStringIO and UnicodeStringIO:
+ /// Instead of writing the length of the string, UTF8StringIO writes the length of the
+ /// byte array.
+ ///
+ ///
+ /// Note the different implementation when compared to LatinStringIO and UnicodeStringIO:
+ /// Instead of writing the length of the string, UTF8StringIO writes the length of the
+ /// byte array.
+ ///
+ public override void WriteLengthAndString(IWriteBuffer buffer, string str)
+ {
+ if (str == null)
+ {
+ buffer.WriteInt(0);
+ return;
+ }
+ byte[] bytes = Encode(str);
+ buffer.WriteInt(bytes.Length);
+ buffer.WriteBytes(bytes);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Config.Encoding;
+using Db4objects.Db4o.Internal.Encoding;
+
+namespace Db4objects.Db4o.Internal.Encoding
+{
+ ///
+ public class LatinStringEncoding : BuiltInStringEncoding
+ {
+ public override string Decode(byte[] bytes, int start, int length)
+ {
+ throw new NotImplementedException();
+ }
+
+ // special StringIO, should never be called
+ public override byte[] Encode(string str)
+ {
+ throw new NotImplementedException();
+ }
+
+ // special StringIO, should never be called
+ protected override LatinStringIO CreateStringIo(IStringEncoding encoding)
+ {
+ return new LatinStringIO();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,107 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Marshall;
+using Sharpen;
+
+namespace Db4objects.Db4o.Internal.Encoding
+{
+ ///
+ public class LatinStringIO
+ {
+ public virtual byte[] Bytes(ByteArrayBuffer buffer)
+ {
+ int len = buffer.ReadInt();
+ len = BytesPerChar() * len;
+ byte[] res = new byte[len];
+ System.Array.Copy(buffer._buffer, buffer._offset, res, 0, len);
+ return res;
+ }
+
+ protected virtual int BytesPerChar()
+ {
+ return 1;
+ }
+
+ public virtual byte EncodingByte()
+ {
+ return BuiltInStringEncoding.EncodingByteForEncoding(new LatinStringEncoding());
+ }
+
+ public virtual int Length(string str)
+ {
+ return str.Length + Const4.ObjectLength + Const4.IntLength;
+ }
+
+ public virtual string Read(IReadBuffer buffer, int length)
+ {
+ char[] chars = new char[length];
+ for (int ii = 0; ii < length; ii++)
+ {
+ chars[ii] = (char)(buffer.ReadByte() & unchecked((int)(0xff)));
+ }
+ return new string(chars, 0, length);
+ }
+
+ public virtual string Read(byte[] bytes)
+ {
+ char[] chars = new char[bytes.Length];
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ chars[i] = (char)(bytes[i] & unchecked((int)(0xff)));
+ }
+ return new string(chars, 0, bytes.Length);
+ }
+
+ public virtual string ReadLengthAndString(IReadBuffer buffer)
+ {
+ int length = buffer.ReadInt();
+ if (length == 0)
+ {
+ return string.Empty;
+ }
+ return Read(buffer, length);
+ }
+
+ public virtual int ShortLength(string str)
+ {
+ return str.Length + Const4.IntLength;
+ }
+
+ public virtual void Write(IWriteBuffer buffer, string str)
+ {
+ int length = str.Length;
+ char[] chars = new char[length];
+ Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0);
+ for (int i = 0; i < length; i++)
+ {
+ buffer.WriteByte((byte)(chars[i] & unchecked((int)(0xff))));
+ }
+ }
+
+ public virtual byte[] Write(string str)
+ {
+ int length = str.Length;
+ char[] chars = new char[length];
+ Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0);
+ byte[] bytes = new byte[length];
+ for (int i = 0; i < length; i++)
+ {
+ bytes[i] = (byte)(chars[i] & unchecked((int)(0xff)));
+ }
+ return bytes;
+ }
+
+ public virtual void WriteLengthAndString(IWriteBuffer buffer, string str)
+ {
+ if (str == null)
+ {
+ buffer.WriteInt(0);
+ return;
+ }
+ buffer.WriteInt(str.Length);
+ Write(buffer, str);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,16 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Config.Encoding;
+using Db4objects.Db4o.Internal.Encoding;
+
+namespace Db4objects.Db4o.Internal.Encoding
+{
+ ///
+ public class UnicodeStringEncoding : LatinStringEncoding
+ {
+ protected override LatinStringIO CreateStringIo(IStringEncoding encoding)
+ {
+ return new UnicodeStringIO();
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,83 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Encoding;
+using Db4objects.Db4o.Marshall;
+
+namespace Db4objects.Db4o.Internal.Encoding
+{
+ ///
+ public sealed class UnicodeStringIO : LatinStringIO
+ {
+ protected override int BytesPerChar()
+ {
+ return 2;
+ }
+
+ public override byte EncodingByte()
+ {
+ return BuiltInStringEncoding.EncodingByteForEncoding(new UnicodeStringEncoding());
+ }
+
+ public override int Length(string str)
+ {
+ return (str.Length * 2) + Const4.ObjectLength + Const4.IntLength;
+ }
+
+ public override string Read(IReadBuffer buffer, int length)
+ {
+ char[] chars = new char[length];
+ for (int ii = 0; ii < length; ii++)
+ {
+ chars[ii] = (char)((buffer.ReadByte() & unchecked((int)(0xff))) | ((buffer.ReadByte
+ () & unchecked((int)(0xff))) << 8));
+ }
+ return new string(chars, 0, length);
+ }
+
+ public override string Read(byte[] bytes)
+ {
+ int length = bytes.Length / 2;
+ char[] chars = new char[length];
+ int j = 0;
+ for (int ii = 0; ii < length; ii++)
+ {
+ chars[ii] = (char)((bytes[j++] & unchecked((int)(0xff))) | ((bytes[j++] & unchecked(
+ (int)(0xff))) << 8));
+ }
+ return new string(chars, 0, length);
+ }
+
+ public override int ShortLength(string str)
+ {
+ return (str.Length * 2) + Const4.IntLength;
+ }
+
+ public override void Write(IWriteBuffer buffer, string str)
+ {
+ int length = str.Length;
+ char[] chars = new char[length];
+ Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0);
+ for (int i = 0; i < length; i++)
+ {
+ buffer.WriteByte((byte)(chars[i] & unchecked((int)(0xff))));
+ buffer.WriteByte((byte)(chars[i] >> 8));
+ }
+ }
+
+ public override byte[] Write(string str)
+ {
+ int length = str.Length;
+ char[] chars = new char[length];
+ Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0);
+ byte[] bytes = new byte[length * 2];
+ int j = 0;
+ for (int i = 0; i < length; i++)
+ {
+ bytes[j++] = (byte)(chars[i] & unchecked((int)(0xff)));
+ bytes[j++] = (byte)(chars[i] >> 8);
+ }
+ return bytes;
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,182 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o.Foundation;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Reflect;
+
+namespace Db4objects.Db4o.Internal
+{
+ ///
+ public sealed class EventDispatchers
+ {
+ private sealed class _IEventDispatcher_11 : IEventDispatcher
+ {
+ public _IEventDispatcher_11()
+ {
+ }
+
+ public bool Dispatch(Transaction trans, object obj, int eventID)
+ {
+ return true;
+ }
+
+ public bool HasEventRegistered(int eventID)
+ {
+ return false;
+ }
+ }
+
+ public static readonly IEventDispatcher NullDispatcher = new _IEventDispatcher_11
+ ();
+
+ private static readonly string[] events = new string[] { "objectCanDelete", "objectOnDelete"
+ , "objectOnActivate", "objectOnDeactivate", "objectOnNew", "objectOnUpdate", "objectCanActivate"
+ , "objectCanDeactivate", "objectCanNew", "objectCanUpdate" };
+
+ internal const int CanDelete = 0;
+
+ internal const int Delete = 1;
+
+ internal const int Activate = 2;
+
+ internal const int Deactivate = 3;
+
+ internal const int New = 4;
+
+ public const int Update = 5;
+
+ internal const int CanActivate = 6;
+
+ internal const int CanDeactivate = 7;
+
+ internal const int CanNew = 8;
+
+ internal const int CanUpdate = 9;
+
+ internal const int DeleteCount = 2;
+
+ internal const int Count = 10;
+
+ private class EventDispatcherImpl : IEventDispatcher
+ {
+ private readonly IReflectMethod[] methods;
+
+ public EventDispatcherImpl(IReflectMethod[] methods_)
+ {
+ methods = methods_;
+ }
+
+ public virtual bool HasEventRegistered(int eventID)
+ {
+ return methods[eventID] != null;
+ }
+
+ public virtual bool Dispatch(Transaction trans, object obj, int eventID)
+ {
+ if (methods[eventID] == null)
+ {
+ return true;
+ }
+ object[] parameters = new object[] { trans.ObjectContainer() };
+ ObjectContainerBase container = trans.Container();
+ int stackDepth = container.StackDepth();
+ int topLevelCallId = container.TopLevelCallId();
+ container.StackDepth(0);
+ try
+ {
+ object res = methods[eventID].Invoke(obj, parameters);
+ if (res is bool)
+ {
+ return ((bool)res);
+ }
+ }
+ finally
+ {
+ container.StackDepth(stackDepth);
+ container.TopLevelCallId(topLevelCallId);
+ }
+ return true;
+ }
+ }
+
+ public static IEventDispatcher ForClass(ObjectContainerBase container, IReflectClass
+ classReflector)
+ {
+ if (container == null || classReflector == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (!container.DispatchsEvents())
+ {
+ return NullDispatcher;
+ }
+ int count = EventCountFor(container);
+ if (count == 0)
+ {
+ return NullDispatcher;
+ }
+ IReflectMethod[] handlers = EventHandlerTableFor(container, classReflector);
+ return HasEventHandler(handlers) ? new EventDispatchers.EventDispatcherImpl(handlers
+ ) : NullDispatcher;
+ }
+
+ private static IReflectMethod[] EventHandlerTableFor(ObjectContainerBase container
+ , IReflectClass classReflector)
+ {
+ IReflectClass[] parameterClasses = new IReflectClass[] { container._handlers.IclassObjectcontainer
+ };
+ IReflectMethod[] methods = new IReflectMethod[Count];
+ for (int i = Count - 1; i >= 0; i--)
+ {
+ IReflectMethod method = classReflector.GetMethod(events[i], parameterClasses);
+ if (null == method)
+ {
+ method = classReflector.GetMethod(ToPascalCase(events[i]), parameterClasses);
+ }
+ if (method != null)
+ {
+ methods[i] = method;
+ }
+ }
+ return methods;
+ }
+
+ private static bool HasEventHandler(IReflectMethod[] methods)
+ {
+ return Iterators.Any(Iterators.Iterate(methods), new _IPredicate4_118());
+ }
+
+ private sealed class _IPredicate4_118 : IPredicate4
+ {
+ public _IPredicate4_118()
+ {
+ }
+
+ public bool Match(object candidate)
+ {
+ return candidate != null;
+ }
+ }
+
+ private static int EventCountFor(ObjectContainerBase container)
+ {
+ CallBackMode callbackMode = container.ConfigImpl.CallbackMode();
+ if (callbackMode == CallBackMode.All)
+ {
+ return Count;
+ }
+ if (callbackMode == CallBackMode.DeleteOnly)
+ {
+ return DeleteCount;
+ }
+ return 0;
+ }
+
+ private static string ToPascalCase(string name)
+ {
+ return Sharpen.Runtime.Substring(name, 0, 1).ToUpper() + Sharpen.Runtime.Substring
+ (name, 1);
+ }
+ }
+}
diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs
--- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs 1970-01-01 00:00:00.000000000 +0000
+++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs 2012-01-03 07:52:06.000000000 +0000
@@ -0,0 +1,732 @@
+/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */
+
+using System;
+using Db4objects.Db4o;
+using Db4objects.Db4o.Events;
+using Db4objects.Db4o.Ext;
+using Db4objects.Db4o.Internal;
+using Db4objects.Db4o.Internal.Callbacks;
+using Db4objects.Db4o.Internal.Events;
+using Db4objects.Db4o.Query;
+using Sharpen.Lang;
+
+namespace Db4objects.Db4o.Internal.Events
+{
+ ///
+ public class EventRegistryImpl : ICallbacks, IEventRegistry
+ {
+ protected System.EventHandler _queryStarted;
+
+ protected System.EventHandler _queryFinished;
+
+ protected System.EventHandler
+ _creating;
+
+ protected System.EventHandler
+ _activating;
+
+ protected System.EventHandler
+ _updating;
+
+ protected System.EventHandler
+ _deleting;
+
+ protected System.EventHandler
+ _deactivating;
+
+ protected System.EventHandler _created;
+
+ protected System.EventHandler _activated;
+
+ protected System.EventHandler _updated;
+
+ protected System.EventHandler _deleted;
+
+ protected System.EventHandler _deactivated;
+
+ protected System.EventHandler _committing;
+
+ protected System.EventHandler _committed;
+
+ protected System.EventHandler _instantiated;
+
+ protected System.EventHandler _classRegistered;
+
+ protected System.EventHandler _closing;
+
+ protected System.EventHandler _opened;
+
+ // Callbacks implementation
+ public virtual void QueryOnFinished(Transaction transaction, IQuery query)
+ {
+ if (!(_queryFinished != null))
+ {
+ return;
+ }
+ WithExceptionHandling(new _IRunnable_50(this, transaction, query));
+ }
+
+ private sealed class _IRunnable_50 : IRunnable
+ {
+ public _IRunnable_50(EventRegistryImpl _enclosing, Transaction transaction, IQuery
+ query)
+ {
+ this._enclosing = _enclosing;
+ this.transaction = transaction;
+ this.query = query;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._queryFinished) this._enclosing._queryFinished(null,
+ new QueryEventArgs(transaction, query));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly Transaction transaction;
+
+ private readonly IQuery query;
+ }
+
+ public virtual void QueryOnStarted(Transaction transaction, IQuery query)
+ {
+ if (!(_queryStarted != null))
+ {
+ return;
+ }
+ WithExceptionHandling(new _IRunnable_59(this, transaction, query));
+ }
+
+ private sealed class _IRunnable_59 : IRunnable
+ {
+ public _IRunnable_59(EventRegistryImpl _enclosing, Transaction transaction, IQuery
+ query)
+ {
+ this._enclosing = _enclosing;
+ this.transaction = transaction;
+ this.query = query;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._queryStarted) this._enclosing._queryStarted(null, new
+ QueryEventArgs(transaction, query));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly Transaction transaction;
+
+ private readonly IQuery query;
+ }
+
+ public virtual bool ObjectCanNew(Transaction transaction, object obj)
+ {
+ return TriggerCancellableObjectEventArgsInCallback(transaction, _creating, null,
+ obj);
+ }
+
+ public virtual bool ObjectCanActivate(Transaction transaction, object obj)
+ {
+ return TriggerCancellableObjectEventArgsInCallback(transaction, _activating, null
+ , obj);
+ }
+
+ public virtual bool ObjectCanUpdate(Transaction transaction, IObjectInfo objectInfo
+ )
+ {
+ return TriggerCancellableObjectEventArgsInCallback(transaction, _updating, objectInfo
+ , objectInfo.GetObject());
+ }
+
+ public virtual bool ObjectCanDelete(Transaction transaction, IObjectInfo objectInfo
+ )
+ {
+ return TriggerCancellableObjectEventArgsInCallback(transaction, _deleting, objectInfo
+ , objectInfo.GetObject());
+ }
+
+ public virtual bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo
+ )
+ {
+ return TriggerCancellableObjectEventArgsInCallback(transaction, _deactivating, objectInfo
+ , objectInfo.GetObject());
+ }
+
+ public virtual void ObjectOnActivate(Transaction transaction, IObjectInfo obj)
+ {
+ TriggerObjectInfoEventInCallback(transaction, _activated, obj);
+ }
+
+ public virtual void ObjectOnNew(Transaction transaction, IObjectInfo obj)
+ {
+ TriggerObjectInfoEventInCallback(transaction, _created, obj);
+ }
+
+ public virtual void ObjectOnUpdate(Transaction transaction, IObjectInfo obj)
+ {
+ TriggerObjectInfoEventInCallback(transaction, _updated, obj);
+ }
+
+ public virtual void ObjectOnDelete(Transaction transaction, IObjectInfo obj)
+ {
+ TriggerObjectInfoEventInCallback(transaction, _deleted, obj);
+ }
+
+ public virtual void ClassOnRegistered(ClassMetadata clazz)
+ {
+ if (!(_classRegistered != null))
+ {
+ return;
+ }
+ WithExceptionHandling(new _IRunnable_104(this, clazz));
+ }
+
+ private sealed class _IRunnable_104 : IRunnable
+ {
+ public _IRunnable_104(EventRegistryImpl _enclosing, ClassMetadata clazz)
+ {
+ this._enclosing = _enclosing;
+ this.clazz = clazz;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._classRegistered) this._enclosing._classRegistered(null,
+ new ClassEventArgs(clazz));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly ClassMetadata clazz;
+ }
+
+ public virtual void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj)
+ {
+ TriggerObjectInfoEventInCallback(transaction, _deactivated, obj);
+ }
+
+ public virtual void ObjectOnInstantiate(Transaction transaction, IObjectInfo obj)
+ {
+ TriggerObjectInfoEventInCallback(transaction, _instantiated, obj);
+ }
+
+ public virtual void CommitOnStarted(Transaction transaction, CallbackObjectInfoCollections
+ objectInfoCollections)
+ {
+ if (!(_committing != null))
+ {
+ return;
+ }
+ WithExceptionHandlingInCallback(new _IRunnable_121(this, transaction, objectInfoCollections
+ ));
+ }
+
+ private sealed class _IRunnable_121 : IRunnable
+ {
+ public _IRunnable_121(EventRegistryImpl _enclosing, Transaction transaction, CallbackObjectInfoCollections
+ objectInfoCollections)
+ {
+ this._enclosing = _enclosing;
+ this.transaction = transaction;
+ this.objectInfoCollections = objectInfoCollections;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._committing) this._enclosing._committing(null, new CommitEventArgs
+ (transaction, objectInfoCollections, false));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly Transaction transaction;
+
+ private readonly CallbackObjectInfoCollections objectInfoCollections;
+ }
+
+ public virtual void CommitOnCompleted(Transaction transaction, CallbackObjectInfoCollections
+ objectInfoCollections, bool isOwnCommit)
+ {
+ if (!(_committed != null))
+ {
+ return;
+ }
+ WithExceptionHandlingInCallback(new _IRunnable_132(this, transaction, objectInfoCollections
+ , isOwnCommit));
+ }
+
+ private sealed class _IRunnable_132 : IRunnable
+ {
+ public _IRunnable_132(EventRegistryImpl _enclosing, Transaction transaction, CallbackObjectInfoCollections
+ objectInfoCollections, bool isOwnCommit)
+ {
+ this._enclosing = _enclosing;
+ this.transaction = transaction;
+ this.objectInfoCollections = objectInfoCollections;
+ this.isOwnCommit = isOwnCommit;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._committed) this._enclosing._committed(null, new CommitEventArgs
+ (transaction, objectInfoCollections, isOwnCommit));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly Transaction transaction;
+
+ private readonly CallbackObjectInfoCollections objectInfoCollections;
+
+ private readonly bool isOwnCommit;
+ }
+
+ public virtual void CloseOnStarted(IObjectContainer container)
+ {
+ if (!(_closing != null))
+ {
+ return;
+ }
+ WithExceptionHandlingInCallback(new _IRunnable_143(this, container));
+ }
+
+ private sealed class _IRunnable_143 : IRunnable
+ {
+ public _IRunnable_143(EventRegistryImpl _enclosing, IObjectContainer container)
+ {
+ this._enclosing = _enclosing;
+ this.container = container;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._closing) this._enclosing._closing(null, new ObjectContainerEventArgs
+ (container));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly IObjectContainer container;
+ }
+
+ public virtual void OpenOnFinished(IObjectContainer container)
+ {
+ if (!(_opened != null))
+ {
+ return;
+ }
+ WithExceptionHandlingInCallback(new _IRunnable_154(this, container));
+ }
+
+ private sealed class _IRunnable_154 : IRunnable
+ {
+ public _IRunnable_154(EventRegistryImpl _enclosing, IObjectContainer container)
+ {
+ this._enclosing = _enclosing;
+ this.container = container;
+ }
+
+ public void Run()
+ {
+ if (null != this._enclosing._opened) this._enclosing._opened(null, new ObjectContainerEventArgs
+ (container));
+ }
+
+ private readonly EventRegistryImpl _enclosing;
+
+ private readonly IObjectContainer container;
+ }
+
+ public virtual event System.EventHandler QueryFinished
+ {
+ add
+ {
+ _queryFinished = (System.EventHandler)System.Delegate.Combine
+ (_queryFinished, value);
+ }
+ remove
+ {
+ _queryFinished = (System.EventHandler)System.Delegate.Remove
+ (_queryFinished, value);
+ }
+ }
+
+ public virtual event System.EventHandler QueryStarted
+ {
+ add
+ {
+ _queryStarted = (System.EventHandler)System.Delegate.Combine
+ (_queryStarted, value);
+ }
+ remove
+ {
+ _queryStarted = (System.EventHandler)System.Delegate.Remove
+ (_queryStarted, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Creating
+ {
+ add
+ {
+ _creating = (System.EventHandler
+ )System.Delegate.Combine(_creating, value);
+ }
+ remove
+ {
+ _creating = (System.EventHandler
+ )System.Delegate.Remove(_creating, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Activating
+ {
+ add
+ {
+ _activating = (System.EventHandler
+ )System.Delegate.Combine(_activating, value);
+ }
+ remove
+ {
+ _activating = (System.EventHandler
+ )System.Delegate.Remove(_activating, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Updating
+ {
+ add
+ {
+ _updating = (System.EventHandler
+ )System.Delegate.Combine(_updating, value);
+ }
+ remove
+ {
+ _updating = (System.EventHandler
+ )System.Delegate.Remove(_updating, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Deleting
+ {
+ add
+ {
+ _deleting = (System.EventHandler
+ )System.Delegate.Combine(_deleting, value);
+ }
+ remove
+ {
+ _deleting = (System.EventHandler
+ )System.Delegate.Remove(_deleting, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Deactivating
+ {
+ add
+ {
+ _deactivating = (System.EventHandler
+ )System.Delegate.Combine(_deactivating, value);
+ }
+ remove
+ {
+ _deactivating = (System.EventHandler
+ )System.Delegate.Remove(_deactivating, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Created
+ {
+ add
+ {
+ _created = (System.EventHandler)System.Delegate.Combine
+ (_created, value);
+ }
+ remove
+ {
+ _created = (System.EventHandler)System.Delegate.Remove
+ (_created, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Activated
+ {
+ add
+ {
+ _activated = (System.EventHandler)System.Delegate.Combine
+ (_activated, value);
+ }
+ remove
+ {
+ _activated = (System.EventHandler)System.Delegate.Remove
+ (_activated, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Updated
+ {
+ add
+ {
+ _updated = (System.EventHandler)System.Delegate.Combine
+ (_updated, value);
+ }
+ remove
+ {
+ _updated = (System.EventHandler)System.Delegate.Remove
+ (_updated, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Deleted
+ {
+ add
+ {
+ _deleted = (System.EventHandler)System.Delegate.Combine
+ (_deleted, value);
+ }
+ remove
+ {
+ _deleted = (System.EventHandler)System.Delegate.Remove
+ (_deleted, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Deactivated
+ {
+ add
+ {
+ _deactivated = (System.EventHandler)System.Delegate.Combine
+ (_deactivated, value);
+ }
+ remove
+ {
+ _deactivated = (System.EventHandler)System.Delegate.Remove
+ (_deactivated, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Committing
+ {
+ add
+ {
+ _committing = (System.EventHandler)System.Delegate.Combine
+ (_committing, value);
+ }
+ remove
+ {
+ _committing = (System.EventHandler)System.Delegate.Remove
+ (_committing, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Committed
+ {
+ add
+ {
+ _committed = (System.EventHandler)System.Delegate.Combine
+ (_committed, value);
+ OnCommittedListenerAdded();
+ }
+ remove
+ {
+ _committed = (System.EventHandler)System.Delegate.Remove
+ (_committed, value);
+ }
+ }
+
+ public virtual event System.EventHandler ClassRegistered
+ {
+ add
+ {
+ _classRegistered = (System.EventHandler)System.Delegate.Combine
+ (_classRegistered, value);
+ }
+ remove
+ {
+ _classRegistered = (System.EventHandler)System.Delegate.Remove
+ (_classRegistered, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Instantiated
+ {
+ add
+ {
+ _instantiated = (System.EventHandler)
+ System.Delegate.Combine(_instantiated, value);
+ }
+ remove
+ {
+ _instantiated = (System.EventHandler)
+ System.Delegate.Remove(_instantiated, value);
+ }
+ }
+
+ public virtual event System.EventHandler
+ Closing
+ {
+ add
+ {
+ _closing = (System.EventHandler)
+ System.Delegate.Combine(_closing, value);
+ }
+ remove
+ {
+ _closing = (System.EventHandler)
+ System.Delegate.Remove(_closing, value);
+ }
+ }
+
+ protected virtual void OnCommittedListenerAdded()
+ {
+ }
+
+ // do nothing
+ public virtual bool CaresAboutCommitting()
+ {
+ return (_committing != null);
+ }
+
+ public virtual bool CaresAboutCommitted()
+ {
+ return (_committed != null);
+ }
+
+ public virtual bool CaresAboutDeleting()
+ {
+ return (_deleting != null);
+ }
+
+ public virtual bool CaresAboutDeleted()
+ {
+ return (_deleted != null);
+ }
+
+ internal virtual bool TriggerCancellableObjectEventArgsInCallback(Transaction transaction
+ , System.EventHandler e, IObjectInfo objectInfo, object
+ o)
+ {
+ if (!(e != null))
+ {
+ return true;
+ }
+ CancellableObjectEventArgs args = new CancellableObjectEventArgs(transaction, objectInfo
+ , o);
+ WithExceptionHandlingInCallback(new _IRunnable_258(e, args));
+ return !args.IsCancelled;
+ }
+
+ private sealed class _IRunnable_258 : IRunnable
+ {
+ public _IRunnable_258(System.EventHandler e, CancellableObjectEventArgs
+ args)
+ {
+ this.e = e;
+ this.args = args;
+ }
+
+ public void Run()
+ {
+ if (null != e) e(null, args);
+ }
+
+ private readonly System.EventHandler e;
+
+ private readonly CancellableObjectEventArgs args;
+ }
+
+ internal virtual void TriggerObjectInfoEventInCallback(Transaction transaction, System.EventHandler<
+ ObjectInfoEventArgs> e, IObjectInfo o)
+ {
+ if (!(e != null))
+ {
+ return;
+ }
+ WithExceptionHandlingInCallback(new _IRunnable_270(e, transaction, o));
+ }
+
+ private sealed class _IRunnable_270 : IRunnable
+ {
+ public _IRunnable_270(System.EventHandler e, Transaction transaction
+ , IObjectInfo o)
+ {
+ this.e = e;
+ this.transaction = transaction;
+ this.o = o;
+ }
+
+ public void Run()
+ {
+ if (null != e) e(null, new ObjectInfoEventArgs(transaction, o));
+ }
+
+ private readonly System.EventHandler