Regenerated our DObject derivations in the new world order.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3288 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-12-28 03:51:29 +00:00
parent d27b150365
commit 55a0ab91f7
23 changed files with 273 additions and 1096 deletions
@@ -1,78 +0,0 @@
//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.data;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DSet;
/**
* Every client in the system has an associated client object to which
* only they subscribe. The client object can be used to deliver messages
* solely to a particular client as well as to publish client-specific
* data.
*/
public class ClientObject extends DObject
{
/** The name of a message event delivered to the client when they
* switch usernames (and therefore user objects). */
public static final String CLOBJ_CHANGED = "!clobj_changed!";
/** Used to publish all invocation service receivers registered on
* this client. */
public DSet receivers = new DSet();
/**
* Returns a short string identifying this client.
*/
public String who ()
{
return "(" + getOid() + ")";
}
/**
* Used for reference counting client objects, adds a reference to
* this object.
*/
public synchronized void reference ()
{
_references++;
// Log.info("Incremented references [who=" + who() +
// ", refs=" + _references + "].");
}
/**
* Used for reference counting client objects, releases a reference to
* this object.
*
* @return true if the object has remaining references, false
* otherwise.
*/
public synchronized boolean release ()
{
// Log.info("Decremented references [who=" + who() +
// ", refs=" + (_references-1) + "].");
return (--_references > 0);
}
/** Used to reference count resolved client objects. */
protected transient int _references;
}
@@ -32,8 +32,10 @@ import com.threerings.presents.dobj.DSet;
*/
public class ClientObject extends DObject
{
// AUTO-GENERATED: FIELDS START
/** The field name of the <code>receivers</code> field. */
public static final String RECEIVERS = "receivers";
// AUTO-GENERATED: FIELDS END
/** The name of a message event delivered to the client when they
* switch usernames (and therefore user objects). */
@@ -79,6 +81,7 @@ public class ClientObject extends DObject
/** Used to reference count resolved client objects. */
protected transient int _references;
// AUTO-GENERATED: METHODS START
/**
* Requests that the specified entry be added to the
* <code>receivers</code> set. The set will not change until the event is
@@ -86,7 +89,7 @@ public class ClientObject extends DObject
*/
public void addToReceivers (DSet.Entry elem)
{
requestEntryAdd(RECEIVERS, elem);
requestEntryAdd(RECEIVERS, receivers, elem);
}
/**
@@ -96,7 +99,7 @@ public class ClientObject extends DObject
*/
public void removeFromReceivers (Comparable key)
{
requestEntryRemove(RECEIVERS, key);
requestEntryRemove(RECEIVERS, receivers, key);
}
/**
@@ -106,7 +109,7 @@ public class ClientObject extends DObject
*/
public void updateReceivers (DSet.Entry elem)
{
requestEntryUpdate(RECEIVERS, elem);
requestEntryUpdate(RECEIVERS, receivers, elem);
}
/**
@@ -121,7 +124,8 @@ public class ClientObject extends DObject
*/
public void setReceivers (DSet receivers)
{
requestAttributeChange(RECEIVERS, receivers);
requestAttributeChange(RECEIVERS, receivers, this.receivers);
this.receivers = receivers;
}
// AUTO-GENERATED: METHODS END
}
@@ -1,5 +1,5 @@
//
// $Id: InvocationObject.java,v 1.5 2004/08/27 02:20:19 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -1,122 +0,0 @@
//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.data;
import com.threerings.presents.dobj.DObject;
/**
* Used to communicate time bases to clients so that more efficient delta
* times can be transmitted over the network. Two time stamps are
* maintained: even and odd. When the even time base is sufficiently old
* that our delta time container (usually a short or an int) will exceed
* its maximum value, we switch to the odd time base. The bouncing between
* two separate values prevents problems from arising when the base time
* is changed, yet values using the old base time might still be
* propagating through the system.
*
* <p> Note that for sufficiently small delta time containers, stale
* values could still linger longer than the time required for two swaps
* (two byte delta stamps for example, must swap every 30 seconds).
*/
public class TimeBaseObject extends DObject
{
/** The even time base, used to decode even delta times. */
public long evenBase;
/** The odd time base, used to decode odd delta times. */
public long oddBase;
/**
* Converts the supplied time stamp into a time delta (measured
* relative to the appropriate time base, even or odd) with maximum
* value of 2^15. (One bit must be used to indicate that it is an even
* or odd time stamp).
*/
public short toShortDelta (long timeStamp)
{
return (short)getDelta(timeStamp, Short.MAX_VALUE);
}
/**
* Converts the supplied time stamp into a time delta (measured
* relative to the appropriate time base, even or odd) with maximum
* value of 2^31. (One bit must be used to indicate that it is an even
* or odd time stamp).
*/
public int toIntDelta (long timeStamp)
{
return (int)getDelta(timeStamp, Integer.MAX_VALUE);
}
/**
* Converts the supplied delta time back to a wall time based on the
* base time in this time base object. Either an int or short delta
* can be passed to this method (the short will have been promoted to
* an int in the process but that will not mess up its encoded value).
*/
public long fromDelta (int delta)
{
boolean even = (delta > 0);
long time = even ? evenBase : oddBase;
if (even) {
time += delta;
} else {
time += (-1 - delta);
}
return time;
}
/**
* Obtains a delta with the specified maximum value, swapping from
* even to odd, if necessary.
*/
protected long getDelta (long timeStamp, long maxValue)
{
boolean even = (evenBase > oddBase);
long base = even ? evenBase : oddBase;
long delta = timeStamp - base;
// make sure this timestamp is not sufficiently old that we can't
// generate a delta time with it
if (delta < 0) {
String errmsg = "Time stamp too old for conversion to delta time";
throw new IllegalArgumentException(errmsg);
}
// see if it's time to swap
if (delta > maxValue) {
if (even) {
setOddBase(timeStamp);
} else {
setEvenBase(timeStamp);
}
delta = 0;
}
// if we're odd, we need to mark the value as such
if (!even) {
delta = (-1 - delta);
}
return delta;
}
}
@@ -39,11 +39,13 @@ import com.threerings.presents.dobj.DObject;
*/
public class TimeBaseObject extends DObject
{
// AUTO-GENERATED: FIELDS START
/** The field name of the <code>evenBase</code> field. */
public static final String EVEN_BASE = "evenBase";
/** The field name of the <code>oddBase</code> field. */
public static final String ODD_BASE = "oddBase";
// AUTO-GENERATED: FIELDS END
/** The even time base, used to decode even delta times. */
public long evenBase;
@@ -126,31 +128,37 @@ public class TimeBaseObject extends DObject
return delta;
}
// AUTO-GENERATED: METHODS START
/**
* Requests that the <code>evenBase</code> field be set to the specified
* value. The local value will be updated immediately and an event
* will be propagated through the system to notify all listeners that
* the attribute did change. Proxied copies of this object (on
* Requests that the <code>evenBase</code> field be set to the
* specified value. The local value will be updated immediately and an
* event will be propagated through the system to notify all listeners
* that the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setEvenBase (long evenBase)
public void setEvenBase (long value)
{
requestAttributeChange(EVEN_BASE, new Long(evenBase));
this.evenBase = evenBase;
long ovalue = this.evenBase;
requestAttributeChange(
EVEN_BASE, new Long(value), new Long(ovalue));
this.evenBase = value;
}
/**
* Requests that the <code>oddBase</code> field be set to the specified
* value. The local value will be updated immediately and an event
* will be propagated through the system to notify all listeners that
* the attribute did change. Proxied copies of this object (on
* Requests that the <code>oddBase</code> field be set to the
* specified value. The local value will be updated immediately and an
* event will be propagated through the system to notify all listeners
* that the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setOddBase (long oddBase)
public void setOddBase (long value)
{
requestAttributeChange(ODD_BASE, new Long(oddBase));
this.oddBase = oddBase;
long ovalue = this.oddBase;
requestAttributeChange(
ODD_BASE, new Long(value), new Long(ovalue));
this.oddBase = value;
}
// AUTO-GENERATED: METHODS END
}