about listeners idea
Posted on 2011-05-24 13:10 Tommy Liang 閱讀(237) 評論(0) 編輯 收藏 引用 所屬分類: development ideathink about the grid listeners of grid, it's so complicate that it's hard to maintain relationship and status,I think it's necessary to arose an intermediate level to cope with this;
perhaps like this:
//somewhere in A.hpp ...
Grid A("guid_a");
//somewhere else in B.hpp
Grid B("guid_b");
//somewhere else in C.hpp
Form c("guid_c");
A.AddListener("guid_b"); //why use string but not directly object pointer? because perhaps listeners is not yet valid at this runtime, this is just a registeration work
A.AddListener("guid_c");
//cope with the code when A select a row:
GridListenerHandler handler(A);
handler.HandleListeners();
//how to handle? like follow:
Context context = ...;
BOOST_FOREACH(shared_ptr<IListener> listener, InnerGetListeners())
{
listener->Execute(context);
}
perhaps like this:
//somewhere in A.hpp ...
Grid A("guid_a");
//somewhere else in B.hpp
Grid B("guid_b");
//somewhere else in C.hpp
Form c("guid_c");
A.AddListener("guid_b"); //why use string but not directly object pointer? because perhaps listeners is not yet valid at this runtime, this is just a registeration work
A.AddListener("guid_c");
//cope with the code when A select a row:
GridListenerHandler handler(A);
handler.HandleListeners();
//how to handle? like follow:
Context context = ...;
BOOST_FOREACH(shared_ptr<IListener> listener, InnerGetListeners())
{
listener->Execute(context);
}


