12 #ifndef SST_CORE_SSTHANDLER_H 13 #define SST_CORE_SSTHANDLER_H 15 #include "sst/core/profile/profiletool.h" 16 #include "sst/core/sst_types.h" 47 virtual void handlerStart(uintptr_t UNUSED(key)) {}
48 virtual void handlerEnd(uintptr_t UNUSED(key)) {}
96 static std::atomic<HandlerId_t> id_counter;
104 for (
auto& x : tools )
105 x.first->handlerStart(x.second);
109 for (
auto& x : tools )
110 x.first->handlerEnd(x.second);
119 auto key = tool->registerHandler(mdata);
120 tools.push_back(std::make_pair(tool, key));
123 HandlerId_t getId() {
return my_id; }
126 std::vector<std::pair<HandlerProfileToolAPI*, uintptr_t>> tools;
130 HandlerProfileToolList* profile_tools;
134 SSTHandlerBaseProfile() : profile_tools(nullptr) {}
136 virtual ~SSTHandlerBaseProfile()
138 if ( profile_tools )
delete profile_tools;
141 void addProfileTool(HandlerProfileToolAPI* tool,
const HandlerMetaData& mdata)
143 if ( !profile_tools ) profile_tools =
new HandlerProfileToolList();
144 profile_tools->addProfileTool(tool, mdata);
147 void transferProfilingInfo(SSTHandlerBaseProfile* handler)
149 if ( handler->profile_tools ) {
150 profile_tools = handler->profile_tools;
151 handler->profile_tools =
nullptr;
163 return profile_tools->getId();
169 template <
typename returnT,
typename argT>
173 virtual returnT operator_impl(argT) = 0;
178 inline returnT operator()(argT arg)
180 if ( profile_tools ) {
183 profile_tools->handlerStart();
184 auto ret = operator_impl(arg);
185 profile_tools->handlerEnd();
188 return operator_impl(arg);
193 template <
typename argT>
197 virtual void operator_impl(argT) = 0;
202 inline void operator()(argT arg)
204 if ( profile_tools ) {
205 profile_tools->handlerStart();
207 profile_tools->handlerEnd();
218 template <
typename returnT,
typename argT,
typename classT,
typename dataT =
void>
222 typedef returnT (classT::*PtrMember)(argT, dataT);
224 const PtrMember member;
233 SSTHandler(classT*
const object, PtrMember member, dataT data) :
240 returnT operator_impl(argT arg)
override {
return (object->*member)(arg, data); }
247 template <
typename returnT,
typename argT,
typename classT>
251 typedef returnT (classT::*PtrMember)(argT);
252 const PtrMember member;
263 returnT operator_impl(argT arg)
override {
return (object->*member)(arg); }
268 template <
typename returnT>
273 virtual returnT operator_impl() = 0;
281 inline returnT operator()()
283 if ( profile_tools ) {
284 profile_tools->handlerStart();
285 auto ret = operator_impl();
286 profile_tools->handlerEnd();
289 return operator_impl();
298 virtual void operator_impl() = 0;
306 inline void operator()()
308 if ( profile_tools ) {
309 profile_tools->handlerStart();
311 profile_tools->handlerEnd();
314 return operator_impl();
321 template <
typename returnT,
typename classT,
typename dataT =
void>
325 typedef returnT (classT::*PtrMember)(dataT);
327 const PtrMember member;
343 void operator_impl()
override {
return (object->*member)(data); }
350 template <
typename returnT,
typename classT>
354 typedef returnT (classT::*PtrMember)();
355 const PtrMember member;
369 void operator_impl()
override {
return (object->*member)(); }
374 #endif // SST_CORE_SSTHANDLER_H Handlers with 1 handler defined argument to callback from caller.
Definition: ssthandler.h:170
Handler class with user-data argument.
Definition: ssthandler.h:219
HandlerId_t getId()
Get the ID for this Handler.
Definition: ssthandler.h:160
Handlers with no arguments to callback from caller.
Definition: ssthandler.h:269
virtual ~SSTHandlerBaseNoArgs()
Handler function.
Definition: ssthandler.h:304
Event Handler class with user-data argument.
Definition: ssthandler.h:322
Parameter store.
Definition: params.h:55
SSTHandlerNoArgs(classT *const object, PtrMember member, dataT data)
Constructor.
Definition: ssthandler.h:336
Functor classes for Event handling.
Definition: ssthandler.h:89
SSTHandler(classT *const object, PtrMember member, dataT data)
Constructor.
Definition: ssthandler.h:233
SSTHandler(classT *const object, PtrMember member)
Constructor.
Definition: ssthandler.h:260
SSTHandlerNoArgs(classT *const object, PtrMember member)
Constructor.
Definition: ssthandler.h:363
virtual ~SSTHandlerBaseNoArgs()
Handler function.
Definition: ssthandler.h:279