/*!

\brief Tests if two HandleContainer object have the same content.
\param[in] Container HandleContainer to test against.
\return Returns dmz::True if the two HandleContainer objects have the same content.

*/
dmz::Boolean
dmz::HandleContainer::has_same_content (const HandleContainer &Container) const {

   Boolean result (False);

   if (get_count () == Container.get_count ()) {

      result = True;

      HandleContainerIterator it;
      Handle value;

      while (result && get_next (it, value)) {

         if (!Container.contains (value)) { result = False; }
      }
   }

   return result;
}
Example #2
0
void
dmz::JsExtV8Input::_do_callback (
      const int Argc,
      V8Value argv[],
      CallbackTable &ct,
      HandleContainer &called) {

   HashTableHandleIterator it;
   CallbackStruct *cb (0);

   while (ct.table.get_next (it, cb)) {

      if (!called.contains (it.get_hash_key ()) &&
            (cb->self.IsEmpty () == false) && (cb->func.IsEmpty () == false)) {

         // Copy self and func onto stack because CallbackStruct  may not be valid
         // after the callback is made.
         V8Object localSelf = v8::Local<v8::Object>::New (cb->self);
         V8Function localFunc = v8::Local<v8::Function>::New (cb->func);

         called.add (it.get_hash_key ());
         v8::TryCatch tc;

         argv[Argc - 1] = localSelf;
         // CallbackStruct cs may not be valid after this call and should not be
         // referenced after this point.
         localFunc->Call (localSelf, Argc, argv);

         if (tc.HasCaught ()) {

            if (_core) { _core->handle_v8_exception (it.get_hash_key (), tc); }
            _release_callback (localSelf, localFunc);
            cb = 0;
         }
      }
   }
}
Example #3
0
void
dmz::ObjectModuleGridBasic::update_object_position (
      const UUID &Identity,
      const Handle ObjectHandle,
      const Handle AttributeHandle,
      const Vector &Value,
      const Vector *PreviousValue) {

   ObjectStruct *current (_objTable.lookup (ObjectHandle));

   if (current && _grid) {

      current->pos = Value;

      const Int32 OldPlace = current->place;
      const Int32 Place = _map_point (Value);

      if (Place != current->place) {

         _remove_object_from_grid (*current);
         current->place = Place;
         _grid[Place].objTable.store (current->Object, current);
      }

      if ((Place != OldPlace) && (OldPlace >= 0)) {

         HashTableHandleIterator it;
         GridStruct *cell = &(_grid[OldPlace]);
         ObserverStruct *os = cell->obsTable.get_first (it);
         HandleContainer tested;

         while (os) {

            tested.add_handle (os->ObsHandle);
            _update_observer (
               os->obs.get_observer_volume (),
               *current,
               *os);

            os = cell->obsTable.get_next (it);
         }

         cell = &(_grid[Place]);
         os = cell->obsTable.get_first (it);

         while (os) {

            if (!tested.contains (os->ObsHandle)) {

               _update_observer (
                  os->obs.get_observer_volume (),
                  *current,
                  *os);
            }

            os = cell->obsTable.get_next (it);
         }
      }
      else {

         HashTableHandleIterator it;
         GridStruct *cell = &(_grid[Place]);
         ObserverStruct *os = cell->obsTable.get_first (it);

         while (os) {

            _update_observer (
               os->obs.get_observer_volume (),
               *current,
               *os);

            os = cell->obsTable.get_next (it);
         }
      }
   }
}