virtual Boolean add_plugins (PluginContainer &container) {

      Boolean result (True);

      HandleContainer pluginList;

      container.get_plugin_list (pluginList);

      Handle plugin = pluginList.get_first ();

      while (plugin) {

         PluginInfo *infoPtr = container.lookup_plugin_info (plugin);
         Plugin *pluginPtr = container.lookup_plugin (plugin);

         if (container.release_plugin (plugin)) {

            if (!add_plugin (infoPtr, pluginPtr)) { 

               result = False;

               if (container.add_plugin (infoPtr, pluginPtr)) {

                  container.remove_plugin (plugin);
               }
            }
         }

         plugin = pluginList.get_next ();
      }

      return result;
   }
Example #2
0
// ArchiveObserver Interface.
void
dmz::ArchivePluginObject::create_archive (
      const Handle ArchiveHandle,
      const Int32 Version,
      Config &local,
      Config &global) {

   ObjectModule *objMod (get_object_module ());

   if (objMod) {

      _currentFilterList = _filterTable.lookup (ArchiveHandle);

      HandleContainer container;

      objMod->get_object_handles (container);

      Handle object = container.get_first ();

      while (object) {

         Config objArchive = _archive_object (object);

         if (!objArchive.is_empty ()) {

            local.add_config (objArchive);
         }

         object = container.get_next ();
      }

      _currentFilterList = 0;
   }
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_set_component_hide_state (
      const Handle Obj,
      const Boolean Value,
      ObjectModule &objMod) {

   objMod.store_flag (Obj, _hideAttrHandle, Value);

   HandleContainer list;

   if (objMod.lookup_sub_links (Obj, _linkAttrHandle, list)) {

      Handle child = list.get_first ();

      while (child) {

         _set_component_hide_state (child, Value, objMod);
         child = list.get_next ();
      }
   }

   if (objMod.lookup_sub_links (Obj, _logicAttrHandle, list)) {

      Handle child = list.get_first ();

      while (child) {

         objMod.store_flag (child, _hideAttrHandle, Value);
         child = list.get_next ();
      }
   }
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_update_tree (
      const Handle SuperHandle,
      const Handle SubHandle,
      const Int32 Column,
      Int32 &count) {

   ObjectModule *objMod (get_object_module ());

   if (objMod && SuperHandle && SubHandle) {

      Vector rootPos (0.0, 0.0, 0.0);

      Vector superPos;
      objMod->lookup_position (SuperHandle, _defaultAttrHandle, superPos);

      Vector offset ((Column * _hOffset), 0.0, (count * _vOffset));
      Vector topPos (rootPos + offset);

      HandleContainer children;
      objMod->lookup_sub_links (SubHandle, _linkAttrHandle, children);

      if (children.get_count ()) {

         Int32 startCount (count);

         Handle current (children.get_first ());

         while (current) {

            _update_tree (SubHandle, current, Column + 1, count);

            current = children.get_next ();
         }

         Int32 endCount (count);

         offset.set_xyz (0.0, 0.0, ((endCount - startCount - 1) * 0.5f * _vOffset));
         objMod->store_position (SubHandle, _defaultAttrHandle, topPos + offset);

         _update_logic (SubHandle);

         _update_path (SubHandle);
      }
      else {

         offset.set_xyz ((Column * _hOffset), 0.0, (count * _vOffset));
         objMod->store_position (SubHandle, _defaultAttrHandle, rootPos + offset);

         count++;
      }
   }
}
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; }
}
void
dmz::InputPluginMouseEventToMessage::_send (
      const Message &Msg,
      HandleContainer &targets) {

   if (Msg) {

      Handle target (targets.get_first ());

      while (target) {

         Msg.send (target, 0, 0);
         target = targets.get_next ();
      }
   }
}
Example #7
0
dmz::Handle
dmz::EventModuleCommonBasic::_get_source (const Handle ObjectHandle) {

   Handle result (0);

   if (_objMod) {

      HandleContainer links;

      if (_objMod->lookup_super_links (ObjectHandle, _sourceHandle, links)) {

         result = links.get_first ();
      }
   }

   return result;
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_update_path (const Handle Object) {

   ObjectModule *objMod (get_object_module ());

   if (objMod && Object) {

      Vector rootPos;
      objMod->lookup_position (Object, _defaultAttrHandle, rootPos);
      const QPointF RootPoint (rootPos.get_x (), rootPos.get_z ());

      Vector logicPos (
         rootPos.get_x () + (0.5f * _hOffset),
         rootPos.get_y (),
         rootPos.get_z ());

      const QPointF LogicPoint (logicPos.get_x (), logicPos.get_z ());

      _path.moveTo (RootPoint);
      _path.lineTo (LogicPoint);

      HandleContainer children;
      objMod->lookup_sub_links (Object, _linkAttrHandle, children);

      if (children.get_count ()) {

         Vector pos;
         Handle current (children.get_first ());

         while (current) {

            Vector pos;
            objMod->lookup_position (current, _defaultAttrHandle, pos);
            QPointF end (pos.get_x (), pos.get_z ());

            _path.moveTo (LogicPoint);
            _path.lineTo (LogicPoint.x (), end.y ());
            _path.lineTo (end);

            current = children.get_next ();
         }
      }
   }
}
   // 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 ());
      }
   }
