Example #1
0
ExternalEventSource*
LaunchDaemon::_FindEvent(const char* owner, const char* name) const
{
	if (name == NULL)
		return NULL;

	BString eventName = name;
	eventName.ToLower();

	EventMap::const_iterator found = fEvents.find(eventName);
	if (found != fEvents.end())
		return found->second;

	if (owner == NULL)
		return NULL;

	eventName.Prepend("/");
	eventName.Prepend(get_leaf(owner));

	found = fEvents.find(eventName);
	if (found != fEvents.end())
		return found->second;

	return NULL;
}
Example #2
0
/// Обновление
  void UpdateEvent (const char* name, ResourceState state)
  {
    EventMap::iterator iter = event_map.find (name);

    if (iter == event_map.end ())
    {
      EventPtr event = EventPtr (new EventDesc (name, state), false);

      EventList::iterator iter = event_list.insert (event_list.end (), event);

      event_map.insert_pair (name, iter);
    }
    else
    {
      EventPtr event = *iter->second;

      if (state == event->state)
        return;

      if (event->state == ResourceState_Ignore)
      {
        event_list.splice (event_list.end (), event_list, iter->second);

        event->state = state;

        return;
      }

      switch (state)
      {
        case ResourceState_Unloaded:
          event->state = ResourceState_Ignore;
          break;
        case ResourceState_Prefetched:
          if (event->state != ResourceState_Unloaded)
            return;

          event_list.splice (event_list.end (), event_list, iter->second);

          event->state = state;          

          break;
        case ResourceState_Loaded:
          if (event->state == ResourceState_Unloaded) event->state = ResourceState_Ignore;
          else 
          {
            event_list.splice (event_list.end (), event_list, iter->second);

            event->state = state;
          }

          break;
        default:
          break;
      }
    }    
  }