SST 16.0.0
Structural Simulation Toolkit
oneshot.h
1// Copyright 2009-2026 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2026, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_ONESHOT_H
13#define SST_CORE_ONESHOT_H
14
15#ifndef COMPILING_ONESHOT_CC
16#warning \
17 "OneShot was not intended to be part of the public element API and has known bugs that will not be fixed. It is being removed from the public API and oneshot.h will be removed in SST 16"
18#endif
19
20#include "sst/core/action.h"
21#include "sst/core/sst_types.h"
22#include "sst/core/ssthandler.h"
23
24namespace SST {
25
26class TimeConverter;
27
28/**
29 * A OneShot Event class.
30 *
31 * Calls callback functions (handlers) on a specified period
32 */
33class OneShot : public Action
34{
35public:
36 /**
37 Base handler for OneShot callbacks.
38 */
40
41 /**
42 Used to create checkpointable handlers for OneShot. The callback function is
43 expected to be in the form of:
44
45 void func()
46
47 In which case, the class is created with:
48
49 new OneShot::Handler<classname, &classname::function_name>(this)
50
51 Or, to add static data, the callback function is:
52
53 void func(dataT data)
54
55 and the class is created with:
56
57 new OneShot::Handler<classname, &classname::function_name, dataT>(this, data)
58 */
59 template <typename classT, auto funcT, typename dataT = void>
61
62 /**
63 Used to create checkpointable handlers for OneShot. The callback function is
64 expected to be in the form of:
65
66 void func()
67
68 In which case, the class is created with:
69
70 new OneShot::Handler<classname, &classname::function_name>(this)
71
72 Or, to add static data, the callback function is:
73
74 void func(dataT data)
75
76 and the class is created with:
77
78 new OneShot::Handler<classname, &classname::function_name, dataT>(this, data)
79 */
80 template <typename classT, auto funcT, typename dataT = void>
81 using Handler2 [[deprecated(
82 "The name Handler2 has been deprecated and will be removed in SST 17. Please rename Handler2 to Handler.")]]
84
85
86 /////////////////////////////////////////////////
87
88 /** Create a new One Shot for a specified time that will callback the
89 handler function.
90 Note: OneShot cannot be canceled, and will always callback after
91 the timedelay.
92 */
93 OneShot(TimeConverter* timeDelay, int priority = ONESHOTPRIORITY) {}
94 ~OneShot() {}
95
96 /** Add a handler to be called on this OneShot Event */
98};
99
100} // namespace SST
101
102#endif // SST_CORE_ONESHOT_H
A OneShot Event class.
Definition oneshot.h:34
SSTHandlerBase< void, void > HandlerBase
Base handler for OneShot callbacks.
Definition oneshot.h:39
OneShot(TimeConverter *timeDelay, int priority=ONESHOTPRIORITY)
Create a new One Shot for a specified time that will callback the handler function.
Definition oneshot.h:93
SSTHandler< void, void, classT, dataT, funcT > Handler
Used to create checkpointable handlers for OneShot.
Definition oneshot.h:60
void registerHandler(OneShot::HandlerBase *handler)
Add a handler to be called on this OneShot Event.
Definition oneshot.h:97
Base template for handlers which take a class defined argument.
Definition ssthandler.h:79
Base template for the class.
Definition ssthandler.h:1102
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:31