/*!

\brief Serializes the EventType definitions in a RuntimeContext and stores the result
in a Config object.
\ingroup Runtime
\details Format of the returned Config object:
\code
<runtime>
   <event-type name="String" parent="String"/>
</runtime>
\endcode

- \b event-type.name String containing the name of the EventType.
- \b event-type.parent String containing the name of the parent EventType.
- \b event-type.* Config data of the EventType.

\param[in] context Pointer to the RuntimeContext to serialize.
\return Returns a Config object containing the serialized EventType definitions in the
RuntimeContext.

*/
dmz::Config
dmz::runtime_event_types_to_config (RuntimeContext *context) {

   RuntimeContextDefinitions *defs = (context ? context->get_definitions_context () : 0);

   Config result (RuntimeName);

   if (defs) {

      defs->ref ();

      const EventType RootEventType = Definitions (context).get_root_event_type ();

      HashTableHandleIterator it;
      ObjectType *otype (0);
      EventType *etype (0);

      while (defs->eventHandleTable.get_next (it, etype)) {

         if (RootEventType != *etype) {

            Config data ("event-type");
            data.store_attribute ("name", etype->get_name ());
            EventType parent = etype->get_parent ();

            if (parent != RootEventType) {

               data.store_attribute ("parent", parent.get_name ());
            }

            data.add_children (etype->get_config ());

            result.add_config (data);
         }
      }

      defs->unref ();
   }

   return result;
}
Exemple #2
0
//! Gets root event type.
dmz::EventType
dmz::Definitions::get_root_event_type () const {

   EventType result;

   if (_state.context && _state.defs) {

      EventType *ptr (_state.defs->eventNameTable.lookup (LocalRootEventTypeName));

      if (!ptr) {

         TypeContext *rootTypeContext = new TypeContext (
            LocalRootEventTypeName,
            _state.context,
            0,
            0);

         if (rootTypeContext) {

            ptr = new EventType (rootTypeContext);

            if (ptr && _state.defs->eventNameTable.store (ptr->get_name (), ptr)) {

               _state.defs->eventHandleTable.store (ptr->get_handle (), ptr);
            }
            else if (ptr) { delete ptr; ptr = 0; }

            rootTypeContext->unref ();
         }
      }

      if (ptr) { result = *ptr; }
   }

   return result;
}
Exemple #3
0
dmz::Handle
dmz::EventModuleBasic::create_event (
      const EventType &Type,
      const EventLocalityEnum Locality) {

   Handle result (0);

   if (Type && (Locality != EventLocalityUnknown)) {

      EventStruct *event (_recycleList);

      if (event) { _recycleList = _recycleList->next; event->next = 0; event->reset (); }
      else { event = new EventStruct; }

      if (event) {

         result = event->get_handle (Type.get_name (), _PluginInfoData.get_context ());

         if (result) {

            if (_eventTable.store (result, event)) {

               event->type = Type;
               event->locality = Locality;
            }
            else {

               result = 0;
               event->next = _recycleList; _recycleList = event;
            }
         }
      }
   }

   return result;
}