void OHLocationServiceCache::notifyLocationUpdated(const ObjectReference& uuid, const TimedMotionVector3f& oldval, const TimedMotionVector3f& newval) {
    Lock lck(mMutex);
    for(ListenerSet::iterator listener_it = mListeners.begin(); listener_it != mListeners.end(); listener_it++)
        (*listener_it)->locationPositionUpdated(uuid, oldval, newval);
    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
void OHLocationServiceCache::notifyObjectRemoved(const ObjectReference& uuid) {
    Lock lck(mMutex);
    for(ListenerSet::iterator listener_it = mListeners.begin(); listener_it != mListeners.end(); listener_it++)
        (*listener_it)->locationDisconnected(uuid);
    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
Esempio n. 3
0
void ReplicatedLocationServiceCache::stopRefcountTracking(const ObjectID& id) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(id);
    assert (it != mObjects.end());

    it->second.tracking--;
    tryRemoveObject(it);
}
void OHLocationServiceCache::notifyBoundsUpdated(const ObjectReference& uuid, const BoundingSphere3f& oldval, const BoundingSphere3f& newval) {
    Lock lck(mMutex);
    for(ListenerSet::iterator listen_it = mListeners.begin(); listen_it != mListeners.end(); listen_it++) {
        (*listen_it)->locationRegionUpdated(uuid, regionFromBounds(oldval), regionFromBounds(newval));
        (*listen_it)->locationMaxSizeUpdated(uuid, maxSizeFromBounds(oldval), maxSizeFromBounds(newval));
    }
    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
void OHLocationServiceCache::notifyObjectAdded(
    const ObjectReference& uuid, const TimedMotionVector3f& loc,
    const BoundingSphere3f& bounds
) {
    Lock lck(mMutex);
    for(ListenerSet::iterator listener_it = mListeners.begin(); listener_it != mListeners.end(); listener_it++)
        (*listener_it)->locationConnected(uuid, true, loc, regionFromBounds(bounds), maxSizeFromBounds(bounds));
    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
Esempio n. 6
0
void ReplicatedLocationServiceCache::notifyPhysicsUpdated(Liveness::Token alive_token, const ObjectReference& uuid) {
    Liveness::Lock alive(alive_token);
    if (!alive) return;

    Lock lck(mMutex);

    ReplicatedLocationUpdateProvider::notify(&ReplicatedLocationUpdateListener::onPhysicsUpdated, this, uuid);

    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
void CBRLocationServiceCache::processObjectRemoved(const ObjectReference& uuid, bool agg) {
    if (!agg) {
        Lock lck(mListenerMutex);
        for(ListenerSet::iterator it = mListeners.begin(); it != mListeners.end(); it++)
            (*it)->locationDisconnected(uuid);
    }

    {
        Lock lck(mDataMutex);
        ObjectDataMap::iterator data_it = mObjects.find(uuid);
        data_it->second.tracking--;
        tryRemoveObject(data_it);
    }
}
void CBRLocationServiceCache::stopRefcountTracking(const ObjectID& objid) {
    Lock lck(mDataMutex);

    ObjectDataMap::iterator it = mObjects.find(objid);
    if (it == mObjects.end()) {
        printf("Warning: stopped tracking unknown object\n");
        return;
    }
    if (it->second.tracking <= 0) {
        printf("Warning: stopped tracking untracked object\n");
    }
    it->second.tracking--;
    tryRemoveObject(it);
}
void CBRLocationServiceCache::processObjectRemoved(const UUID& uuid, bool agg) {
    Lock lck(mMutex);

    ObjectDataMap::iterator data_it = mObjects.find(uuid);
    if (data_it == mObjects.end()) return;

    assert(data_it->second.exists);
    data_it->second.exists = false;

    tryRemoveObject(data_it);

    if (!agg)
        for(ListenerSet::iterator it = mListeners.begin(); it != mListeners.end(); it++)
            (*it)->locationDisconnected(uuid);
}
Esempio n. 10
0
void ReplicatedLocationServiceCache::notifyParentUpdated(Liveness::Token alive_token, const ObjectReference& uuid, const ObjectReference& oldval, const ObjectReference& newval) {
    Liveness::Lock alive(alive_token);
    if (!alive) return;

    Lock lck(mMutex);

    for(ListenerSet::iterator listener_it = mListeners.begin(); listener_it != mListeners.end(); listener_it++)
        (*listener_it)->locationParentUpdated(uuid, oldval, newval);

    ReplicatedLocationUpdateProvider::notify(&ReplicatedLocationUpdateListener::onParentUpdated, this, uuid);

    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
void CBRLocationServiceCache::processObjectAdded(const ObjectReference& uuid, ObjectData data) {
    // TODO(ewencp) at some point, we might want to (optionally) use aggregates
    // here, especially if we're reconstructing entire trees.
    if (!data.isAggregate) {
        Lock lck(mListenerMutex);
        for(ListenerSet::iterator it = mListeners.begin(); it != mListeners.end(); it++)
            (*it)->locationConnected(uuid, false, data.isLocal, data.location, data.bounds.centerBounds(), data.bounds.maxObjectRadius);
    }

    {
        Lock lck(mDataMutex);

        ObjectDataMap::iterator data_it = mObjects.find(uuid);
        data_it->second.tracking--;
        tryRemoveObject(data_it);
    }
}
Esempio n. 12
0
void ReplicatedLocationServiceCache::notifyBoundsUpdated(Liveness::Token alive_token, const ObjectReference& uuid, const AggregateBoundingInfo& oldval, const AggregateBoundingInfo& newval) {
    Liveness::Lock alive(alive_token);
    if (!alive) return;

    Lock lck(mMutex);

    for(ListenerSet::iterator listen_it = mListeners.begin(); listen_it != mListeners.end(); listen_it++) {
        (*listen_it)->locationRegionUpdated(uuid, oldval.centerBounds(), newval.centerBounds());
        (*listen_it)->locationMaxSizeUpdated(uuid, oldval.maxObjectRadius, newval.maxObjectRadius);
    }

    ReplicatedLocationUpdateProvider::notify(&ReplicatedLocationUpdateListener::onBoundsUpdated, this, uuid);

    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
Esempio n. 13
0
void CBRLocationServiceCache::stopTracking(const Iterator& id) {
    Lock lck(mMutex);

    // In this special case, we ignore the true iterator and do the lookup.
    // This is necessary because ordering problems can cause the iterator to
    // become invalidated.
    IteratorData* itdat = (IteratorData*)id.data;

    ObjectDataMap::iterator it = mObjects.find(itdat->objid);
    if (it == mObjects.end()) {
        printf("Warning: stopped tracking unknown object\n");
        return;
    }
    if (it->second.tracking <= 0) {
        printf("Warning: stopped tracking untracked object\n");
    }
    it->second.tracking--;
    tryRemoveObject(it);
}
Esempio n. 14
0
void ReplicatedLocationServiceCache::notifyObjectAdded(
    Liveness::Token alive_token,
    const ObjectReference& uuid,
    const ObjectReference& parent, bool agg,
    const TimedMotionVector3f& loc,
    const AggregateBoundingInfo& bounds
) {
    Liveness::Lock alive(alive_token);
    if (!alive) return;

    Lock lck(mMutex);

    for(ListenerSet::iterator listener_it = mListeners.begin(); listener_it != mListeners.end(); listener_it++)
        (*listener_it)->locationConnectedWithParent(uuid, parent, agg, true, loc, bounds.centerBounds(), bounds.maxObjectRadius);

    ReplicatedLocationUpdateProvider::notify(&ReplicatedLocationUpdateListener::onObjectAdded, this, uuid);

    ObjectDataMap::iterator obj_it = mObjects.find(uuid);
    obj_it->second.tracking--;
    tryRemoveObject(obj_it);
}
Esempio n. 15
0
void OHLocationServiceCache::objectRemoved(const ObjectReference& uuid) {
    Lock lck(mMutex);

    ObjectDataMap::iterator data_it = mObjects.find(uuid);
    if (data_it == mObjects.end()) return;

    assert(data_it->second.exists);
    data_it->second.exists = false;
    bool agg = data_it->second.aggregate;

    tryRemoveObject(data_it);

    if (!agg) {
        data_it->second.tracking++;
        mStrand->post(
            std::tr1::bind(
                &OHLocationServiceCache::notifyObjectRemoved, this,
                uuid
            ),
            "OHLocationServiceCache::notifyObjectRemoved"
        );
    }
}