void
dmz::InputPluginMouseEventToMessage::_get_targets (
      const String &Name,
      Config &config,
      HandleContainer &targets) {

   Config targetList;

   if (config.lookup_all_config (Name, targetList)) {

      ConfigIterator it;
      Config targetConfig;

      while (targetList.get_next_config (it, targetConfig)) {

         const String TargetName (config_to_string ("name", targetConfig));

         if (TargetName) {

            const Handle Target (_defs.create_named_handle (TargetName));
            targets.add (Target);
         }
         else { _log.error << "Unable to add unnamed target" << endl; }
      }
   }
   else if ((&targets) != (&_targetTable)) { targets = _targetTable; }
}
   // RuntimeModule Interface
   virtual void get_plugin_list (HandleContainer &container) {

      HashTableHandleIterator it;
      PluginStruct *ps (0);
   
      while (pluginTable.get_next (it, ps)) {

         container.add (it.get_hash_key ());
      }
   }
Example #3
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;
         }
      }
   }
}
/*!

\brief Converts Config to a HandleContainer.
\details Defined in dmzRuntimeConfigToNamedHandle.h.
\code
dmz::HandleContainer value = dmz::config_to_handle_container ("dmz.handle", global);
\endcode
The Config for the above example would be formatted as follows:
\code
<dmz>
   <handle name="dmzToolPluginFoo"/>
   <handle name="dmzToolPluginBar"/>
</dmz>
\endcode
\param[in] Name String containing name of config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] context Pointer to the runtime context.
\return Returns dmz::HandleContainer of the named Handle values.

*/
dmz::HandleContainer
dmz::config_to_handle_container (
      const String &Name,
      const Config &Source,
      RuntimeContext *context) {

   HandleContainer result;
   Definitions defs (context);

   Config nameList;

   if (Name) { Source.lookup_all_config (Name, nameList); }
   else { Source.lookup_all_config ("handle", nameList); }

   ConfigIterator it;
   Config name;

   while (nameList.get_next_config (it, name)) {

      result.add (defs.create_named_handle (config_to_string ("name", name)));
   }

   return result;
}
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 (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);
         }
      }
   }
}
void
dmz::ObjectModuleGridBasic::find_objects (
      const Volume &SearchSpace,
      HandleContainer &objects,
      const ObjectTypeSet *IncludeTypes,
      const ObjectTypeSet *ExcludeTypes) {

   Vector origin, min, max;
   SearchSpace.get_extents (origin, min, max);
   Int32 minX = 0, minY = 0, maxX = 0, maxY = 0;
   _map_point_to_coord (min, minX, minY);
   _map_point_to_coord (max, maxX, maxY);

   ObjectStruct *list (0);

//   HandleContainer found;

   for (Int32 ix = minX; ix <= maxX; ix++) {

      for (Int32 jy = minY; jy <= maxY; jy++) {

         HashTableHandleIterator it;
         GridStruct *cell = &(_grid[_map_coord (ix, jy)]);
         ObjectStruct *current = cell->objTable.get_first (it);

         while (current) {

            Boolean test (True);

            if (IncludeTypes && !IncludeTypes->contains_type (current->Type)) {

               test = False;
            }
            else if (ExcludeTypes && ExcludeTypes->contains_type (current->Type)) {

               test = False;
            }

            if (test && SearchSpace.contains_point (current->pos)) {

#if 0
if (!found.add_handle (current->Object)) {

_log.error << "origin: " << origin << endl
   << "minX: " << minX << endl
   << "minY: " << minY << endl
   << "maxX: " << maxX << endl
   << "maxY: " << maxY << endl;


HandleContainer cc;
   for (Int32 xx = minX; xx <= maxX; xx++) {

      for (Int32 yy = minY; yy <= maxY; yy++) {
Boolean s = cc.add_handle ((Handle)_map_coord (xx, yy));
_log.error << (s ? "" : "##### NOT UNIQUE ") << xx << " " << yy << " = " << _map_coord (xx, yy) << endl;
      }
   }
}
#endif // 0

               current->distanceSquared = (origin - current->pos).magnitude_squared ();

               current->next = 0;

               if (!list) { list = current; }
               else {

                  ObjectStruct *p = 0, *c = list;

                  Boolean done (False);

                  while (!done) {

                     if (c->distanceSquared > current->distanceSquared) {

                        if (!c->next) { c->next = current; done = True; }
                        else {

                           p = c; c = c->next;

                           if (!c) { p->next = current; done = True; }
                        }
                     }
                     else {

                        if (p) { p->next = current; }
                        else { list = current; }

                        current->next = c;
                        done = True;
                     }
                  }
               }
            }

            current = cell->objTable.get_next (it);
         }
      }
   }

   while (list) {

      if (!objects.add (list->Object)) {

         _log.error << "Loop detected in object list for object: " << list->Object
            << endl;
         list = 0;
      }
      else { list = list->next; }
   }
}