<commit_before>//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2011 Three Rings Design, Inc., All Rights Reserved
// http://code.google.com/p/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.dobj;

import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import com.samskivert.util.ArrayUtil;
import com.samskivert.util.ListUtil;
import com.samskivert.util.StringUtil;

import com.threerings.io.Streamable;

import com.threerings.presents.net.Transport;

import static com.threerings.presents.Log.log;

/**
 * The distributed object forms the foundation of the Presents system. All information shared among
 * users of the system is done via distributed objects. A distributed object has a set of
 * listeners. These listeners have access to the object or a proxy of the object and therefore have
 * access to the data stored in the object's members at all times.
 *
 * <p> Additionally, an object has a set of subscribers. Subscribers manage the lifespan of the
 * object; while a subscriber is subscribed, the listeners registered with an object will be
 * notified of events. When the subscriber unsubscribes, the object becomes non-live and the
 * listeners are no longer notified. <em>Note:</em> on the server, object subscription is merely a
 * formality as all objects remain live all the time, so <em>do not</em> depend on event
 * notifications ceasing when a subscriber has relinquished its subscription. Always unregister all
 * listeners when they no longer need to hear from an object.
 *
 * <p> When there is any change to the the object's fields data, an event is generated which is
 * dispatched to all listeners of the object, notifying them of that change and effecting that
 * change to the copy of the object maintained at each client. In this way, both a repository of
 * shared information and a mechanism for asynchronous notification are made available as a
 * fundamental application building blocks.
 *
 * <p> To define what information is shared, an application creates a distributed object
 * declaration which is much like a class declaration except that it is transformed into a proper
 * derived class of <code>DObject</code> by a script. A declaration looks something like this:
 *
 * <pre>
 * public dclass RoomObject
 * {
 *     public String description;
 *     public int[] occupants;
 * }
 * </pre>
 *
 * which is converted into an actual Java class that looks like this:
 *
 * <pre>
 * public class RoomObject extends DObject
 * {
 *     public String getDescription ()
 *     {
 *         // ...
 *     }
 *
 *     public void setDescription (String description)
 *     {
 *         // ...
 *     }
 *
 *     public int[] getOccupants ()
 *     {
 *         // ...
 *     }
 *
 *     public void setOccupants (int[] occupants)
 *     {
 *         // ...
 *     }
 *
 *     public void setOccupantsAt (int index, int value)
 *     {
 *         // ...
 *     }
 * }
 * </pre>
 *
 * These method calls on the actual distributed object will result in the proper attribute change
 * events being generated and dispatched.
 *
 * <p> Note that distributed object fields can be any of the following set of primitive types:
 *
 * <code><pre>
 * boolean, byte, short, int, long, float, double
 * Boolean, Byte, Short, Integer, Long, Float, Double, String
 * boolean[], byte[], short[], int[], long[], float[], double[], String[]
 * </pre></code>
 *
 * Fields of type {@link Streamable} can also be used.
 */
public class DObject
    implements Streamable
{
    public DObject ()
    {
        _accessors = _atable.get(getClass());
        if (_accessors == null) {
            _accessors = createAccessors();
            Arrays.sort(_accessors);
            _atable.put(getClass(), _accessors);
        }
    }

    /**
     * Returns the object id of this object. All objects in the system have a unique object id.
     */
    public int getOid ()
    {
        return _oid;
    }

    /**
     * Returns the dobject manager under the auspices of which this object operates. This could be
     * <code>null</code> if the object is not active.
     */
    public DObjectManager getManager ()
    {
        return _omgr;
    }<commit_msg>Tidied up some really ancient and really incorrect documentation.<commit_after>//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2011 Three Rings Design, Inc., All Rights Reserved
// http://code.google.com/p/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.dobj;

import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import com.samskivert.util.ArrayUtil;
import com.samskivert.util.ListUtil;
import com.samskivert.util.StringUtil;

import com.threerings.io.Streamable;

import com.threerings.presents.net.Transport;

import static com.threerings.presents.Log.log;

/**
 * The distributed object forms the foundation of the Presents system. All information shared among
 * users of the system is done via distributed objects. A distributed object has a set of
 * listeners. These listeners have access to the object or a proxy of the object and therefore have
 * access to the data stored in the object's members at all times.
 *
 * <p> Additionally, an object has a set of subscribers. Subscribers manage the lifespan of the
 * object; while a subscriber is subscribed, the listeners registered with an object will be
 * notified of events. When the subscriber unsubscribes, the object becomes non-live and the
 * listeners are no longer notified. <em>Note:</em> on the server, object subscription is merely a
 * formality as all objects remain live all the time, so <em>do not</em> depend on event
 * notifications ceasing when a subscriber has relinquished its subscription. Always unregister all
 * listeners when they no longer need to hear from an object.
 *
 * <p> When there is any change to the the object's properties (which must be effected via the
 * setter methods), an event is generated which is dispatched to all listeners of the object,
 * notifying them of that change and effecting that change to the copy of the object maintained at
 * each client. In this way, both a repository of shared information and a mechanism for
 * asynchronous notification are made available as a fundamental application building blocks.
 *
 * <p> Distributed object fields can be any of the following set of primitive types:
 * <pre>{@code
 * boolean, byte, short, int, long, float, double
 * Boolean, Byte, Short, Integer, Long, Float, Double, String
 * boolean[], byte[], short[], int[], long[], float[], double[], String[]
 * }</pre>
 * as well as custom types that implement {@link Streamable}.
 */
public class DObject
    implements Streamable
{
    public DObject ()
    {
        _accessors = _atable.get(getClass());
        if (_accessors == null) {
            _accessors = createAccessors();
            Arrays.sort(_accessors);
            _atable.put(getClass(), _accessors);
        }
    }

    /**
     * Returns the object id of this object. All objects in the system have a unique object id.
     */
    public int getOid ()
    {
        return _oid;
    }

    /**
     * Returns the dobject manager under the auspices of which this object operates. This could be
     * <code>null</code> if the object is not active.
     */
    public DObjectManager getManager ()
    {
        return _omgr;
    }
{'fraction_non_alphanumeric': 0.08560394765071873, 'fraction_numerical': 0.005149109633125939, 'mean_word_length': 3.25125398996808, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008563', 'n_tokens_mistral': 2527, 'n_tokens_neox': 2457, 'n_words': 1140}