SST 16.0.0
Structural Simulation Toolkit
stopAction.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_STOPACTION_H
13#define SST_CORE_STOPACTION_H
14
15#include "sst/core/action.h"
16#include "sst/core/output.h"
17
18#include <cinttypes>
19#include <iostream>
20#include <string>
21
22namespace SST {
23
24/**
25 * Action which causes the Simulation to end
26 */
27class StopAction : public Action
28{
29private:
30 std::string message;
31 bool print_message;
32
33public:
34 StopAction()
35 {
36 setPriority(STOPACTIONPRIORITY);
37 print_message = false;
38 }
39
40 /** Create a new StopAction which includes a message to be printed when it fires
41 */
42 explicit StopAction(const std::string& msg)
43 {
44 setPriority(STOPACTIONPRIORITY);
45 print_message = true;
46 message = msg;
47 }
48
49 void execute() override
50 {
51 if ( print_message ) {
52 Output::getDefaultObject().output("%s\n", message.c_str());
53 }
55 delete this;
56 }
57
58 void print(const std::string& header, Output& out) const override
59 {
60 out.output("%s StopAction to be delivered at %" PRIu64 "\n", header.c_str(), getDeliveryTime());
61 }
62
63 void serialize_order(SST::Core::Serialization::serializer& ser) override
64 {
65 Action::serialize_order(ser);
66 SST_SER(message);
67 SST_SER(print_message);
68 }
69 ImplementSerializable(SST::StopAction)
70};
71
72} // namespace SST
73
74#endif // SST_CORE_STOPACTION_H
void endSimulation()
Called to signal to the Simulation object to end the simulation.
Definition action.cc:21
void setPriority(uint64_t priority)
Set the priority of the Activity.
Definition activity.h:200
SimTime_t getDeliveryTime() const
Return the time at which this Activity will be delivered.
Definition activity.h:150
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file.
Definition output.h:58
void output(uint32_t line, const char *file, const char *func, const char *format,...) const
Output the message with formatting as specified by the format parameter.
Definition output.h:189
void execute() override
Function which will be called when the time for this Activity comes to pass.
Definition stopAction.h:49
StopAction(const std::string &msg)
Create a new StopAction which includes a message to be printed when it fires.
Definition stopAction.h:42