void
dmz::MBRAPluginFaultTreeAutoLayout::_update_tree () {

   ObjectModule *objMod (get_object_module ());

   if (objMod && _root) {

      HandleContainer children;

      objMod->lookup_sub_links (_root, _linkAttrHandle, children);

      _path = QPainterPath ();

      Int32 count (0);

      Handle current (children.get_first ());

      while (current) {

         _update_tree (_root, current, 1, count);

         current = children.get_next ();
      }

      Vector offset (0.0, 0.0, 0.0);

      if (count) {

         offset.set_z ((count - 1) * 0.5f * _vOffset);
      }

      objMod->store_position (_root, _defaultAttrHandle, offset);

      _update_logic (_root);

      if (children.get_count ()) {

         _update_path (_root);
      }

      if (_pathItem) { _pathItem->setPath (_path); }
   }
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_update_logic (const Handle Parent) {

   ObjectModule *objMod (get_object_module ());

   if (objMod) {

      HandleContainer logic;
      objMod->lookup_sub_links (Parent, _logicAttrHandle, logic);

      if (logic.get_count ()) {

         Vector pos;
         objMod->lookup_position (Parent, _defaultAttrHandle, pos);

         pos.set_x (pos.get_x () + (_hOffset * 0.5f));
         objMod->store_position (logic.get_first (), _defaultAttrHandle, pos);
      }
   }
}
/*!

\brief Relational "equal to" operator.
\details Test that each container has the same content and that the content is
stored in the same order.
\param[in] Container HandleContainer to test against.
\return Returns dmz::True if the two HandleContainer objects have the same content stored
in the same order.

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

   Boolean result (False);

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

      result = True;

      HandleContainerIterator it1, it2;
      Handle v1, v2;

      while (result && get_next (it1, v1) && Container.get_next (it2, v2)) {

         if (v1 != v2) { result = False; }
      }
   }

   return result;
}
/*!

\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 #14
0
/*!

\brief Sends the message to multiple targets.
\param[in] Targets HandleContainer of unique handles of message observers to send message.
\param[in] InData Pointer to the data object that is sent along with the message. May
be NULL if no data is to be sent.
\param[out] outData Pointer to Data object that will be used by the target
message observer to return results. This parameter may be NULL if no data is to be
returned.
\return Returns an id associated with the sent message. This id is not a unique
runtime handle but is instead a running counter that will roll over when max unsigned
integer messages have been sent.

*/
dmz::UInt32
dmz::Message::send (
      const HandleContainer &Targets,
      const Data *InData,
      Data *outData) const {

   UInt32 result (0);
   
   if (_context && _context->context) {

      Handle target (Targets.get_first ());

      while (target) {

         result = _context->context->send (*this, target, InData, outData);

         target = Targets.get_next ();
      }
   }

   return result;
}
Example #15
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 #16
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;
}
Example #17
0
/*!

\brief Sends the message to multiple targets.
\param[in] Targets HandleContainer of unique handles of message observers to send message.
\param[in] InData Pointer to the data object that is sent along with the message. May
be NULL if no data is to be sent.
\param[out] outData Pointer to Data object that will be used by the target
message observer to return results. This parameter may be NULL if no data is to be
returned.
\return Returns an id associated with the sent message. This id is not a unique
runtime handle but is instead a running counter that will roll over when max unsigned
integer messages have been sent.
\note If the Message is a monostate, Targets will be ignored.

*/
dmz::UInt32
dmz::Message::send (
      const HandleContainer &Targets,
      const Data *InData,
      Data *outData) const {

   UInt32 result (0);

   if (_context && _context->dispatch) {

      if (_context->monostate) {

         _context->dispatch->send_monostate_warning (*this);

         send (0, InData, outData);
      }
      else {

         Handle target (Targets.get_first ());

         while (target) {

            result = _context->dispatch->send (
               (result == 0 ? True : False),
               *this,
               target,
               InData,
               outData);

            target = Targets.get_next ();
         }
      }
   }

   return result;
}
Example #18
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);
         }
      }
   }
}
Example #19
0
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_handle (list->Object)) {

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