예제 #1
0
/*!

\brief Finds Config.
\details Looks for Config up the EventType tree until Config is found or the root
EventType is reached. Uses dmz::Config::lookup_all_config_merged().
\param[in] Name String containing the name of the Config data to find.
\param[out] type EventType that the Config was found in.
\return Returns a Config object. The Config object will be empty if the named Config
can not be found.

*/
dmz::Config
dmz::EventType::find_config (const String &Name, EventType &type) const {

   Config result;

   EventType current (_context);

   while (current) {

      if (current.get_config ().lookup_all_config_merged (Name, result)) {

         type = current;
         current.set_type_context (0);
      }
      else { current.become_parent (); }
   }

   return result;
}
예제 #2
0
/*!

\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;
}