Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Contributions to C::B => Topic started by: mmkider on April 01, 2009, 06:10:54 am

Title: Add event order(high, mid and low)?
Post by: mmkider on April 01, 2009, 06:10:54 am
I think about event order is requirement.

If I use the same event  into my two plug-ins,I can't estimate this event order because that depend on the name of plugin.

I only force to change my  plug-in's name or create a new event to use.
However, I think it's not general if event order is important.

Any suggest ??

Thank you.
Title: Re: Add event order(high, mid and low)?
Post by: MortenMacFly on April 10, 2009, 07:49:06 pm
I think about event order is requirement. [...]
I am sorry to say this but (at least) I did not understand what you mean exactly. What events are you talking about? SDK events or self-made events? And why should the order of an event matter? Can you provide an example?
Title: Re: Add event order(high, mid and low)?
Post by: mmkider on April 10, 2009, 08:32:28 pm
I think about event order is requirement. [...]
I am sorry to say this but (at least) I did not understand what you mean exactly. What events are you talking about? SDK events or self-made events? And why should the order of an event matter? Can you provide an example?

For the sdk of codeblocks, codeblocks event will be stored in the map.
sometime these events should have priority for some plug-in.

For some of the plug-in dependencies, call evnets need a more specific order.

My english is poor, I post some pesudo-code for my mind.

Thank you for your reply.  :lol:

Code
enum EVENT_PRIORITY
{
    LOW=0,
    MID,
   HIGH
};


void RegisterEventSink(wxEventType eventType, IEventFunctorBase<CodeBlocksEvent>* functor,EVENT_PRIORITY priority=EVENT_PRIORITY::LOW);


void Manager::RegisterEventSink(wxEventType eventType, IEventFunctorBase<CodeBlocksEvent>* functor,EVENT_PRIORITY priority)
{
m_EventSinks[priority][eventType].push_back(functor);
}


Code
        EventSinksMap m_EventSinks[2];

Code
Manager::Get()->RegisterEventSink(cbEVT_EDITOR_OPEN, new cbEventFunctor<DebuggerGDB, CodeBlocksEvent>(this, &DebuggerGDB::OnEditorOpened),EVENT_PRIORITY::MID);