SST  15.1.0
StructuralSimulationToolkit
oneshot.h
1 // Copyright 2009-2025 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-2025, 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 
24 namespace SST {
25 
26 class TimeConverter;
27 
28 /**
29  * A OneShot Event class.
30  *
31  * Calls callback functions (handlers) on a specified period
32  */
33 class OneShot : public Action
34 {
35 public:
36  /**
37  Base handler for OneShot callbacks.
38  */
40 
41  /**
42  Used to create 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>(this, &classname::function_name)
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, dataT>(this, &classname::function_name, data)
58  */
59  template <typename classT, typename dataT = void>
60  using Handler
61  [[deprecated("Handler has been deprecated. Please use Handler2 instead as it supports checkpointing.")]] =
63 
64  /**
65  Used to create checkpointable handlers for OneShot. The callback function is
66  expected to be in the form of:
67 
68  void func()
69 
70  In which case, the class is created with:
71 
72  new OneShot::Handler2<classname, &classname::function_name>(this)
73 
74  Or, to add static data, the callback function is:
75 
76  void func(dataT data)
77 
78  and the class is created with:
79 
80  new OneShot::Handler2<classname, &classname::function_name, dataT>(this, data)
81  */
82  template <typename classT, auto funcT, typename dataT = void>
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
An Action is a schedulable Activity which is not an Event.
Definition: action.h:26
Base template for the class.
Definition: ssthandler.h:1273
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:27
Definition: action.cc:18
void registerHandler(OneShot::HandlerBase *handler)
Add a handler to be called on this OneShot Event.
Definition: oneshot.h:97
Base template for handlers which don&#39;t take a class defined argument.
Definition: ssthandler.h:702
Event Handler class with user-data argument.
Definition: ssthandler.h:1201
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
A OneShot Event class.
Definition: oneshot.h:33