12 #ifndef SST_CORE_SSTHANDLER_H 13 #define SST_CORE_SSTHANDLER_H 15 #include "sst/core/profile/profiletool.h" 16 #include "sst/core/serialization/serializable.h" 17 #include "sst/core/sst_types.h" 51 virtual void handlerStart(uintptr_t UNUSED(key)) {}
52 virtual void handlerEnd(uintptr_t UNUSED(key)) {}
133 static std::atomic<HandlerId_t> id_counter;
141 for (
auto& x : tools )
142 x.first->handlerStart(x.second);
146 for (
auto& x : tools )
147 x.first->handlerEnd(x.second);
156 auto key = tool->registerHandler(mdata);
157 tools.push_back(std::make_pair(tool, key));
160 HandlerId_t getId() {
return my_id; }
164 std::vector<std::pair<HandlerProfileToolAPI*, uintptr_t>> tools;
168 HandlerProfileToolList* profile_tools;
172 SSTHandlerBaseProfile() : profile_tools(nullptr) {}
174 virtual ~SSTHandlerBaseProfile()
176 if ( profile_tools )
delete profile_tools;
179 void addProfileTool(HandlerProfileToolAPI* tool,
const HandlerMetaData& mdata)
181 if ( !profile_tools ) profile_tools =
new HandlerProfileToolList();
182 profile_tools->addProfileTool(tool, mdata);
185 void transferProfilingInfo(SSTHandlerBaseProfile* handler)
187 if ( handler->profile_tools ) {
188 profile_tools = handler->profile_tools;
189 handler->profile_tools =
nullptr;
201 return profile_tools->getId();
209 template <
typename returnT,
typename argT>
213 virtual returnT operator_impl(argT) = 0;
218 inline returnT operator()(argT arg)
220 if ( profile_tools ) {
221 if constexpr ( std::is_void_v<returnT> ) {
222 profile_tools->handlerStart();
224 profile_tools->handlerEnd();
228 profile_tools->handlerStart();
229 auto ret = operator_impl(arg);
230 profile_tools->handlerEnd();
234 return operator_impl(arg);
241 template <
typename returnT>
246 virtual returnT operator_impl() = 0;
254 inline returnT operator()()
256 if ( profile_tools ) {
257 if constexpr ( std::is_void_v<returnT> ) {
258 profile_tools->handlerStart();
260 profile_tools->handlerEnd();
264 profile_tools->handlerStart();
265 auto ret = operator_impl();
266 profile_tools->handlerEnd();
270 return operator_impl();
272 ImplementVirtualSerializable(SSTHandlerBase)
283 template <
typename returnT,
typename argT,
typename classT,
typename dataT =
void>
287 typedef returnT (classT::*PtrMember)(argT, dataT);
289 const PtrMember member;
298 SSTHandler(classT*
const object, PtrMember member, dataT data) :
305 returnT operator_impl(argT arg)
override {
return (object->*member)(arg, data); }
314 template <
typename returnT,
typename argT,
typename classT>
318 typedef returnT (classT::*PtrMember)(argT);
319 const PtrMember member;
330 returnT operator_impl(argT arg)
override {
return (object->*member)(arg); }
336 template <
typename returnT>
341 virtual returnT operator_impl() = 0;
349 inline returnT operator()()
351 if ( profile_tools ) {
352 if constexpr ( std::is_void_v<returnT> ) {
353 profile_tools->handlerStart();
355 profile_tools->handlerEnd();
359 profile_tools->handlerStart();
360 auto ret = operator_impl();
361 profile_tools->handlerEnd();
365 return operator_impl();
367 ImplementVirtualSerializable(SSTHandlerBaseNoArgs)
376 virtual void operator_impl() = 0;
384 inline void operator()()
386 if ( profile_tools ) {
387 profile_tools->handlerStart();
389 profile_tools->handlerEnd();
392 return operator_impl();
395 ImplementVirtualSerializable(SSTHandlerNoArgs)
401 template <
typename returnT,
typename classT,
typename dataT =
void>
405 typedef returnT (classT::*PtrMember)(dataT);
407 const PtrMember member;
423 void operator_impl()
override {
return (object->*member)(data); }
432 template <
typename returnT,
typename classT>
436 typedef returnT (classT::*PtrMember)();
437 const PtrMember member;
451 void operator_impl()
override {
return (object->*member)(); }
465 template <
typename returnT,
typename argT,
typename classT,
typename dataT, auto funcT>
472 static_assert(std::is_fundamental<dataT>::value,
"Mismatched handler templates.");
473 static_assert(!std::is_fundamental<dataT>::value,
"Mismatched handler templates.");
480 template <
typename returnT,
typename argT,
typename classT,
typename dataT, returnT (
classT::*funcT)(argT, dataT)>
498 returnT operator_impl(argT arg)
override {
return (object->*funcT)(arg, data); }
507 ImplementSerializable(SSTHandler2)
514 template <
typename returnT,
typename argT,
typename classT, returnT (
classT::*funcT)(argT)>
528 returnT operator_impl(argT arg)
override {
return (object->*funcT)(arg); }
536 ImplementSerializable(SSTHandler2)
543 template <
typename returnT,
typename classT,
typename dataT, returnT (
classT::*funcT)(dataT)>
558 returnT operator_impl()
override {
return (object->*funcT)(data); }
567 ImplementSerializable(SSTHandler2)
574 template <
typename returnT,
typename classT, returnT (
classT::*funcT)()>
588 returnT operator_impl()
override {
return (object->*funcT)(); }
596 ImplementSerializable(SSTHandler2)
604 template <
typename returnT,
typename classT>
605 class SSTHandlerNoArgs<returnT, classT, void> :
public SSTHandlerBaseNoArgs<returnT>
608 typedef returnT (classT::*PtrMember)();
609 const PtrMember member;
618 SSTHandlerBaseNoArgs<returnT>(),
623 void operator_impl()
override {
return (object->*member)(); }
631 #endif // SST_CORE_SSTHANDLER_H This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Handlers with 1 handler defined argument to callback from caller.
Definition: ssthandler.h:210
Base template for the class.
Definition: ssthandler.h:466
Handler class with user-data argument.
Definition: ssthandler.h:284
HandlerId_t getId()
Get the ID for this Handler.
Definition: ssthandler.h:198
Definition: serializable.h:118
Handlers with no arguments to callback from caller.
Definition: ssthandler.h:337
SSTHandler2(classT *const object)
Constructor.
Definition: ssthandler.h:585
virtual ~SSTHandlerBaseNoArgs()
Handler function.
Definition: ssthandler.h:382
Event Handler class with user-data argument.
Definition: ssthandler.h:402
virtual ~SSTHandlerBase()
Handler function.
Definition: ssthandler.h:252
SSTHandler2(classT *const object, dataT data)
Constructor.
Definition: ssthandler.h:494
SSTHandler2(classT *const object, dataT data)
Constructor.
Definition: ssthandler.h:555
SSTHandler2(classT *const object)
Constructor.
Definition: ssthandler.h:525
Parameter store.
Definition: params.h:55
SSTHandlerNoArgs(classT *const object, PtrMember member, dataT data)
Constructor.
Definition: ssthandler.h:416
Functor classes for Event handling.
Definition: ssthandler.h:126
SSTHandler(classT *const object, PtrMember member, dataT data)
Constructor.
Definition: ssthandler.h:298
SSTHandler(classT *const object, PtrMember member)
Constructor.
Definition: ssthandler.h:327
SSTHandlerNoArgs(classT *const object, PtrMember member)
Constructor.
Definition: ssthandler.h:445
virtual ~SSTHandlerBaseNoArgs()
Handler function.
Definition: ssthandler.h:347